Site icon Console Flare Blog

Build your first Python app in 5 minutes: ‘Ask Me Anything’

Before jumping into the Python app, let us have a brief about Python. We all know that Python is a general-purpose programming language which means Python can be used for various requirements whether it is data science, machine learning, task automation, game development, or web-based app development. Python has a wide range of libraries to perform tasks like numpy for calculations, pandas for data analytics, and seaborn for data visualizations, in the same way, python has a library called Streamlit which helps us to create web-based applications.

In this blog, we are creating a simple Ask Me Anything application, where any user can input the name of the topic and search for it. In this program, we will use libraries like Streamlit and Wikipedia.

Step 1: In the first step of the Python app, we need to install Streamlit and Wikipedia libraries.

We will give command in the terminal and then press enter and wait for a few seconds and then we will give the command for installation of the Wikipedia library

Press enter and wait for a few seconds.

For more such content and regular updates, follow us on FacebookInstagramLinkedIn

Step 2: Now we are going to import these libraries.Python app

Copy
import streamlit as st
import wikipedia
Python

Step 3: In this step, we are going to create a title for the Python app and an input box where a user can search for the topic.

Copy
st.title('Welcome to, "Ask me Anything"')
topic=st.text_input('Enter the topic you want to search here')
Python

topic is a variable that stores the topic which will be inputted by the user.

Output:

Step 4: Now we need to create a button “Generate” which will generate texts about the topic searched by the user.Python app

Copy
if st.button('Generate'):
    text=wikipedia.summary(topic,sentences=10)
    text=text.split('.')
    st.subheader(f'You have searched for, {topic.title()}')
    for i,t in enumerate(text):
        st.write(f'{i+1}. {t}')
Python

Step 5: Finally, it is time for the results.Python app

Python is the easiest and most general-purpose programming language which means it can be used to perform a variety of tasks whether web-based development, software development, data analysis, and a lot more. This program is just an example of the easiness of Python programming language. You can create more such Python app with the help of Streamlit and other libraries. Python python app

Right now, data science has become one of the fields where companies are hiring regularly and there is a lot of gap in the demand and supply of data analysts in the market.

If you wish to learn more about data science or want to curve your career in the data science field feel free to join our free workshop on Masters in Data Science with PowerBI, where you will get to know how exactly the data science field works and why companies are ready to pay handsome salaries in this field.

In this workshop, you will get to know each tool and technology from scratch that will make you skillfully eligible for any data science profile.

To join this workshop, register yourself on consoleflare and we will call you back.

Thinking, Why Console Flare?

Register yourself on consoleflare and we will call you back.

Exit mobile version