Each module runs separately via Pyodide. Output appears right below the code.
Colored console output: ๐ข stdout / ๐ด stderr / ๐ฃ status
Module 1 — Hello & Print
Your first Python program — using print() and input().
# Module 1 — Hello & print
name = input("What's your name? ")
print(f"Hello, {name}! Welcome to Python basics.")
— output here —
Module 2 — Variables & Types
Numbers, strings, booleans, and type checking.
x = 42
y = 3.14
name = "Ada"
is_ready = True
print(x, type(x))
print(y, type(y))
print(name.upper(), type(name))
print("Is ready?", is_ready)
— output here —
Module 3 — Control Flow
Using if/else, loops, and range().
n = 5
for i in range(1, n+1):
if i % 2 == 0:
print(i, "is even")
else:
print(i, "is odd")
count = 3
while count > 0:
print("Counting down:", count)
count -= 1
— output here —
Module 4 — Functions & Modules
Defining functions and using Python's standard library.
import math
def circle_area(radius):
return math.pi * radius ** 2
r = 2.5
print(f"Area of circle with radius {r} is {circle_area(r):.3f}")
— output here —
Module 5 — Lists & Comprehensions
Creating lists, slicing, and list comprehensions.
numbers = [1, 2, 3, 4, 5]
squares = [n**2 for n in numbers]
evens = [n for n in numbers if n % 2 == 0]
print("numbers:", numbers)
print("squares:", squares)
print("evens:", evens)
print("first two:", numbers[:2])
Syntax highlighting via Prism.js. In-browser execution via Pyodide. Colored console output: ๐ข stdout / ๐ด stderr / ๐ฃ status.
Interactive runner
Paste examples into the editor (or use Copy & Use from any module) and click Run. Output appears below.
Editor
Pyodide status: loading...
Quick snippets
Console output
— ready —
Module 1 — Hello & print
The first program: printing to console, comments, and basic I/O.
# Module 1 — Hello & print
name = input("What's your name? ")
print(f"Hello, {name}! Welcome to Python basics.")
Module 2 — Variables & Types
Numbers, strings, booleans, and type checking.
x = 42
y = 3.14
name = "Ada"
is_ready = True
print(x, type(x))
print(y, type(y))
print(name.upper(), type(name))
print("Is ready?", is_ready)
Module 3 — Control Flow
if/else, for loops, while loops, and range.
n = 5
for i in range(1, n+1):
if i % 2 == 0:
print(i, "is even")
else:
print(i, "is odd")
count = 3
while count > 0:
print("Counting down:", count)
count -= 1
Module 4 — Functions & Modules
Defining functions, parameters, return values, and importing a module.
import math
def circle_area(radius):
return math.pi * radius ** 2
r = 2.5
print(f"Area of circle with radius {r} is {circle_area(r):.3f}")
Module 5 — Lists & Comprehensions
Creating lists, indexing, slicing, and list comprehensions.
numbers = [1, 2, 3, 4, 5]
squares = [n**2 for n in numbers]
evens = [n for n in numbers if n % 2 == 0]
print("numbers:", numbers)
print("squares:", squares)
print("evens:", evens)
print("first two:", numbers[:2])
Python Website Demo: Full Tutorial (Login, Projects, Customers, Stories)
Python Website Demo Tutorial
Build a complete demo web application using Python + Flask, featuring: login, projects, customers, and success stories pages. Each module gets you closer to a real-world site!
Module 1: Setup & Install Flask
pip install flask flask-login
mkdir pywebdemo
cd pywebdemo
touch app.py
mkdir templates static
Gmail Authentication with Django: Step-by-Step Tutorial
Gmail Authentication in Django: Step-by-Step Tutorial
Learn how to set up Gmail (Google) authentication on your Django site using the popular third-party package django-allauth. This method lets users log in or sign up with their Google account in a secure, scalable way.
Django Masterclass: 10 Modules to Professional Web Apps
Django Masterclass: 10 Modules to Professional Web Apps
Step up to building robust, scalable web applications with Django! This 10-part blog series takes you from setup to production deployment through hands-on modules with code, explanations, and best practices.
Module 1: Introduction to Django & Installation
pip install django
django-admin startproject mysite
cd mysite
python manage.py runserver
Module 2: Django App Structure Explained
python manage.py startapp blog
mysite/ (project root)
blog/ (your app: models, views, templates)
manage.py (Django CLI)
Module 3: Models and Admin
# blog/models.py
from django.db import models
class Post(models.Model):
title = models.CharField(max_length=200)
body = models.TextField()
pub_date = models.DateTimeField(auto_now_add=True)
Module 8: Advanced Features – Class-based Views & Pagination
from django.views.generic import ListView
from .models import Post
class PostListView(ListView):
model = Post
paginate_by = 5
template_name = "post_list.html"
# blog/api.py
from rest_framework import viewsets
from .models import Post
from .serializers import PostSerializer
class PostViewSet(viewsets.ModelViewSet):
queryset = Post.objects.all()
serializer_class = PostSerializer
# blog/serializers.py
from rest_framework import serializers
from .models import Post
class PostSerializer(serializers.ModelSerializer):
class Meta:
model = Post
fields = "__all__"
FastAPI Masterclass: Build & Deploy APIs in 10 Modules
This comprehensive guide introduces you to FastAPI, the modern Python framework for building high-performance APIs and web apps. Each module builds on the next, taking you from setup to deployment.
Module 1: Introduction to FastAPI
FastAPI is a high-performance web framework built for speed with async support. Install it and run your first app.
from fastapi import HTTPException
@app.get("/divide")
def divide(a: int, b: int):
if b == 0:
raise HTTPException(status_code=400, detail="Division by zero not allowed")
return {"result": a / b}
Module 6: Background Tasks
from fastapi import BackgroundTasks
def write_log(message: str):
with open("log.txt", "a") as f:
f.write(f"{message}\n")
@app.post("/log/")
def log_message(background_tasks: BackgroundTasks, message: str):
background_tasks.add_task(write_log, message)
return {"status": "Task scheduled"}
Module 7: Working with Databases (SQLite + SQLAlchemy)
pip install sqlalchemy
from sqlalchemy import create_engine, Column, Integer, String
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
SQLALCHEMY_DATABASE_URL = "sqlite:///./test.db"
engine = create_engine(SQLALCHEMY_DATABASE_URL, connect_args={"check_same_thread": False})
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
Base = declarative_base()
class User(Base):
__tablename__ = "users"
id = Column(Integer, primary_key=True, index=True)
name = Column(String, index=True)
Base.metadata.create_all(bind=engine)
Module 8: Authentication with FastAPI
from fastapi.security import OAuth2PasswordBearer
from fastapi import Depends
oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token")
@app.get("/users/me")
def read_current_user(token: str = Depends(oauth2_scheme)):
return {"token": token}
This guide shows you how to create a Python Flask web tool that locates phone numbers—revealing region and carrier information using the phonenumbers library.
Step 1: Install Requirements
pip install Flask phonenumbers
Step 2: Create the Flask App (app.py)
from flask import Flask, request, render_template_string
import phonenumbers
from phonenumbers import geocoder, carrier
app = Flask(__name__)
TEMPLATE = """
<!DOCTYPE html>
<html>
<head>
<title>Phone Number Locator</title>
<style>
body { font-family: Arial, sans-serif; margin:40px; }
.container { max-width: 500px; margin: auto; }
input[type=text] { width: 80%; padding: 8px; }
input[type=submit] { padding: 8px 16px; }
.result { margin-top:20px; background: #f0fafc; padding: 16px; border-radius: 5px;}
</style>
</head>
<body>
<div class="container">
<h2>Phone Number Locator</h2>
<form method="post">
<label for="phone">Enter Phone Number (with country code):</label><br><br>
<input type="text" name="phone" placeholder="+14155552671"/><br><br>
<input type="submit" value="Locate">
</form>
{% if info %}
<div class="result">
<b>Number:</b> {{ info['number'] }} <br>
<b>Country/Region:</b> {{ info['region'] }} <br>
<b>Carrier:</b> {{ info['carrier'] }} <br>
</div>
{% endif %}
</div>
</body>
</html>
"""
@app.route('/', methods=['GET', 'POST'])
def locate():
info = None
if request.method == 'POST':
number = request.form['phone']
try:
parsed = phonenumbers.parse(number, None)
region = geocoder.description_for_number(parsed, "en")
carrier_name = carrier.name_for_number(parsed, "en")
info = {
'number': number,
'region': region if region else 'Unknown',
'carrier': carrier_name if carrier_name else 'Unknown'
}
except Exception as e:
info = {'number': number, 'region': 'Invalid number', 'carrier': 'Invalid number'}
return render_template_string(TEMPLATE, info=info)
if __name__ == '__main__':
app.run(debug=True)
Step 3: Run Locally
python app.py
Open http://127.0.0.1:5000/ in your browser.
Enter an international phone number (e.g., +14155552671 for US).
This blog covers essential NumPy concepts with simple code examples. Each demo has syntax highlighting and a copy button — perfect for learning or sharing!
1. Importing NumPy
import numpy as np
2. Creating Arrays
# From list
a = np.array([1, 2, 3])
print(a)
# From tuple
b = np.array((4, 5, 6))
print(b)
This blog covers essential Pandas concepts with simple code examples. Each demo has syntax highlighting and a copy button — perfect for learning or sharing!
Combine the power of Streamlit (for RIA's [Rich Internet Application] in pure Python) and LangChain (for agentic workflows, tools, memory, chains) to build sleek AI dashboards that think, act, and respond.
Whether you’re creating a chat-agent, document assistant, or data-query bot — this guide gets you started fast. ๐
1️⃣ Install the Libraries
!pip install streamlit langchain openai tiktoken
2️⃣ Build a Simple Agent Dashboard
import streamlit as st
from langchain.llms import OpenAI
from langchain import LLMChain
from langchain.prompts import PromptTemplate
st.set_page_config(page_title="Agentic AI Dashboard", layout="wide")
st.title("๐ค Ask Me Anything: AI Agent")
openai_api_key = st.sidebar.text_input("OpenAI API Key", type="password")
if openai_api_key:
prompt = PromptTemplate(
input_variables=["question"],
template="You are a helpful assistant. Answer: {question}"
)
llm = OpenAI(openai_api_key=openai_api_key, temperature=0.5)
chain = LLMChain(llm=llm, prompt=prompt)
user_question = st.text_area("Enter your question:")
if st.button("Ask"):
response = chain.run(user_question)
st.info(response)
else:
st.warning("Please enter your OpenAI API Key in the sidebar.")
3️⃣ Add Tools and Agent with Thought Trace
Use LangChain Agent with tools and display agent thoughts/actions.
import streamlit as st
from langchain.agents import initialize_agent, Tool, AgentType
from langchain.llms import OpenAI
from langchain_community.callbacks.streamlit import StreamlitCallbackHandler
st.title("๐ ️ Agent with Tools Demo")
openai_api_key = st.sidebar.text_input("OpenAI API Key", type="password")
if openai_api_key:
llm = OpenAI(openai_api_key=openai_api_key, streaming=True)
tools = [
Tool(name="calculator", func=lambda x: eval(x), description="Evaluate math expressions")
]
agent = initialize_agent(tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True)
query = st.text_area("Ask the agent (it may use tools):")
if st.button("Submit"):
with st.container():
callback = StreamlitCallbackHandler(st.container(), expand_new_thoughts=False)
result = agent.run(query, callbacks=[callback])
st.success(result)
else:
st.warning("Enter OpenAI API Key in sidebar.")
4️⃣ Document Upload + Q&A Dashboard
import streamlit as st
import pandas as pd
from langchain.chat_models import ChatOpenAI
from langchain.agents import create_pandas_dataframe_agent
from langchain.agents.agent_types import AgentType
st.title("๐ Ask Your Data Dashboard")
uploaded_file = st.file_uploader("Upload CSV", type=["csv"])
openai_api_key = st.sidebar.text_input("OpenAI API Key", type="password")
if uploaded_file and openai_api_key:
df = pd.read_csv(uploaded_file)
st.dataframe(df.head())
agent = create_pandas_dataframe_agent(
llm=ChatOpenAI(openai_api_key=openai_api_key),
df=df,
agent_type=AgentType.OPENAI_FUNCTIONS,
verbose=True
)
user_query = st.text_input("What do you want to ask about the data?")
if st.button("Run Query"):
response = agent.run(user_query)
st.info(response)
else:
st.warning("Please upload a CSV and enter OpenAI API Key.")
5️⃣ Deployment Tips
Once your dashboard works locally, deploy it via Streamlit Community Cloud — simply push your code + `requirements.txt` and click “Deploy”.
Use `st.secrets.toml` to securely manage your OpenAI API key.
✅ What You Can Build Next
๐ง Chatbots with memory, custom tools & chain logic
๐ Data-agents that ingest documents, spreadsheets & databases
Bro, this opens up the door to full-fledged agentic AI dashboards — from assistants to analytics bots.
Want me to prepare a **complete notebook + GitHub repo template** for this? Let’s go!
Want to see your ML models in action with sliders, dropdowns, and live predictions?
Streamlit makes that super easy — no frontend code, just Python!
Let’s build interactive dashboards for both regression and classification tasks. ๐
# Save the file as app.py
# Run this in terminal
streamlit run app.py (or) python -m streamlit run app.py
Open the link Streamlit gives (usually http://localhost:8501) — and your ML dashboard is live ๐ฏ
Part of Response(s) should be like ๐
Regression
Classification
✅ What You Learned
⚙️ Use Streamlit for real-time model dashboards
๐ก Build a regression dashboard with metrics & charts
๐ธ Add interactive classification UI with sliders
๐ Visualize results using Plotly
Now bro, you can turn any ML model into a live web app in under 50 lines of Python ๐ฅ
Next up? “Streamlit + LangChain for Agentic AI Apps” — want me to make that next?
๐ฏ Streamlit for Data Apps — Build Dashboards in 10 Lines of Python
Tired of HTML and JS? Streamlit lets you create interactive dashboards with pure Python — no frontend code required!
From charts to file uploads to ML model demos — it’s all possible in minutes.
Let’s dive into the world of Streamlit! ๐
1️⃣ Install Streamlit
!pip install streamlit
Then launch the app with:
streamlit run app.py
Just check in your terminal prompt cmd: python -m streamlit hell
2️⃣ Your First Streamlit App (10 Lines Only)
import streamlit as st
import pandas as pd
import numpy as np
st.title("๐ My First Streamlit Dashboard")
st.write("Hello, Data Scientists! ๐")
data = pd.DataFrame(np.random.randn(10, 2), columns=["A", "B"])
st.line_chart(data)
Run it and open the browser link — boom ๐ฅ an interactive chart in seconds!
It it does not work, try in your project folder cmd prompt: python -m pip install --upgrade streamlit && python -m streamlit run t1.py
3️⃣ Adding Widgets
import streamlit as st
st.title("๐️ Widgets in Action")
name = st.text_input("Enter your name:")
age = st.slider("Select your age", 10, 60, 25)
clicked = st.button("Greet Me")
if clicked:
st.success(f"Hey {name}, you are {age} years old! ๐")
๐ Streamlit automatically handles UI, state, and interactivity — no callbacks needed!
4️⃣ Displaying DataFrames and Charts
import streamlit as st
import pandas as pd
import plotly.express as px
st.title("๐ Visualizing Data with Plotly")
df = px.data.gapminder().query("year == 2007")
continent = st.selectbox("Choose Continent", df["continent"].unique())
filtered_df = df[df["continent"] == continent]
fig = px.bar(filtered_df, x="country", y="gdpPercap", color="country", title=f"GDP per Capita in {continent}")
st.plotly_chart(fig)
5️⃣ File Upload Example
import streamlit as st
import pandas as pd
st.title("๐ CSV File Uploader")
file = st.file_uploader("Upload your CSV file", type=["csv"])
if file:
df = pd.read_csv(file)
st.write("Preview:")
st.dataframe(df.head())
Perfect for quick data exploration dashboards ๐
6️⃣ Real-Time Metrics Dashboard
import streamlit as st
import numpy as np
import time
st.title("๐ Real-Time Metrics Dashboard")
progress = st.progress(0)
status = st.empty()
for i in range(100):
progress.progress(i + 1)
status.text(f"Processing... {i + 1}%")
time.sleep(0.05)
st.success("✅ Done!")
Part of Result
7️⃣ Deploy to the Web (Free!)
๐ Host your app free on Streamlit Cloud — just connect your GitHub repo and click “Deploy”.
It auto-runs your streamlit run app.py on the cloud ๐
✅ What You Learned
๐ก Create dashboards in pure Python
๐จ Add charts, forms, and widgets easily
๐ฆ Upload and visualize data
๐ Deploy in minutes with Streamlit Cloud
Bro, now you can build a full-fledged **AI or ML dashboard** in under 30 lines of code ๐
Next step? Try connecting Streamlit with your trained ML model for live predictions!