📌 This guide is made for absolute beginners.
No prior knowledge of web development needed.
Just know basic Python, and you’re good to go!
Streamlit is a free Python library that turns your Python scripts into interactive web apps in seconds.
You write simple Python code → Streamlit makes a live website.
You can build an app that:
- Takes user input
- Runs a machine learning model
- Shows a chart
- All without knowing HTML, CSS, or JavaScript
👉 Think of it like PowerPoint for code, but interactive.
| Reason | Explanation | Real Example |
|---|---|---|
| ⏱️ Fast Development | Write 5–10 lines → get a working app | Build a data viewer in 10 minutes |
| 🧠 Easy with Data Science | Works perfectly with Pandas, NumPy, Matplotlib | Show a chart from a CSV file instantly |
| 🖥️ Real-Time Reload | Save code → app updates automatically | No need to restart server |
| ☁️ Easy to Deploy | One click deploy on Streamlit Community Cloud | Share your app with the world for free |
| ✔️ | Why It’s Good |
|---|---|
| No frontend skills needed | You don’t need to learn HTML/CSS/JS |
| Simple syntax | Just use st.write(), st.button() etc. |
| Great for demos | Perfect for showing your ML model to others |
| Free & open-source | No cost to use or deploy |
| Built-in widgets | Sliders, buttons, file upload — all ready |
| ❌ | What You Can’t Do Easily |
|---|---|
| Not for big websites | Not for Facebook or Amazon-type sites |
| Limited design control | Hard to make custom designs (like animations) |
| Runs one user at a time | Not ideal for 10,000 users at once |
| Always shows code | If someone views source, they see your logic |
🎯 Best for: Prototypes, dashboards, school projects, ML demos
🚫 Not for: Large websites, e-commerce, mobile apps
Here are real-life situations where Streamlit shines:
You trained a model to predict house prices.
👉 Use Streamlit to:
- Let user enter house size, location, bedrooms
- Show predicted price
- Display chart of similar houses
✅ No need to build a full website!
You have sales data in a CSV file.
👉 Use Streamlit to:
- Upload the file
- Show tables and charts
- Add filters (e.g., "Show only 2023 data")
✅ Great for sharing with your team.
You’re a student doing a data science project.
👉 Use Streamlit to:
- Show your analysis
- Let teacher interact with your code
- Present live results
✅ Teachers love interactive apps!
You want to test an idea before building a full app.
👉 Use Streamlit to:
- Build a mini version in 1 hour
- Show it to your boss or client
- Get feedback fast
✅ Save time and money.
Your team needs a small tool to process data.
👉 Use Streamlit to:
- Build a form to upload files
- Clean data automatically
- Download the result
✅ No need to hire a web developer.
| Situation | Why Not |
|---|---|
| Building a company website | Use WordPress, React, or HTML |
| Making a mobile app | Use Flutter, React Native |
| High-traffic app (10k+ users) | Streamlit is slow under heavy load |
| Need login system or payments | Streamlit doesn’t support this easily |
| Want full design control | Streamlit has limited styling options |
| Feature | Streamlit | Flask | Django | Gradio |
|---|---|---|---|---|
| Easy to learn | ✅ Yes | ❌ Medium | ❌ Hard | ✅ Yes |
| For ML apps | ✅ Perfect | ✅ Good | ✅ Good | ✅ Good |
| Design control | ❌ Low | ✅ High | ✅ High | ❌ Low |
| Deployment | ✅ Very easy | ✅ Medium | ✅ Medium | ✅ Easy |
| Best for beginners | ✅ Yes | ❌ No | ❌ No | ✅ Yes |
✅ Streamlit = Best for beginners & fast ML apps
✅ Django/Flask = Best for full websites
Let’s build a tiny app that asks your name and greets you.
import streamlit as st name = st.text_input("What is your name?") if name: st.write(f"Hello, {name}! 👋")streamlit run app.py👉 Open browser → type your name → see greeting!
✅ You just built a web app!
| Yes, if you… | No, if you… |
|---|---|
| Want to build apps fast | Want to build big websites |
| Work with data or ML | Need full design control |
| Are a beginner in coding | Want to make mobile apps |
| Want to impress in school/job | Need user login or payments |
Streamlit is not for everything, but it’s perfect for learning and fast projects.
🎯 If you know Python, you can build real apps today.
🚀 Start small. Build one app. Share it. Learn more.
✅ You don’t need to be an expert. Just start.
🎯 This guide is for non-technical learners.
No prior knowledge of coding or computers needed.
We’ll go step by step, like a recipe.
Before we begin, make sure you have:
| Thing | Why You Need It |
|---|---|
| A computer (Windows, Mac, or Linux) | To run the apps |
| Internet connection | To download tools |
| Basic typing skills | To type simple commands |
✅ That’s it! No special skills needed.
Streamlit runs on Python — a programming language.
But don’t worry — you don’t need to learn all of Python.
Just install it, like installing any app.
- Go to: https://www.python.org/downloads/
- Click the big yellow button: Download Python
- When the file downloads, double-click it
- In the installer:
- ✅ Check: Add Python to PATH (very important!)
- Click: Install Now
- Wait for it to finish
- Close the window
✅ Python is now installed!
💡 Tip: If you see a message about "security", click "Run anyway".
- Go to: https://www.python.org/downloads/
- Click Download Python
- Open the downloaded file
- Double-click
python-xxx.pkg - Follow the steps and click "Continue" until done
- Wait and finish
✅ Python is now installed!
Open Terminal (you can search for it in your apps).
Type these commands one by one:
sudo apt update👉 Press Enter, type your password if asked.
sudo apt install python3 python3-pip -y👉 This installs Python and a tool called pip.
Check if it worked:
python3 --version👉 You should see something like Python 3.8 or higher.
✅ Python is now installed!
pip is a tool that helps install libraries like Streamlit.
Open Command Prompt (Windows) or Terminal (Mac/Linux) and type:
pip --version👉 If you see a version (like pip 23.0), great! You’re done.
👉 If you see "command not found", run this:
Download from: https://bootstrap.pypa.io/get-pip.py
Save the file as get-pip.py
Then in Command Prompt/Terminal, go to the folder where you saved it and run:
python get-pip.py✅ Now pip is installed.
Now we install Streamlit using pip.
In Command Prompt (Windows) or Terminal (Mac/Linux), type:
pip install streamlitWait for it to finish. You’ll see lines like:
Downloading streamlit... Installing collected packages: streamlit Successfully installed streamlit-1.29.0 ✅ Streamlit is now installed!
Let’s make a simple app to check if everything works.
- Open Notepad (Windows) or TextEdit (Mac)
- Type this code:
import streamlit as st st.title("My First App") st.write("Hello! This is my first Streamlit app.")- Save the file as:
my_app.py- Save it on your Desktop
- Make sure it ends with
.py(not.txt)
💡 On Mac: In TextEdit, go to Format → Make Plain Text before saving.
Open Command Prompt (Windows) or Terminal (Mac/Linux).
Type:
cd Desktop👉 This tells the computer: “Go to the Desktop”.
Then run:
streamlit run my_app.pyWait a few seconds.
👉 A web browser will open automatically at http://localhost:8501
You should see:
- A title: "My First App"
- A message: "Hello! This is my first Streamlit app."
✅ Congratulations! You just built and ran your first web app!
🔁 To stop the app, go back to Command Prompt/Terminal and press
Ctrl + C
Create a folder called streamlit_apps on your Desktop.
Inside it, save all your .py files like:
my_app.pydata_viewer.pyml_demo.py
This keeps everything organized.
| Problem | Solution |
|---|---|
streamlit is not recognized | You forgot to install it. Run pip install streamlit again |
| App doesn’t open in browser | Copy the link http://localhost:8501 and paste in Chrome/Firefox |
File saves as .txt not .py | In Notepad, choose "All Files" when saving, and write my_app.py |
| Python not found | Make sure you checked Add Python to PATH during install |
| Slow internet | Wait longer. It may take 2–5 minutes to install |
| You Did | What It Means |
|---|---|
| Installed Python | Gave your computer the ability to run code |
Ran pip install streamlit | Added the Streamlit tool |
Wrote a .py file | Told the computer what to show |
Ran streamlit run | Turned your code into a live website |
👉 Think of it like building a LEGO house:
- Python = The LEGO base
- Streamlit = The LEGO blocks
- Your code = The instructions
- The app = The finished house
Replace the code in my_app.py with this:
import streamlit as st import random st.title("🎲 Dice Roller") if st.button("Roll Dice"): number = random.randint(1, 6) st.write(f"You rolled: {number}!") if number == 6: st.balloons() st.write("🎉 Yay! You got a six!")Save and run:
streamlit run my_app.pyClick the button and see what happens!
✅ You just made an interactive game!
You don’t need to be a tech expert to use Streamlit.
You just need to try, fail, fix, and try again.
🎯 Every coder starts exactly where you are now.
✅ You did it!
🚀 Keep going. The next step is even more fun.
🎯 This guide is for absolute beginners.
Just copy, paste, run — and see magic happen!
- Copy the code
- Paste into a new file
- Save it with
.pyextension - Run the command in your terminal
- See the app in your browser
✅ All commands work on Windows, Mac, and Linux.
- Show text, titles, and code
- Use
st.write(),st.title(),st.code()
Create a new file called 01_basics.py
👉 Copy and paste this code:
import streamlit as st # Show a big title st.title("My First Streamlit App") # Show normal text st.write("This is a simple text message.") # Show bold and italic text st.write("This is **bold** and *italic*.") # Show a code block code = ''' import pandas as pd df = pd.read_csv("data.csv") print(df.head()) ''' st.code(code, language="python") # Show a dictionary user = {"name": "Alice", "age": 25, "city": "Dhaka"} st.write(user)Open Terminal (Mac/Linux) or Command Prompt/PowerShell (Windows).
Run this command:
streamlit run 01_basics.py👉 Your browser will open with your app!
✅ You should see:
- A title
- Some text
- A code block
- A dictionary
🔁 To stop: Press
Ctrl + Cin the terminal
- Show tables and JSON data
- Use
st.dataframe(),st.table(),st.json()
Create a new file called 02_display_data.py
👉 Copy and paste this code:
import streamlit as st import pandas as pd import numpy as np # Create fake data df = pd.DataFrame({ "Name": ["Alice", "Bob", "Charlie", "Diana"], "Age": [24, 30, 28, 35], "City": ["Dhaka", "Delhi", "London", "NYC"] }) # Show as scrollable table st.dataframe(df) # Show as static table st.table(df) # Show a metric (like a KPI) st.metric("Total Users", value=4, delta="+1 new") # Show dictionary as JSON data = {"project": "Streamlit Course", "students": 100, "status": "active"} st.json(data, expanded=False)Run this command:
streamlit run 02_display_data.py✅ You should see:
- A scrollable table
- A fixed table
- A metric box
- A collapsible JSON block
- Draw line, bar charts
- Show locations on a map
Create a new file called 03_charts.py
👉 Copy and paste this code:
import streamlit as st import pandas as pd import numpy as np # Create sample data chart_data = pd.DataFrame( np.random.randn(20, 3), columns=['A', 'B', 'C'] ) # Line chart st.subheader("Line Chart") st.line_chart(chart_data) # Bar chart st.subheader("Bar Chart") st.bar_chart(chart_data) # Map st.subheader("Map of Cities") places = pd.DataFrame({ "lat": [19.0760, 28.6139, 40.7128], # Mumbai, Delhi, NYC "lon": [72.8777, 77.2090, -74.0060] }) st.map(places)Run this command:
streamlit run 03_charts.py✅ You should see:
- A line chart
- A bar chart
- A map with 3 cities
- Use buttons, checkboxes, dropdowns
Create a new file called 04_widgets.py
👉 Copy and paste this code:
import streamlit as st # Button if st.button("Click Me"): st.write("Button was clicked!") # Checkbox agree = st.checkbox("I agree to the terms") if agree: st.write("Thank you for agreeing!") # Radio button food = st.radio( "What would you like to eat?", ("Pizza", "Burger", "Salad") ) st.write(f"You selected: {food}") # Dropdown (selectbox) city = st.selectbox( "Where do you live?", ["Dhaka", "Delhi", "London", "Tokyo"] ) st.write(f"Your city: {city}")Run this command:
streamlit run 04_widgets.py✅ You should see:
- A button that shows text when clicked
- A checkbox that reveals a message
- A radio button and dropdown that respond to choices
- Get input from users
Create a new file called 05_input.py
👉 Copy and paste this code:
import streamlit as st # Slider age = st.slider("Your Age", 0, 100, 25) st.write(f"You are {age} years old.") # Text input name = st.text_input("Your Name", placeholder="Type your name") if name: st.write(f"Hello, {name}!") # Number input weight = st.number_input("Your Weight (kg)", min_value=30, max_value=200, value=60) st.write(f"Your weight: {weight} kg") # Multiselect hobbies = st.multiselect( "Your Hobbies", ["Music", "Sports", "Reading", "Cooking"], default=["Music"] ) st.write("You enjoy:", hobbies)Run this command:
streamlit run 05_input.py✅ You should see:
- A slider for age
- A text box for name
- A number input for weight
- A multiselect for hobbies
- Upload files and take photos
Create a new file called 06_file_upload.py
👉 Copy and paste this code:
import streamlit as st # File uploader uploaded_file = st.file_uploader("Upload a text file", type=["txt"]) if uploaded_file: content = uploaded_file.read().decode("utf-8") st.write("File content:") st.text(content) # Camera input camera_photo = st.camera_input("Take a photo") if camera_photo: st.image(camera_photo, caption="Your photo")📷 Note: Camera may not work on all devices (e.g., desktops without webcam)
Run this command:
streamlit run 06_file_upload.py✅ Try:
- Uploading a
.txtfile - Taking a photo (if your device has a camera)
- Display media files
Download these files and save them in the same folder:
- Image:
doggo.jpg→ Download any JPG image - Audio:
audio.mp3→ Download sample MP3 - Video:
video.mp4→ Download sample MP4
Or skip if you don’t have them.
Create a new file called 07_media.py
👉 Copy and paste this code:
import streamlit as st # Show image st.image("doggo.jpg", caption="A cute dog", width=400) # Play audio st.audio("audio.mp3", format="audio/mp3") # Play video st.video("video.mp4", format="video/mp4")Run this command:
streamlit run 07_media.py✅ You should see:
- An image
- An audio player
- A video player
🔁 If file not found: Make sure the files are in the same folder
- Organize your app layout
Create a new file called 08_layouts.py
👉 Copy and paste this code:
import streamlit as st # Sidebar with st.sidebar: st.header("Menu") choice = st.radio("Go to", ["Home", "Settings"]) # Columns col1, col2 = st.columns(2) col1.write("This is left column") col2.write("This is right column") # Tabs tab1, tab2 = st.tabs(["Info", "Data"]) tab1.write("Welcome to the Info tab!") tab2.write("Here is some data: 1, 2, 3, 4, 5") # Expander with st.expander("Click to see more"): st.write("This was hidden!")Run this command:
streamlit run 08_layouts.py✅ You should see:
- A sidebar with options
- Two columns
- Two tabs
- A clickable expander
- Show loading, progress, fun effects
Create a new file called 09_status.py
👉 Copy and paste this code:
import streamlit as st import time # Progress bar st.subheader("Progress Bar") progress = st.progress(0) for i in range(100): time.sleep(0.05) progress.progress(i + 1) # Spinner with st.spinner("Loading..."): time.sleep(3) st.success("Done!") # Fun effects st.balloons() st.snow()Run this command:
streamlit run 09_status.py✅ You should see:
- A progress bar that fills up
- A spinner with "Loading..."
- Balloons and snow animation
| File | Purpose |
|---|---|
01_basics.py | Show text and code |
02_display_data.py | Show tables and JSON |
03_charts.py | Draw charts and maps |
04_widgets.py | Buttons and choices |
05_input.py | Get user input |
06_file_upload.py | Upload files and photo |
07_media.py | Show image, audio, video |
08_layouts.py | Organize layout |
09_status.py | Show progress and effects |
You just built 9 working apps — all from scratch.
No magic. Just code. And you did it!
✅ You don’t need to be a genius.
✅ You just need to practice.
🎯 Keep going. The next step is even more fun.
- Group inputs in a form
- Use
st.form()andst.form_submit_button() - Show code with
st.echo()
Create a new file called 10_forms.py
👉 Copy and paste this code:
import streamlit as st # Form to collect user info with st.form("user_form"): name = st.text_input("Your Name") age = st.slider("Your Age", 18, 100, 25) email = st.text_input("Email Address") # This button submits the form submitted = st.form_submit_button("Submit") # Show result after submit if submitted: st.success(f"Thanks, {name}! We’ll send info to {email}.") st.write(f"Age: {age}") # Show some code nicely st.subheader("Code Example") with st.echo(): def greet(user): return f"Hello, {user}!" msg = greet("Alice") st.write(msg)Run this command in your terminal:
streamlit run 10_forms.py✅ You should see:
- A form with name, age, email
- A submit button
- After submit: a success message
- A code block that shows itself (
st.echo())
💡 Tip:
st.echo()is great for teaching or showing your code live.
- Update charts in real time
- Use
add_rows()to add new data
Create a new file called 11_dynamic.py
👉 Copy and paste this code:
import streamlit as st import pandas as pd import numpy as np import time # Initial data df = pd.DataFrame( np.random.randn(10, 2), columns=["Stock Price", "Volume"] ) # Show initial chart st.subheader("Live Stock Chart") chart = st.line_chart(df) # Add new data every second st.write("Updating chart...") for i in range(5): time.sleep(1) # Wait 1 second new_row = pd.DataFrame( np.random.randn(1, 2), columns=["Stock Price", "Volume"] ) chart.add_rows(new_row) # Add new point to chart st.balloons() st.write("Chart update complete!")Run this command:
streamlit run 11_dynamic.py✅ You should see:
- A line chart
- It updates every second with new random points
- Ends with balloons
📈 Use this for live data: sensors, stock prices, temperature
- Remember values even after button clicks
- Use
st.session_state
Create a new file called 12_session.py
👉 Copy and paste this code:
import streamlit as st # Initialize counter if not exists if "counter" not in st.session_state: st.session_state.counter = 0 # Show current count st.write(f"Counter: {st.session_state.counter}") # Buttons to change counter if st.button("Add 1"): st.session_state.counter += 1 if st.button("Reset"): st.session_state.counter = 0 # Bonus: Use widget with key name = st.text_input("Save your name", key="user_name") if st.session_state.user_name: st.write(f"Hello again, {st.session_state.user_name}!")Run this command:
streamlit run 12_session.py✅ You should see:
- A counter that increases when you click "Add 1"
- It remembers the count even after clicking other buttons
- A text box that remembers your name
💡 Without
st.session_state, Streamlit forgets everything on every click.
- Make your app faster
- Use
@st.cache_resourceand@st.cache_data
Create a new file called 13_caching.py
👉 Copy and paste this code:
import streamlit as st import time import pandas as pd import numpy as np # ❌ Slow function (without cache) def slow_function(): st.write("⏳ Loading data... (This takes time!)") time.sleep(3) return pd.DataFrame(np.random.randn(10, 2), columns=["A", "B"]) # ✅ Fast function (with cache) @st.cache_data def cached_function(): st.write("📦 Caching data...") time.sleep(3) return pd.DataFrame(np.random.randn(10, 2), columns=["A", "B"]) st.subheader("Without Cache") if st.button("Run Slow Function"): result = slow_function() st.dataframe(result) st.subheader("With Cache") if st.button("Run Cached Function"): result = cached_function() st.dataframe(result)Run this command:
streamlit run 13_caching.py✅ Try:
- Click "Run Slow Function" → waits 3 seconds
- Click again → waits again
- Click "Run Cached Function" → waits 3 seconds
- Click again → instant result!
💡
@st.cache_datasaves the result so it doesn’t run again.
| Use Case | Which Decorator |
|---|---|
| Load a big CSV file | @st.cache_data |
| Load a machine learning model | @st.cache_resource |
| Process data (e.g., clean CSV) | @st.cache_data |
| Connect to database | @st.cache_resource |
🔹
@st.cache_data→ for data (CSV, lists, DataFrames)
🔹@st.cache_resource→ for heavy objects (models, connections)
| File | Purpose |
|---|---|
01_basics.py | Text, titles, code |
02_display_data.py | Tables, JSON |
03_charts.py | Charts and maps |
04_widgets.py | Buttons, checkboxes |
05_input.py | Sliders, text input |
06_file_upload.py | Upload files, camera |
07_media.py | Image, audio, video |
08_layouts.py | Sidebar, columns, tabs |
09_status.py | Progress, spinner, balloons |
10_forms.py | Forms and echo code |
11_dynamic.py | Live-updating chart |
12_session.py | Remember values |
13_caching.py | Speed up app |
Let’s combine what you’ve learned!
Create a file: bmi_calculator.py
import streamlit as st st.title("🧮 BMI Calculator") # Input height = st.slider("Height (cm)", 100, 250, 170) weight = st.slider("Weight (kg)", 30, 200, 70) # Calculate bmi = weight / ((height / 100) ** 2) # Show result st.subheader(f"Your BMI: {bmi:.2f}") # Give feedback if bmi < 18.5: st.warning("Underweight") elif bmi < 25: st.success("Normal weight") elif bmi < 30: st.warning("Overweight") else: st.error("Obese")Run it:
streamlit run bmi_calculator.py✅ You just built a real tool!
You started with zero.
Now you’ve built 13 apps + 1 project.
You’re no longer a beginner.
🎯 Keep building:
- A to-do list
- A quiz app
- A data viewer for CSV files
✅ You can do this.
🚀 Just keep coding.
- Let user upload a CSV file
- Show data and basic stats
- Make a simple data explorer
Create a new file called csv_viewer.py
👉 Copy and paste this code:
import streamlit as st import pandas as pd st.title("📂 CSV Data Viewer") # Upload CSV file uploaded = st.file_uploader("Upload your CSV file", type=["csv"]) if uploaded: # Read the file df = pd.read_csv(uploaded) # Show data st.subheader("Data Preview") st.dataframe(df.head(10)) # Show first 10 rows # Show basic info st.subheader("Basic Info") st.write(f"Total Rows: {df.shape[0]}") st.write(f"Total Columns: {df.shape[1]}") st.write("Column Names:", list(df.columns)) # Show data types st.subheader("Data Types") st.write(df.dtypes) # Show chart (if numeric columns exist) numeric_cols = df.select_dtypes(include=['number']).columns if len(numeric_cols) > 0: st.subheader("Chart of First Numeric Column") st.line_chart(df[numeric_cols[0]].head(20)) else: st.info("No numeric data to chart.")Run this command in your terminal:
streamlit run csv_viewer.py✅ How to test:
- Find any CSV file (e.g., Excel saved as
.csv) - Or create one:
data.csvName,Age,Score Alice,24,85 Bob,30,92 Charlie,28,78 - Upload it in the app
✅ You should see:
- Table preview
- Row/column count
- Data types
- A line chart (if numbers exist)
- Save user input using
st.session_state - Add and clear tasks
Create a new file called todo_app.py
👉 Copy and paste this code:
import streamlit as st st.title("📝 Simple To-Do List") # Initialize session state for tasks if "tasks" not in st.session_state: st.session_state.tasks = [] # Input to add new task new_task = st.text_input("Add a new task:") if st.button("Add Task") and new_task: st.session_state.tasks.append(new_task) st.success(f"Task added: {new_task}") # Show all tasks if st.session_state.tasks: st.subheader("Your Tasks") for i, task in enumerate(st.session_state.tasks): st.write(f"{i+1}. {task}") else: st.info("No tasks yet. Add one above!") # Clear all tasks if st.button("Clear All Tasks"): st.session_state.tasks = [] st.warning("All tasks cleared!")Run this command:
streamlit run todo_app.py✅ Try:
- Type a task and click "Add Task"
- See it appear in the list
- Click "Clear All" to reset
✅ This app remembers your tasks even after adding new ones!
- Use radio buttons for choices
- Track score
- Show final result
Create a new file called quiz_app.py
👉 Copy and paste this code:
import streamlit as st st.title("🧠 Simple Quiz App") # Questions and answers questions = [ { "q": "Is Python a programming language?", "options": ["Yes", "No"], "correct": "Yes" }, { "q": "Does Streamlit need HTML?", "options": ["Yes", "No"], "correct": "No" }, { "q": "Can you deploy Streamlit for free?", "options": ["Yes", "No"], "correct": "Yes" } ] # Start quiz st.write("Answer the questions below:") score = 0 for i, qa in enumerate(questions): st.subheader(f"Question {i+1}: {qa['q']}") answer = st.radio(f"Choose:", qa["options"], key=f"q{i}") if answer == qa["correct"]: score += 1 # Show result if st.button("Submit Quiz"): st.subheader(f"Your Score: {score} / {len(questions)}") if score == len(questions): st.balloons() st.success("🎉 Perfect! You're a Streamlit pro!") elif score >= 2: st.success("Good job! Keep learning.") else: st.warning("Keep practicing. You'll get better!")Run this command:
streamlit run quiz_app.py✅ Try:
- Answer all questions
- Click "Submit Quiz"
- See your score and feedback
✅ Great for teaching or self-testing!
- Convert between Celsius and Fahrenheit
- Use
selectboxandnumber_input
Create a new file called temp_converter.py
👉 Copy and paste this code:
import streamlit as st st.title("🌡️ Temperature Converter") # Choose conversion type conversion = st.selectbox( "Convert from:", ["Celsius to Fahrenheit", "Fahrenheit to Celsius"] ) # Input temperature temp = st.number_input("Enter temperature:", value=0.0) # Convert if conversion == "Celsius to Fahrenheit": result = (temp * 9/5) + 32 st.write(f"**{temp}°C = {result:.1f}°F**") else: result = (temp - 32) * 5/9 st.write(f"**{temp}°F = {result:.1f}°C**") # Add a fun message if temp > 100: st.warning("That's boiling hot!") elif temp < 0: st.info("Below freezing!")Run this command:
streamlit run temp_converter.py✅ Try:
- Enter 0°C → should give 32°F
- Enter 100°C → should give 180°F
- See fun messages at extremes
- Build a form with multiple inputs
- Collect and display feedback
Create a new file called feedback_form.py
👉 Copy and paste this code:
import streamlit as st st.title("📬 Feedback Form") with st.form("feedback_form"): name = st.text_input("Your Name") rating = st.slider("Rate us (1-5)", 1, 5, 3) comments = st.text_area("Your Comments") submitted = st.form_submit_button("Submit") if submitted: st.success("Thank you for your feedback!") st.write(f"**Name:** {name}") st.write(f"**Rating:** {rating} ⭐") st.write(f"**Comments:** {comments}")Run this command:
streamlit run feedback_form.py✅ Try:
- Fill out the form
- Click "Submit"
- See your feedback displayed
✅ Perfect for surveys or class projects!
| App | Skills Used |
|---|---|
csv_viewer.py | File upload, pandas, charts |
todo_app.py | Session state, list management |
quiz_app.py | Loops, scoring, radio buttons |
temp_converter.py | Math, selectbox, conditions |
feedback_form.py | Forms, text area, feedback display |
Now that you can build real apps:
- Change colors (use
st.success,st.warning) - Add your logo:
st.image("logo.jpg") - Save data to file (advanced)
- Add a to-do list inside a sidebar
- Let user upload CSV and chart it
- Build a dashboard with tabs
Go to: https://share.streamlit.io/
Connect your GitHub and deploy any app in 2 minutes.
You started with
print("Hello").
Now you’re building real apps that solve problems.
🎯 Keep going:
- Teach a friend
- Build an app for your school/work
- Share on social media
✅ You are now a Streamlit developer.
🚀 The only next step is to keep building.
🎯 This is a real-world project that combines everything you've learned.
You’ll build a personal portfolio website — like a mini LinkedIn or resume site.
Perfect for students, freelancers, or job seekers.
- Use tabs to organize content
- Show images, text, and links
- Add contact form
- Deploy it online (free)
✅ No HTML/CSS needed. Just Python + Streamlit.
Create a folder called my_portfolio/ and inside:
my_portfolio/ ├── app.py ← Your main app ├── profile.jpg ← Your photo (download any if you don’t have) 👉 You can download a sample image here:
https://picsum.photos/400/500 → Right-click → Save as profile.jpg
Create a file called app.py inside the my_portfolio folder.
👉 Copy and paste this full code:
import streamlit as st # Page config st.set_page_config( page_title="My Portfolio", page_icon="👨💻", layout="centered" ) # Title & Profile st.title("👨💻 My Portfolio") st.subheader("Hi, I'm Alice!") st.write("A passionate learner and future developer.") # Profile Image st.image("profile.jpg", width=200, caption="That's me!") # Info Section st.write("---") # Line divider st.subheader("About Me") st.write(""" I am a student from Bangladesh. I love coding, data science, and building small apps. Currently learning Streamlit to create interactive projects. """) # Skills st.subheader("Skills") skills = ["Python", "Streamlit", "Pandas", "Data Analysis", "Basic ML"] for skill in skills: st.markdown(f"- {skill}") # Projects st.write("---") st.subheader("Projects") projects = [ {"name": "CSV Viewer", "desc": "Upload and view CSV files"}, {"name": "To-Do List", "desc": "Simple task manager with session state"}, {"name": "Quiz App", "desc": "Interactive quiz with scoring"} ] for proj in projects: st.write(f"**{proj['name']}**: {proj['desc']}") # Contact Form st.write("---") st.subheader("Contact Me") with st.form("contact_form"): name = st.text_input("Your Name") email = st.text_input("Your Email") message = st.text_area("Your Message") submitted = st.form_submit_button("Send Message") if submitted: st.success("Thank you! I'll get back to you soon.") # In real app, you'd send email (advanced) st.write(f"Name: {name}") st.write(f"Email: {email}") st.write(f"Message: {message}") # Footer st.write("---") st.write("🔗 Find me on: [GitHub](https://github.com/yourusername) | [LinkedIn](https://linkedin.com/in/yourprofile)") st.write("📧 Email: you@example.com") st.write("Built with ❤️ using Streamlit")Open your terminal, go to the my_portfolio folder, and run:
streamlit run app.py✅ You should see:
- Your photo
- About section
- Skills and projects
- Contact form
- Links at the bottom
🔁 Press
Ctrl + Cin terminal to stop the app
| Part | What It Does |
|---|---|
st.set_page_config() | Sets tab title, icon, and layout |
st.image() | Shows your photo |
st.write("---") | Draws a horizontal line |
for skill in skills: | Loops through list and shows each item |
with st.form() | Groups inputs and adds a submit button |
[GitHub](link) | Makes clickable link (Markdown syntax) |
💡 This app uses:
- Text display
- Images
- Lists
- Forms
- Links
- Clean layout
Find:
st.subheader("Hi, I'm Alice!")Replace with:
st.subheader("Hi, I'm [Your Name]!")Save your photo as profile.jpg in the same folder.
Or change the filename:
st.image("my_photo.jpg", width=200, caption="Me")Want an "Education" section? Add:
st.write("---") st.subheader("Education") st.write(""" - BSc in Computer Science – XYZ University (2024) - High School – ABC School (2020) """)Replace the links with your real profiles:
st.write("🔗 Find me on: [GitHub](https://github.com/yourname) | [Twitter](https://twitter.com/yourhandle)")If you have a resume file (resume.pdf), add this:
# Download Resume with open("resume.pdf", "rb") as f: st.download_button( label="📄 Download My Resume", data=f, file_name="my_resume.pdf", mime="application/pdf" )✅ Make sure resume.pdf is in the same folder.
Now users can download your resume!
Want to share your portfolio with the world?
Step 1: Go to Streamlit Community Cloud
- Sign in with GitHub
- Click "New App"
- Connect your GitHub repo
- Upload these files:
app.pyprofile.jpgrequirements.txt(see below)
Create a file called requirements.txt:
streamlit==1.29.0 pandas==2.1.0This tells Streamlit what to install.
✅ In 2 minutes, your app will be live at a link like:
👉 https://yourname.streamlit.app
my_portfolio/ ├── app.py ├── profile.jpg ├── resume.pdf ← optional └── requirements.txt You just built a real portfolio website — no web developer needed.
🎯 This app can:
- Show your skills
- Display your projects
- Let people contact you
- Be shared in job applications
✅ You are now building real tools.
🚀 The next step?
Deploy it. Share it. Be proud.
🎯 You’ve built apps. Now let’s fix common mistakes — the right way.
No panic. No confusion. Just simple fixes.
Perfect for beginners who see errors and think: “What now?”
Even expert coders make mistakes.
The key is not to avoid errors, but to understand and fix them fast.
In this guide, you’ll learn:
- How to read error messages
- Fix 7 most common Streamlit errors
- Use tools to prevent bugs
- Keep your app running smoothly
✅ All examples are copy-paste friendly.
When your app crashes, Streamlit shows red error messages in the browser and terminal.
👉 Read the last few lines — that’s where the real problem is.
Streamlit is not installed.
Run this command in your terminal:
pip install streamlit✅ Wait for it to say "Successfully installed".
Then run your app again:
streamlit run app.py🔁 If you get
pip: command not found, trypip3 install streamlit
You forgot to import Streamlit.
Add this line at the top of your file:
import streamlit as st👉 Wrong code:
st.write("Hello") # ❌ No import!👉 Correct code:
import streamlit as st # ✅ Add this! st.write("Hello")✅ Always start your file with:
import streamlit as stThe file is missing or in the wrong folder.
Make sure:
- The file exists (
profile.jpg) - It’s in the same folder as your
.pyfile
👉 Example folder:
my_app/ ├── app.py ├── profile.jpg ← must be here! Or use the correct path:
st.image("images/profile.jpg") # if inside images/ folder✅ Tip: Right-click the file → "Copy path" to check.
Streamlit reruns the whole script every time you click or type.
So if you type something, the button resets.
Use st.session_state to remember values.
👉 Wrong code:
clicked = st.button("Click me") if clicked: st.write("Button was clicked!") # But it resets when you type in a text box👉 Correct code:
import streamlit as st if "clicked" not in st.session_state: st.session_state.clicked = False if st.button("Click me"): st.session_state.clicked = True if st.session_state.clicked: st.success("Button was clicked and remembered!")✅ Now the click is remembered even after typing.
Old way of showing Matplotlib plots.
Use st.pyplot(fig) with fig argument.
👉 Wrong code:
import matplotlib.pyplot as plt plt.plot([1, 2, 3]) st.pyplot() # ❌ Warning!👉 Correct code:
import streamlit as st import matplotlib.pyplot as plt fig, ax = plt.subplots() ax.plot([1, 2, 3]) st.pyplot(fig) # ✅ Correct!✅ Always pass fig to st.pyplot().
Streamlit forgets input after every interaction.
Use key to save input in st.session_state.
👉 Wrong code:
name = st.text_input("Name") st.write(f"Hello {name}") # Becomes empty when you do other actions👉 Correct code:
name = st.text_input("Name", key="user_name") if st.session_state.user_name: st.write(f"Hello, {st.session_state.user_name}!")✅ The key links the input to session state.
No st.write() or display command.
Add output commands.
👉 Wrong code:
import streamlit as st x = 10 y = 20 z = x + y # No output shown👉 Correct code:
import streamlit as st x = 10 y = 20 z = x + y st.write(f"Result: {z}") # ✅ Now it shows✅ Streamlit only shows what you tell it to show.
Let’s fix a real broken app together.
👉 Copy and paste this broken code:
# This app has 4 errors. Can you fix them? # 1. Missing import # 2. File not found # 3. Button not working # 4. No output shown name = st.text_input("Enter your name") if st.button("Greet Me"): st.write("Hello " + name) st.image("my_photo.jpg") # photo doesn't existRun:
streamlit run broken_app.py👉 You’ll see errors.
Create a new file: fixed_app.py
👉 Copy and paste this fixed version:
import streamlit as st # ✅ Fixed: Added import # ✅ Fixed: Initialize session state if "greeted" not in st.session_state: st.session_state.greeted = False name = st.text_input("Enter your name", key="user_name") # ✅ Saved in session if st.button("Greet Me"): st.session_state.greeted = True # ✅ Fixed: Show output only if name exists if st.session_state.greeted and st.session_state.user_name: st.success(f"Hello, {st.session_state.user_name}! 👋") # ✅ Fixed: Use a working image (or comment out) # st.image("my_photo.jpg") # Removed or replace with valid file st.write("🖼️ No image for now — but app works!")Run:
streamlit run fixed_app.py✅ Now it works!
| Tip | How |
|---|---|
✅ Always start with import streamlit as st | First line of every file |
✅ Use key for inputs | st.text_input("Name", key="name") |
| ✅ Test one feature at a time | Don’t write 100 lines at once |
✅ Use st.write() to debug | Print values to see what’s happening |
| ✅ Save files in the same folder | No broken image/audio errors |
If your app acts weird:
- Press
Ctrl + Cin terminal - Close browser tab
- Run again:
streamlit run app.py✅ Fresh start fixes many issues.
Errors are not your enemy.
They are your teachers.
🎯 Every coder sees red messages.
✅ The difference? They read, fix, and move on.
Now you can too.
🚀 Keep building. Keep breaking. Keep fixing.
🎯 You’ve learned Streamlit. Now let’s build fun, small apps that feel like games or tools.
Each one takes 10–15 minutes.
All are copy-paste friendly and perfect for practice.
- ✅ Copy the code
- ✅ Save as
.pyfile - ✅ Run with
streamlit run filename.py - ✅ Change colors, text, or features to make it yours!
🎯 What it does: Click a button → get a random number.
import streamlit as st import random st.title("🎲 Random Number Generator") if st.button("Generate Number"): num = random.randint(1, 100) st.subheader(f"Your number: {num}") if num > 90: st.balloons() st.success("Wow! A high number!") elif num < 10: st.info("Small but mighty!")streamlit run random_number.py💡 Try: Change range to 1-10 or add sound?
🎯 What it does: Asks a math question, checks answer.
import streamlit as st import random st.title("🧮 Math Quiz") # Generate question if "question" not in st.session_state: a = random.randint(1, 10) b = random.randint(1, 10) st.session_state.question = f"What is {a} + {b}?" st.session_state.answer = a + b # Show question st.write(st.session_state.question) # User input user_ans = st.number_input("Your answer:", step=1) # Check answer if st.button("Check"): if user_ans == st.session_state.answer: st.success("✅ Correct!") st.balloons() else: st.error(f"❌ Wrong! Answer was {st.session_state.answer}") # New question if st.button("New Question"): st.session_state.clear() # Reset st.experimental_rerun()streamlit run math_quiz.py💡 Try: Add subtraction or multiplication.
🎯 What it does: Ask a yes/no question → get a random fortune.
import streamlit as st import random st.title("🔮 Magic 8-Ball") question = st.text_input("Ask a yes/no question:") responses = [ "Yes, definitely!", "No way.", "Ask again later.", "Very doubtful.", "Signs point to yes.", "Absolutely not.", "Maybe, maybe not.", "Without a doubt!" ] if st.button("Shake the Ball"): if question: answer = random.choice(responses) st.subheader(f"🎱: {answer}") st.snow() else: st.warning("Please ask a question first!")streamlit run magic_8ball.py💡 Try: Add your own funny responses!
🎯 What it does: Save and view notes using session state.
import streamlit as st st.title("📝 Simple Notes App") # Initialize notes if "notes" not in st.session_state: st.session_state.notes = [] # Add new note new_note = st.text_area("Write a note:") if st.button("Save Note") and new_note: st.session_state.notes.append(new_note) st.success("Note saved!") st.experimental_rerun() # Show all notes if st.session_state.notes: st.subheader("Your Notes") for i, note in enumerate(st.session_state.notes): st.text(f"{i+1}. {note}") else: st.info("No notes yet.")streamlit run notes_app.py💡 Try: Add a "Clear All" button.
🎯 What it does: Pick a mood → suggest a song.
import streamlit as st st.title("🎵 Music Mood Picker") mood = st.radio( "How do you feel?", ["Happy", "Sad", "Chill", "Energetic"] ) songs = { "Happy": "Pharrell Williams - Happy", "Sad": "Adele - Someone Like You", "Chill": "Lofi Hip Hop Radio - Beats to Relax/Study", "Energetic": "Eye of the Tiger - Survivor" } if st.button("Recommend Song"): st.write(f"🎧 Play: **{songs[mood]}**") st.info("Open YouTube and search for this song!")streamlit run music_mood.py💡 Try: Add links using [Song](https://youtube.com).
🎯 What it does: Pick pet type → get random name.
import streamlit as st import random st.title("🐾 Pet Name Generator") pet = st.selectbox("Choose pet:", ["Dog", "Cat", "Bird", "Fish"]) names = { "Dog": ["Buddy", "Max", "Bella", "Lucy", "Rocky"], "Cat": ["Whiskers", "Luna", "Milo", "Chloe", "Leo"], "Bird": ["Polly", "Sky", "Rio", "Tweety", "Blue"], "Fish": ["Bubbles", "Nemo", "Finley", "Splash", "Goldie"] } if st.button("Generate Name"): name = random.choice(names[pet]) st.subheader(f"Your {pet}'s name: **{name}** 🎉") st.balloons()streamlit run pet_names.py💡 Try: Add more pets or names.
🎯 What it does: Enter temperature → get clothing advice.
import streamlit as st st.title("🌤️ Weather Advisor") temp = st.slider("Current Temperature (°C)", -10, 50, 25) if temp < 0: advice = "🧣 Wear heavy coat! It's freezing!" st.cold = st.image("https://i.imgur.com/pGdLw0A.png", width=100) # Optional elif temp < 15: advice = "🧥 Wear a jacket." elif temp < 25: advice = "👕 Light clothes are fine." else: advice = "☀️ Stay cool! Wear shorts and drink water." st.subheader(advice)streamlit run weather_advisor.py💡 Try: Add humidity or rain input.
🎯 What it does: Roll 1–6 dice and show results.
import streamlit as st import random st.title("🎲 Dice Roller") num_dice = st.slider("How many dice?", 1, 6, 2) if st.button("Roll Dice"): results = [random.randint(1, 6) for _ in range(num_dice)] st.subheader(f"Results: {results}") total = sum(results) st.write(f"**Total: {total}**") if 6 in results: st.balloons() st.success("🎉 You rolled a six!")streamlit run dice_roller.py💡 Try: Add images of dice faces.
🎯 What it does: Generate a simple random password.
import streamlit as st import random import string st.title("🔐 Password Generator") length = st.slider("Password length", 6, 16, 8) if st.button("Generate Password"): chars = string.ascii_letters + string.digits + "!@#$" password = ''.join(random.choice(chars) for _ in range(length)) st.subheader(f"Your password: `{password}`") st.warning("Don’t use this for real accounts! Just for fun.")streamlit run password_gen.py💡 Try: Add checkbox for "include symbols".
🎯 What it does: Let users vote and see results.
import streamlit as st st.title("📊 Favorite Fruit Poll") # Initialize votes if "votes" not in st.session_state: st.session_state.votes = {"Apple": 0, "Banana": 0, "Orange": 0} # Vote choice = st.radio("Choose your favorite:", list(st.session_state.votes.keys())) if st.button("Vote"): st.session_state.votes[choice] += 1 st.success("Thanks for voting!") # Show results st.subheader("Live Results") for fruit, count in st.session_state.votes.items(): st.write(f"{fruit}: {count} votes")streamlit run poll_app.py💡 Try: Add a bar chart of results.
| App | Skills Used |
|---|---|
| 1. Random Number | random, button |
| 2. Math Quiz | session_state, logic |
| 3. Magic 8-Ball | list, random, snow |
| 4. Notes App | session_state, text_area |
| 5. Music Mood | radio, dict |
| 6. Pet Names | selectbox, list |
| 7. Weather Advisor | slider, if-else |
| 8. Dice Roller | list comprehension, sum |
| 9. Password Gen | string, random |
| 10. Poll App | session_state, counting |
Now that you’ve built 10 fun apps:
- Pick your favorite and improve it
- Combine two apps (e.g., quiz + timer)
- Share it on social media or with friends
- Deploy it on Streamlit Community Cloud
You started with
print("Hello").
Now you’re building apps people want to use.
🎯 Keep coding.
🎮 Keep having fun.
🚀 Keep sharing.
✅ You’re not just learning Streamlit.
You’re becoming a creator.
🎉 Congratulations! You’ve completed the full course.
👉 Now go build something amazing.
- 📅 Spend 30 minutes daily on one lecture
- ✍️ Type the code yourself (don’t copy-paste)
- ❓ Break things on purpose (then fix them)
- 🤝 Share your app with friends
| Link | What It’s For |
|---|---|
| docs.streamlit.io | Official Docs |
| Streamlit Gallery | See real apps |
| Streamlit Community | Ask questions |
| GitHub Repo of this Course | Your own repo |
You don’t need to be an expert to start.
Just start.
Every expert was once a beginner.
✅ You now have a complete, step-by-step, beginner-friendly guide to learn Streamlit from zero.
🎯 Go ahead. Run your first app. Break it. Fix it. Build something cool.
⭐ If you liked this guide, give your repo a Star!
👨💻 Happy Coding!
🚀 You’ve got this!