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).