Readable. Powerful. Beginner Friendly.

Python — Complete Tutorial

Learn Python from absolute zero. Every topic explained simply with real examples you can edit and test quickly.

🟩 Beginner Friendly ▶ Editable Examples 📚 164 Topics
Your Progress3% complete
Live Python Lab

Edit the Python example below and click Run to execute it and see the output.

python-lab.py
📝 Edit Code
👁 Live Preview
💡 Try this: change the code (and even add errors) then run to see stdout/stderr.
∙ Chapter 001

Python Tutorial

Learn Python Tutorial with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-tutorial.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
name = "Mana"Assigns a value.
score = 86Assigns a value.
print(f"{name} passed with {score}")Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 002

Python HOME

Learn Python HOME with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-home.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
name = "Mana"Assigns a value.
score = 86Assigns a value.
print(f"{name} passed with {score}")Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 003

Python Intro

Learn Python Intro with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-intro.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
name = "Mana"Assigns a value.
score = 86Assigns a value.
print(f"{name} passed with {score}")Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 004

Python Get Started

Learn Python Get Started with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-get-started.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
name = "Mana"Assigns a value.
score = 86Assigns a value.
print(f"{name} passed with {score}")Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 005

Python Syntax

Learn Python Syntax with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-syntax.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
score = 82Assigns a value.
if score >= 50:Conditional branch.
print("Pass")Outputs text to stdout.
else:Conditional branch.
print("Fail")Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 006

Python Output

Learn Python Output with a small example you can edit and run.

📝Syntax
print('Hello')
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-output.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
print("Practice: edit this example")Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 007

Python Comments

Learn Python Comments with a small example you can edit and run.

📝Syntax
# single-line comment
"""multi-line docstring"""
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-comments.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
score = 82Assigns a value.
if score >= 50:Conditional branch.
print("Pass")Outputs text to stdout.
else:Conditional branch.
print("Fail")Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 008

Python Variables

Learn Python Variables with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-variables.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
name = "Mana"Assigns a value.
age = 18Assigns a value.
is_active = TrueAssigns a value.
nothing = NoneAssigns a value.
print(type(name), type(age), type(is_active), type(nothing))Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 009

Python Data Types

Learn Python Data Types with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-data-types.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
name = "Mana"Assigns a value.
age = 18Assigns a value.
is_active = TrueAssigns a value.
nothing = NoneAssigns a value.
print(type(name), type(age), type(is_active), type(nothing))Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 010

Python Numbers

Learn Python Numbers with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-numbers.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
a = 7Assigns a value.
b = 3Assigns a value.
print("a+b =", a + b)Outputs text to stdout.
print("a//b =", a // b)Outputs text to stdout.
print("float('3.14') =", float('3.14'))Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 011

Python Casting

Learn Python Casting with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-casting.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
a = 7Assigns a value.
b = 3Assigns a value.
print("a+b =", a + b)Outputs text to stdout.
print("a//b =", a // b)Outputs text to stdout.
print("float('3.14') =", float('3.14'))Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 012

Python Strings

Learn Python Strings with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-strings.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
name = "Mana"Assigns a value.
streak = 7Assigns a value.
print(f"{name} has a {streak}-day streak")Outputs text to stdout.
print(name.upper())Outputs text to stdout.
print(name[0:2])Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 013

Python Booleans

Learn Python Booleans with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-booleans.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
score = 72Assigns a value.
if score >= 75:Conditional branch.
result = "Pass"Assigns a value.
elif score >= 50:Conditional branch.
result = "Retry"Assigns a value.
else:Conditional branch.
result = "Fail"Assigns a value.
print(result)Outputs text to stdout.
for i in range(1, 4):Loop: repeats code.
print("i =", i)Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 014

Python Operators

Learn Python Operators with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-operators.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
a = 7Assigns a value.
b = 3Assigns a value.
print("a+b =", a + b)Outputs text to stdout.
print("a//b =", a // b)Outputs text to stdout.
print("float('3.14') =", float('3.14'))Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 015

Python Lists

Learn Python Lists with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-lists.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
nums = [1, 2, 2, 3]Assigns a value.
print("list:", nums)Outputs text to stdout.
print("unique set:", set(nums))Outputs text to stdout.
user = {"name": "Mana", "level": 2}Assigns a value.
user["level"] += 1Assigns a value.
print("dict:", user)Outputs text to stdout.
🏢Real-world
  • 1Store and transform collections (filtering, grouping).
  • 2Use dicts for fast lookups.
Common Mistakes
  • 1Mutating lists unintentionally.
  • 2Using a list where a set/dict would be faster.
Best Practices
  • 1Choose the right container: list vs set vs dict.
  • 2Keep data transformations clear and readable.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 016

Python Tuples

Learn Python Tuples with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-tuples.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
nums = [1, 2, 2, 3]Assigns a value.
print("list:", nums)Outputs text to stdout.
print("unique set:", set(nums))Outputs text to stdout.
user = {"name": "Mana", "level": 2}Assigns a value.
user["level"] += 1Assigns a value.
print("dict:", user)Outputs text to stdout.
🏢Real-world
  • 1Store and transform collections (filtering, grouping).
  • 2Use dicts for fast lookups.
Common Mistakes
  • 1Mutating lists unintentionally.
  • 2Using a list where a set/dict would be faster.
Best Practices
  • 1Choose the right container: list vs set vs dict.
  • 2Keep data transformations clear and readable.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 017

Python Sets

Learn Python Sets with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-sets.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
nums = [1, 2, 2, 3]Assigns a value.
print("list:", nums)Outputs text to stdout.
print("unique set:", set(nums))Outputs text to stdout.
user = {"name": "Mana", "level": 2}Assigns a value.
user["level"] += 1Assigns a value.
print("dict:", user)Outputs text to stdout.
🏢Real-world
  • 1Store and transform collections (filtering, grouping).
  • 2Use dicts for fast lookups.
Common Mistakes
  • 1Mutating lists unintentionally.
  • 2Using a list where a set/dict would be faster.
Best Practices
  • 1Choose the right container: list vs set vs dict.
  • 2Keep data transformations clear and readable.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 018

Python Dictionaries

Learn Python Dictionaries with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-dictionaries.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
nums = [1, 2, 2, 3]Assigns a value.
print("list:", nums)Outputs text to stdout.
print("unique set:", set(nums))Outputs text to stdout.
user = {"name": "Mana", "level": 2}Assigns a value.
user["level"] += 1Assigns a value.
print("dict:", user)Outputs text to stdout.
🏢Real-world
  • 1Store and transform collections (filtering, grouping).
  • 2Use dicts for fast lookups.
Common Mistakes
  • 1Mutating lists unintentionally.
  • 2Using a list where a set/dict would be faster.
Best Practices
  • 1Choose the right container: list vs set vs dict.
  • 2Keep data transformations clear and readable.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 019

Python If...Else

Learn Python If...Else with a small example you can edit and run.

📝Syntax
if condition:
    ...
elif other:
    ...
else:
    ...
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-if-else.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
score = 72Assigns a value.
if score >= 75:Conditional branch.
result = "Pass"Assigns a value.
elif score >= 50:Conditional branch.
result = "Retry"Assigns a value.
else:Conditional branch.
result = "Fail"Assigns a value.
print(result)Outputs text to stdout.
for i in range(1, 4):Loop: repeats code.
print("i =", i)Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 020

Python Match

Learn Python Match with a small example you can edit and run.

📝Syntax
if condition:
    ...
elif other:
    ...
else:
    ...
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-match.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
status = 404Assigns a value.
if status == 200:Conditional branch.
msg = "OK"Assigns a value.
elif status == 404:Conditional branch.
msg = "Not Found"Assigns a value.
else:Conditional branch.
msg = "Other"Assigns a value.
print(msg)Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 021

Python While Loops

Learn Python While Loops with a small example you can edit and run.

📝Syntax
for x in items:
    ...

while condition:
    ...
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-while-loops.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
score = 72Assigns a value.
if score >= 75:Conditional branch.
result = "Pass"Assigns a value.
elif score >= 50:Conditional branch.
result = "Retry"Assigns a value.
else:Conditional branch.
result = "Fail"Assigns a value.
print(result)Outputs text to stdout.
for i in range(1, 4):Loop: repeats code.
print("i =", i)Outputs text to stdout.
🏢Real-world
  • 1Model domain objects (User, Order, Product).
  • 2Organize larger projects into reusable components.
Common Mistakes
  • 1Overusing classes for simple scripts.
  • 2Forgetting `self` as the first parameter in methods.
Best Practices
  • 1Start with functions; add classes when you need state + behavior.
  • 2Use type hints for readability.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 022

Python For Loops

Learn Python For Loops with a small example you can edit and run.

📝Syntax
for x in items:
    ...

while condition:
    ...
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-for-loops.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
score = 72Assigns a value.
if score >= 75:Conditional branch.
result = "Pass"Assigns a value.
elif score >= 50:Conditional branch.
result = "Retry"Assigns a value.
else:Conditional branch.
result = "Fail"Assigns a value.
print(result)Outputs text to stdout.
for i in range(1, 4):Loop: repeats code.
print("i =", i)Outputs text to stdout.
🏢Real-world
  • 1Model domain objects (User, Order, Product).
  • 2Organize larger projects into reusable components.
Common Mistakes
  • 1Overusing classes for simple scripts.
  • 2Forgetting `self` as the first parameter in methods.
Best Practices
  • 1Start with functions; add classes when you need state + behavior.
  • 2Use type hints for readability.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 023

Python Functions

Learn Python Functions with a small example you can edit and run.

📝Syntax
def name(arg):
    return value
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-functions.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
def greet(name: str) -> str:Defines a function.
return f"Hello, {name}!"Python statement.
print(greet("Developer"))Outputs text to stdout.
nums = [1, 2, 3]Assigns a value.
for x in nums:Loop: repeats code.
print(x)Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 024

Python Range

Learn Python Range with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-range.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
score = 72Assigns a value.
if score >= 75:Conditional branch.
result = "Pass"Assigns a value.
elif score >= 50:Conditional branch.
result = "Retry"Assigns a value.
else:Conditional branch.
result = "Fail"Assigns a value.
print(result)Outputs text to stdout.
for i in range(1, 4):Loop: repeats code.
print("i =", i)Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 025

Python Arrays

Learn Python Arrays with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-arrays.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
nums = [1, 2, 2, 3]Assigns a value.
print("list:", nums)Outputs text to stdout.
print("unique set:", set(nums))Outputs text to stdout.
user = {"name": "Mana", "level": 2}Assigns a value.
user["level"] += 1Assigns a value.
print("dict:", user)Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 026

Python Iterators

Learn Python Iterators with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-iterators.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
def greet(name: str) -> str:Defines a function.
return f"Hello, {name}!"Python statement.
print(greet("Developer"))Outputs text to stdout.
nums = [1, 2, 3]Assigns a value.
for x in nums:Loop: repeats code.
print(x)Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 027

Python Modules

Learn Python Modules with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-modules.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
print("Use venv + pip for clean environments")Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 028

Python Dates

Learn Python Dates with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-dates.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
from datetime import datetimeImports a module.
now = datetime.now()Assigns a value.
print(now.strftime("%Y-%m-%d %H:%M"))Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 029

Python Math

Learn Python Math with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-math.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
a = 7Assigns a value.
b = 3Assigns a value.
print("a+b =", a + b)Outputs text to stdout.
print("a//b =", a // b)Outputs text to stdout.
print("float('3.14') =", float('3.14'))Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 030

Python JSON

Learn Python JSON with a small example you can edit and run.

📝Syntax
import json
json.dumps(obj)
json.loads(s)
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-json.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
import jsonImports a module.
obj = {"ok": True, "count": 3}Assigns a value.
s = json.dumps(obj)Assigns a value.
print(s)Outputs text to stdout.
print(json.loads(s))Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 031

Python RegEx

Learn Python RegEx with a small example you can edit and run.

📝Syntax
import re
re.search(r'pattern', text)
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-regex.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
import reImports a module.
text = "email: test@example.com"Assigns a value.
m = re.search(r"[\w.-]+@[\w.-]+", text)Assigns a value.
print(m.group(0) if m else "no match")Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 032

Python PIP

Learn Python PIP with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-pip.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
print("Use venv + pip for clean environments")Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 033

Python Try...Except

Learn Python Try...Except with a small example you can edit and run.

📝Syntax
try:
    ...
except Exception as e:
    ...
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-try-except.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
try:Error handling block.
int("not-a-number")Python statement.
except ValueError as e:Error handling block.
print("Error:", e)Outputs text to stdout.
🏢Real-world
  • 1Handle invalid user input and network failures gracefully.
  • 2Wrap risky parsing with clear errors.
Common Mistakes
  • 1Catching bare `except:` and hiding bugs.
  • 2Swallowing errors without logging.
Best Practices
  • 1Catch specific exceptions (ValueError, KeyError, etc.).
  • 2Log context when something fails.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 034

Python String Formatting

Learn Python String Formatting with a small example you can edit and run.

📝Syntax
for x in items:
    ...

while condition:
    ...
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-string-formatting.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
name = "Mana"Assigns a value.
score = 86Assigns a value.
print(f"{name} scored {score}")Outputs text to stdout.
print("{} scored {}".format(name, score))Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 035

Python None

Learn Python None with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-none.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
name = "Mana"Assigns a value.
age = 18Assigns a value.
is_active = TrueAssigns a value.
nothing = NoneAssigns a value.
print(type(name), type(age), type(is_active), type(nothing))Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 036

Python User Input

Learn Python User Input with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-user-input.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
print("Practice: edit this example")Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 037

Python VirtualEnv

Learn Python VirtualEnv with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-virtualenv.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
print("Use venv + pip for clean environments")Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
Python Classes & OOP
∙ Chapter 038

Python Classes

Learn Python Classes with a small example you can edit and run.

📝Syntax
class Name:
    def __init__(self):
        ...
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-classes.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
class User:Defines a class.
def __init__(self, name: str):Defines a function.
self.name = nameAssigns a value.
def greet(self) -> str:Defines a function.
return f"Hi, I am {self.name}"Python statement.
u = User("Mana")Assigns a value.
print(u.greet())Outputs text to stdout.
🏢Real-world
  • 1Model domain objects (User, Order, Product).
  • 2Organize larger projects into reusable components.
Common Mistakes
  • 1Overusing classes for simple scripts.
  • 2Forgetting `self` as the first parameter in methods.
Best Practices
  • 1Start with functions; add classes when you need state + behavior.
  • 2Use type hints for readability.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 039

Python OOP

Learn Python OOP with a small example you can edit and run.

📝Syntax
class Name:
    def __init__(self):
        ...
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-oop.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
class User:Defines a class.
def __init__(self, name: str):Defines a function.
self.name = nameAssigns a value.
def greet(self) -> str:Defines a function.
return f"Hi, I am {self.name}"Python statement.
u = User("Mana")Assigns a value.
print(u.greet())Outputs text to stdout.
🏢Real-world
  • 1Model domain objects (User, Order, Product).
  • 2Organize larger projects into reusable components.
Common Mistakes
  • 1Overusing classes for simple scripts.
  • 2Forgetting `self` as the first parameter in methods.
Best Practices
  • 1Start with functions; add classes when you need state + behavior.
  • 2Use type hints for readability.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 040

Python Classes/Objects

Learn Python Classes/Objects with a small example you can edit and run.

📝Syntax
class Name:
    def __init__(self):
        ...
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-classes-objects.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
class User:Defines a class.
def __init__(self, name: str):Defines a function.
self.name = nameAssigns a value.
def greet(self) -> str:Defines a function.
return f"Hi, I am {self.name}"Python statement.
u = User("Mana")Assigns a value.
print(u.greet())Outputs text to stdout.
🏢Real-world
  • 1Model domain objects (User, Order, Product).
  • 2Organize larger projects into reusable components.
Common Mistakes
  • 1Overusing classes for simple scripts.
  • 2Forgetting `self` as the first parameter in methods.
Best Practices
  • 1Start with functions; add classes when you need state + behavior.
  • 2Use type hints for readability.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 041

Python __init__ Method

Learn Python __init__ Method with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-init-method.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
print("Practice: edit this example")Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 042

Python self Parameter

Learn Python self Parameter with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-self-parameter.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
print("Practice: edit this example")Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 043

Python Class Properties

Learn Python Class Properties with a small example you can edit and run.

📝Syntax
class Name:
    def __init__(self):
        ...
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-class-properties.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
class User:Defines a class.
def __init__(self, name: str):Defines a function.
self.name = nameAssigns a value.
def greet(self) -> str:Defines a function.
return f"Hi, I am {self.name}"Python statement.
u = User("Mana")Assigns a value.
print(u.greet())Outputs text to stdout.
🏢Real-world
  • 1Model domain objects (User, Order, Product).
  • 2Organize larger projects into reusable components.
Common Mistakes
  • 1Overusing classes for simple scripts.
  • 2Forgetting `self` as the first parameter in methods.
Best Practices
  • 1Start with functions; add classes when you need state + behavior.
  • 2Use type hints for readability.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 044

Python Class Methods

Learn Python Class Methods with a small example you can edit and run.

📝Syntax
class Name:
    def __init__(self):
        ...
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-class-methods.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
class User:Defines a class.
def __init__(self, name: str):Defines a function.
self.name = nameAssigns a value.
def greet(self) -> str:Defines a function.
return f"Hi, I am {self.name}"Python statement.
u = User("Mana")Assigns a value.
print(u.greet())Outputs text to stdout.
🏢Real-world
  • 1Model domain objects (User, Order, Product).
  • 2Organize larger projects into reusable components.
Common Mistakes
  • 1Overusing classes for simple scripts.
  • 2Forgetting `self` as the first parameter in methods.
Best Practices
  • 1Start with functions; add classes when you need state + behavior.
  • 2Use type hints for readability.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 045

Python Inheritance

Learn Python Inheritance with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-inheritance.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
class User:Defines a class.
def __init__(self, name: str):Defines a function.
self.name = nameAssigns a value.
def greet(self) -> str:Defines a function.
return f"Hi, I am {self.name}"Python statement.
u = User("Mana")Assigns a value.
print(u.greet())Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 046

Python Polymorphism

Learn Python Polymorphism with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-polymorphism.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
class User:Defines a class.
def __init__(self, name: str):Defines a function.
self.name = nameAssigns a value.
def greet(self) -> str:Defines a function.
return f"Hi, I am {self.name}"Python statement.
u = User("Mana")Assigns a value.
print(u.greet())Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 047

Python Encapsulation

Learn Python Encapsulation with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-encapsulation.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
class User:Defines a class.
def __init__(self, name: str):Defines a function.
self.name = nameAssigns a value.
def greet(self) -> str:Defines a function.
return f"Hi, I am {self.name}"Python statement.
u = User("Mana")Assigns a value.
print(u.greet())Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 048

Python Inner Classes

Learn Python Inner Classes with a small example you can edit and run.

📝Syntax
class Name:
    def __init__(self):
        ...
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-inner-classes.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
class User:Defines a class.
def __init__(self, name: str):Defines a function.
self.name = nameAssigns a value.
def greet(self) -> str:Defines a function.
return f"Hi, I am {self.name}"Python statement.
u = User("Mana")Assigns a value.
print(u.greet())Outputs text to stdout.
🏢Real-world
  • 1Model domain objects (User, Order, Product).
  • 2Organize larger projects into reusable components.
Common Mistakes
  • 1Overusing classes for simple scripts.
  • 2Forgetting `self` as the first parameter in methods.
Best Practices
  • 1Start with functions; add classes when you need state + behavior.
  • 2Use type hints for readability.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
File Handling
∙ Chapter 049

File Handling

Learn File Handling with a small example you can edit and run.

📝Syntax
with open('file.txt', 'r', encoding='utf-8') as f:
    data = f.read()
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

file-handling.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
path = "demo.txt"Assigns a value.
with open(path, "w", encoding="utf-8") as f:Context manager (ensures cleanup).
f.write("Hello file\n")Python statement.
with open(path, "r", encoding="utf-8") as f:Context manager (ensures cleanup).
print(f.read())Outputs text to stdout.
🏢Real-world
  • 1Read configuration files and write reports/logs.
  • 2Process CSV/text files in automation.
Common Mistakes
  • 1Forgetting to close files (fixed by `with open(...)`).
  • 2Mixing encodings and getting weird characters.
Best Practices
  • 1Always use `with open(..., encoding=\"utf-8\")`.
  • 2Keep file paths configurable.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 050

Python File Handling

Learn Python File Handling with a small example you can edit and run.

📝Syntax
with open('file.txt', 'r', encoding='utf-8') as f:
    data = f.read()
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-file-handling.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
path = "demo.txt"Assigns a value.
with open(path, "w", encoding="utf-8") as f:Context manager (ensures cleanup).
f.write("Hello file\n")Python statement.
with open(path, "r", encoding="utf-8") as f:Context manager (ensures cleanup).
print(f.read())Outputs text to stdout.
🏢Real-world
  • 1Read configuration files and write reports/logs.
  • 2Process CSV/text files in automation.
Common Mistakes
  • 1Forgetting to close files (fixed by `with open(...)`).
  • 2Mixing encodings and getting weird characters.
Best Practices
  • 1Always use `with open(..., encoding=\"utf-8\")`.
  • 2Keep file paths configurable.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 051

Python Read Files

Learn Python Read Files with a small example you can edit and run.

📝Syntax
with open('file.txt', 'r', encoding='utf-8') as f:
    data = f.read()
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-read-files.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
path = "demo.txt"Assigns a value.
with open(path, "w", encoding="utf-8") as f:Context manager (ensures cleanup).
f.write("Hello file\n")Python statement.
with open(path, "r", encoding="utf-8") as f:Context manager (ensures cleanup).
print(f.read())Outputs text to stdout.
🏢Real-world
  • 1Read configuration files and write reports/logs.
  • 2Process CSV/text files in automation.
Common Mistakes
  • 1Forgetting to close files (fixed by `with open(...)`).
  • 2Mixing encodings and getting weird characters.
Best Practices
  • 1Always use `with open(..., encoding=\"utf-8\")`.
  • 2Keep file paths configurable.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 052

Python Write/Create Files

Learn Python Write/Create Files with a small example you can edit and run.

📝Syntax
with open('file.txt', 'r', encoding='utf-8') as f:
    data = f.read()
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-write-create-files.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
path = "demo.txt"Assigns a value.
with open(path, "w", encoding="utf-8") as f:Context manager (ensures cleanup).
f.write("Hello file\n")Python statement.
with open(path, "r", encoding="utf-8") as f:Context manager (ensures cleanup).
print(f.read())Outputs text to stdout.
🏢Real-world
  • 1Read configuration files and write reports/logs.
  • 2Process CSV/text files in automation.
Common Mistakes
  • 1Forgetting to close files (fixed by `with open(...)`).
  • 2Mixing encodings and getting weird characters.
Best Practices
  • 1Always use `with open(..., encoding=\"utf-8\")`.
  • 2Keep file paths configurable.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 053

Python Delete Files

Learn Python Delete Files with a small example you can edit and run.

📝Syntax
with open('file.txt', 'r', encoding='utf-8') as f:
    data = f.read()
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-delete-files.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
path = "demo.txt"Assigns a value.
with open(path, "w", encoding="utf-8") as f:Context manager (ensures cleanup).
f.write("Hello file\n")Python statement.
with open(path, "r", encoding="utf-8") as f:Context manager (ensures cleanup).
print(f.read())Outputs text to stdout.
🏢Real-world
  • 1Read configuration files and write reports/logs.
  • 2Process CSV/text files in automation.
Common Mistakes
  • 1Forgetting to close files (fixed by `with open(...)`).
  • 2Mixing encodings and getting weird characters.
Best Practices
  • 1Always use `with open(..., encoding=\"utf-8\")`.
  • 2Keep file paths configurable.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
Python Modules & Frameworks
∙ Chapter 054

Python Modules (Modules & Frameworks)

Learn Python Modules (Modules & Frameworks) with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-modules.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
print("Use venv + pip for clean environments")Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 055

NumPy Tutorial

Learn NumPy Tutorial with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

numpy-tutorial.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
name = "Mana"Assigns a value.
score = 86Assigns a value.
print(f"{name} passed with {score}")Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 056

Pandas Tutorial

Learn Pandas Tutorial with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

pandas-tutorial.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
name = "Mana"Assigns a value.
score = 86Assigns a value.
print(f"{name} passed with {score}")Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 057

SciPy Tutorial

Learn SciPy Tutorial with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

scipy-tutorial.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
name = "Mana"Assigns a value.
score = 86Assigns a value.
print(f"{name} passed with {score}")Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 058

Django Tutorial

Learn Django Tutorial with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

django-tutorial.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
name = "Mana"Assigns a value.
score = 86Assigns a value.
print(f"{name} passed with {score}")Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
Python Matplotlib
∙ Chapter 059

Python Matplotlib

Learn Python Matplotlib with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-matplotlib.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
try:Error handling block.
import matplotlibImports a module.
print("matplotlib version:", matplotlib.__version__)Outputs text to stdout.
except Exception:Error handling block.
print("Matplotlib may not be installed in this environment.")Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 060

Matplotlib Intro

Learn Matplotlib Intro with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

matplotlib-intro.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
name = "Mana"Assigns a value.
score = 86Assigns a value.
print(f"{name} passed with {score}")Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 061

Matplotlib Get Started

Learn Matplotlib Get Started with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

matplotlib-get-started.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
name = "Mana"Assigns a value.
score = 86Assigns a value.
print(f"{name} passed with {score}")Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 062

Matplotlib Pyplot

Learn Matplotlib Pyplot with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

matplotlib-pyplot.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
try:Error handling block.
import matplotlibImports a module.
print("matplotlib version:", matplotlib.__version__)Outputs text to stdout.
except Exception:Error handling block.
print("Matplotlib may not be installed in this environment.")Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 063

Matplotlib Plotting

Learn Matplotlib Plotting with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

matplotlib-plotting.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
try:Error handling block.
import matplotlibImports a module.
print("matplotlib version:", matplotlib.__version__)Outputs text to stdout.
except Exception:Error handling block.
print("Matplotlib may not be installed in this environment.")Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 064

Matplotlib Markers

Learn Matplotlib Markers with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

matplotlib-markers.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
try:Error handling block.
import matplotlibImports a module.
print("matplotlib version:", matplotlib.__version__)Outputs text to stdout.
except Exception:Error handling block.
print("Matplotlib may not be installed in this environment.")Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 065

Matplotlib Line

Learn Matplotlib Line with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

matplotlib-line.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
try:Error handling block.
import matplotlibImports a module.
print("matplotlib version:", matplotlib.__version__)Outputs text to stdout.
except Exception:Error handling block.
print("Matplotlib may not be installed in this environment.")Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 066

Matplotlib Labels

Learn Matplotlib Labels with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

matplotlib-labels.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
try:Error handling block.
import matplotlibImports a module.
print("matplotlib version:", matplotlib.__version__)Outputs text to stdout.
except Exception:Error handling block.
print("Matplotlib may not be installed in this environment.")Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 067

Matplotlib Grid

Learn Matplotlib Grid with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

matplotlib-grid.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
try:Error handling block.
import matplotlibImports a module.
print("matplotlib version:", matplotlib.__version__)Outputs text to stdout.
except Exception:Error handling block.
print("Matplotlib may not be installed in this environment.")Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 068

Matplotlib Subplot

Learn Matplotlib Subplot with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

matplotlib-subplot.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
try:Error handling block.
import matplotlibImports a module.
print("matplotlib version:", matplotlib.__version__)Outputs text to stdout.
except Exception:Error handling block.
print("Matplotlib may not be installed in this environment.")Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 069

Matplotlib Scatter

Learn Matplotlib Scatter with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

matplotlib-scatter.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
try:Error handling block.
import matplotlibImports a module.
print("matplotlib version:", matplotlib.__version__)Outputs text to stdout.
except Exception:Error handling block.
print("Matplotlib may not be installed in this environment.")Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 070

Matplotlib Bars

Learn Matplotlib Bars with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

matplotlib-bars.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
try:Error handling block.
import matplotlibImports a module.
print("matplotlib version:", matplotlib.__version__)Outputs text to stdout.
except Exception:Error handling block.
print("Matplotlib may not be installed in this environment.")Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 071

Matplotlib Histograms

Learn Matplotlib Histograms with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

matplotlib-histograms.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
try:Error handling block.
import matplotlibImports a module.
print("matplotlib version:", matplotlib.__version__)Outputs text to stdout.
except Exception:Error handling block.
print("Matplotlib may not be installed in this environment.")Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 072

Matplotlib Pie Charts

Learn Matplotlib Pie Charts with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

matplotlib-pie-charts.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
try:Error handling block.
import matplotlibImports a module.
print("matplotlib version:", matplotlib.__version__)Outputs text to stdout.
except Exception:Error handling block.
print("Matplotlib may not be installed in this environment.")Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
Machine Learning
∙ Chapter 073

Machine Learning

Learn Machine Learning with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

machine-learning.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
from statistics import mean, medianImports a module.
nums = [1, 2, 2, 3, 9]Assigns a value.
print("mean:", mean(nums))Outputs text to stdout.
print("median:", median(nums))Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 074

Getting Started

Learn Getting Started with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

getting-started.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
print("Practice: edit this example")Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 075

Mean Median Mode

Learn Mean Median Mode with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

mean-median-mode.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
from statistics import mean, medianImports a module.
nums = [1, 2, 2, 3, 9]Assigns a value.
print("mean:", mean(nums))Outputs text to stdout.
print("median:", median(nums))Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 076

Standard Deviation

Learn Standard Deviation with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

standard-deviation.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
from statistics import mean, medianImports a module.
nums = [1, 2, 2, 3, 9]Assigns a value.
print("mean:", mean(nums))Outputs text to stdout.
print("median:", median(nums))Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 077

Percentile

Learn Percentile with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

percentile.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
from statistics import mean, medianImports a module.
nums = [1, 2, 2, 3, 9]Assigns a value.
print("mean:", mean(nums))Outputs text to stdout.
print("median:", median(nums))Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 078

Data Distribution

Learn Data Distribution with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

data-distribution.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
print("Practice: edit this example")Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 079

Normal Data Distribution

Learn Normal Data Distribution with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

normal-data-distribution.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
print("Practice: edit this example")Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 080

Scatter Plot

Learn Scatter Plot with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

scatter-plot.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
print("Practice: edit this example")Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 081

Linear Regression

Learn Linear Regression with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

linear-regression.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
from statistics import mean, medianImports a module.
nums = [1, 2, 2, 3, 9]Assigns a value.
print("mean:", mean(nums))Outputs text to stdout.
print("median:", median(nums))Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 082

Polynomial Regression

Learn Polynomial Regression with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

polynomial-regression.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
from statistics import mean, medianImports a module.
nums = [1, 2, 2, 3, 9]Assigns a value.
print("mean:", mean(nums))Outputs text to stdout.
print("median:", median(nums))Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 083

Multiple Regression

Learn Multiple Regression with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

multiple-regression.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
from statistics import mean, medianImports a module.
nums = [1, 2, 2, 3, 9]Assigns a value.
print("mean:", mean(nums))Outputs text to stdout.
print("median:", median(nums))Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 084

Scale

Learn Scale with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

scale.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
print("Practice: edit this example")Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 085

Train/Test

Learn Train/Test with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

train-test.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
print("Practice: edit this example")Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 086

Decision Tree

Learn Decision Tree with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

decision-tree.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
nums = [3, 1, 4, 1, 5]Assigns a value.
target = 4Assigns a value.
idx = -1Assigns a value.
for i, x in enumerate(nums):Loop: repeats code.
if x == target:Conditional branch.
idx = iAssigns a value.
breakPython statement.
print("found at", idx)Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 087

Confusion Matrix

Learn Confusion Matrix with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

confusion-matrix.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
print("Practice: edit this example")Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 088

Hierarchical Clustering

Learn Hierarchical Clustering with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

hierarchical-clustering.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
print("Practice: edit this example")Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 089

Logistic Regression

Learn Logistic Regression with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

logistic-regression.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
from statistics import mean, medianImports a module.
nums = [1, 2, 2, 3, 9]Assigns a value.
print("mean:", mean(nums))Outputs text to stdout.
print("median:", median(nums))Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 091

Categorical Data

Learn Categorical Data with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

categorical-data.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
print("Practice: edit this example")Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 092

K-means

Learn K-means with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

k-means.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
from statistics import mean, medianImports a module.
nums = [1, 2, 2, 3, 9]Assigns a value.
print("mean:", mean(nums))Outputs text to stdout.
print("median:", median(nums))Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 093

Bootstrap Aggregation

Learn Bootstrap Aggregation with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

bootstrap-aggregation.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
print("Practice: edit this example")Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 094

Cross Validation

Learn Cross Validation with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

cross-validation.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
print("Practice: edit this example")Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 095

AUC - ROC Curve

Learn AUC - ROC Curve with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

auc-roc-curve.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
print("Practice: edit this example")Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 096

K-nearest neighbors

Learn K-nearest neighbors with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

k-nearest-neighbors.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
print("Practice: edit this example")Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
Python DSA
∙ Chapter 097

Python DSA

Learn Python DSA with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-dsa.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
print("Practice: edit this example")Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 098

Lists and Arrays

Learn Lists and Arrays with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

lists-and-arrays.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
nums = [1, 2, 2, 3]Assigns a value.
print("list:", nums)Outputs text to stdout.
print("unique set:", set(nums))Outputs text to stdout.
user = {"name": "Mana", "level": 2}Assigns a value.
user["level"] += 1Assigns a value.
print("dict:", user)Outputs text to stdout.
🏢Real-world
  • 1Store and transform collections (filtering, grouping).
  • 2Use dicts for fast lookups.
Common Mistakes
  • 1Mutating lists unintentionally.
  • 2Using a list where a set/dict would be faster.
Best Practices
  • 1Choose the right container: list vs set vs dict.
  • 2Keep data transformations clear and readable.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 099

Stacks

Learn Stacks with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

stacks.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
nums = [3, 1, 4, 1, 5]Assigns a value.
target = 4Assigns a value.
idx = -1Assigns a value.
for i, x in enumerate(nums):Loop: repeats code.
if x == target:Conditional branch.
idx = iAssigns a value.
breakPython statement.
print("found at", idx)Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 100

Queues

Learn Queues with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

queues.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
nums = [3, 1, 4, 1, 5]Assigns a value.
target = 4Assigns a value.
idx = -1Assigns a value.
for i, x in enumerate(nums):Loop: repeats code.
if x == target:Conditional branch.
idx = iAssigns a value.
breakPython statement.
print("found at", idx)Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 101

Linked Lists

Learn Linked Lists with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

linked-lists.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
nums = [1, 2, 2, 3]Assigns a value.
print("list:", nums)Outputs text to stdout.
print("unique set:", set(nums))Outputs text to stdout.
user = {"name": "Mana", "level": 2}Assigns a value.
user["level"] += 1Assigns a value.
print("dict:", user)Outputs text to stdout.
🏢Real-world
  • 1Store and transform collections (filtering, grouping).
  • 2Use dicts for fast lookups.
Common Mistakes
  • 1Mutating lists unintentionally.
  • 2Using a list where a set/dict would be faster.
Best Practices
  • 1Choose the right container: list vs set vs dict.
  • 2Keep data transformations clear and readable.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 102

Hash Tables

Learn Hash Tables with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

hash-tables.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
nums = [3, 1, 4, 1, 5]Assigns a value.
target = 4Assigns a value.
idx = -1Assigns a value.
for i, x in enumerate(nums):Loop: repeats code.
if x == target:Conditional branch.
idx = iAssigns a value.
breakPython statement.
print("found at", idx)Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 103

Trees

Learn Trees with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

trees.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
nums = [3, 1, 4, 1, 5]Assigns a value.
target = 4Assigns a value.
idx = -1Assigns a value.
for i, x in enumerate(nums):Loop: repeats code.
if x == target:Conditional branch.
idx = iAssigns a value.
breakPython statement.
print("found at", idx)Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 104

Binary Trees

Learn Binary Trees with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

binary-trees.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
nums = [3, 1, 4, 1, 5]Assigns a value.
target = 4Assigns a value.
idx = -1Assigns a value.
for i, x in enumerate(nums):Loop: repeats code.
if x == target:Conditional branch.
idx = iAssigns a value.
breakPython statement.
print("found at", idx)Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 105

Binary Search Trees

Learn Binary Search Trees with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

binary-search-trees.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
nums = [3, 1, 4, 1, 5]Assigns a value.
target = 4Assigns a value.
idx = -1Assigns a value.
for i, x in enumerate(nums):Loop: repeats code.
if x == target:Conditional branch.
idx = iAssigns a value.
breakPython statement.
print("found at", idx)Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 106

AVL Trees

Learn AVL Trees with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

avl-trees.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
nums = [3, 1, 4, 1, 5]Assigns a value.
target = 4Assigns a value.
idx = -1Assigns a value.
for i, x in enumerate(nums):Loop: repeats code.
if x == target:Conditional branch.
idx = iAssigns a value.
breakPython statement.
print("found at", idx)Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 107

Graphs

Learn Graphs with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

graphs.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
nums = [3, 1, 4, 1, 5]Assigns a value.
target = 4Assigns a value.
idx = -1Assigns a value.
for i, x in enumerate(nums):Loop: repeats code.
if x == target:Conditional branch.
idx = iAssigns a value.
breakPython statement.
print("found at", idx)Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 110

Bubble Sort

Learn Bubble Sort with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

bubble-sort.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
nums = [3, 1, 4, 1, 5]Assigns a value.
target = 4Assigns a value.
idx = -1Assigns a value.
for i, x in enumerate(nums):Loop: repeats code.
if x == target:Conditional branch.
idx = iAssigns a value.
breakPython statement.
print("found at", idx)Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 111

Selection Sort

Learn Selection Sort with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

selection-sort.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
nums = [3, 1, 4, 1, 5]Assigns a value.
target = 4Assigns a value.
idx = -1Assigns a value.
for i, x in enumerate(nums):Loop: repeats code.
if x == target:Conditional branch.
idx = iAssigns a value.
breakPython statement.
print("found at", idx)Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 112

Insertion Sort

Learn Insertion Sort with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

insertion-sort.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
nums = [3, 1, 4, 1, 5]Assigns a value.
target = 4Assigns a value.
idx = -1Assigns a value.
for i, x in enumerate(nums):Loop: repeats code.
if x == target:Conditional branch.
idx = iAssigns a value.
breakPython statement.
print("found at", idx)Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 113

Quick Sort

Learn Quick Sort with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

quick-sort.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
nums = [3, 1, 4, 1, 5]Assigns a value.
target = 4Assigns a value.
idx = -1Assigns a value.
for i, x in enumerate(nums):Loop: repeats code.
if x == target:Conditional branch.
idx = iAssigns a value.
breakPython statement.
print("found at", idx)Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 114

Counting Sort

Learn Counting Sort with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

counting-sort.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
nums = [3, 1, 4, 1, 5]Assigns a value.
target = 4Assigns a value.
idx = -1Assigns a value.
for i, x in enumerate(nums):Loop: repeats code.
if x == target:Conditional branch.
idx = iAssigns a value.
breakPython statement.
print("found at", idx)Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 115

Radix Sort

Learn Radix Sort with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

radix-sort.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
nums = [3, 1, 4, 1, 5]Assigns a value.
target = 4Assigns a value.
idx = -1Assigns a value.
for i, x in enumerate(nums):Loop: repeats code.
if x == target:Conditional branch.
idx = iAssigns a value.
breakPython statement.
print("found at", idx)Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 116

Merge Sort

Learn Merge Sort with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

merge-sort.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
nums = [3, 1, 4, 1, 5]Assigns a value.
target = 4Assigns a value.
idx = -1Assigns a value.
for i, x in enumerate(nums):Loop: repeats code.
if x == target:Conditional branch.
idx = iAssigns a value.
breakPython statement.
print("found at", idx)Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
Python MySQL
∙ Chapter 117

Python MySQL

Learn Python MySQL with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-mysql.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
print("Use a DB driver (mysql-connector / pymongo) in real projects")Outputs text to stdout.
🏢Real-world
  • 1Read/write application data and build CRUD services.
  • 2Use parameterized queries to avoid SQL injection.
Common Mistakes
  • 1Hardcoding credentials in code.
  • 2Building SQL via string concatenation.
Best Practices
  • 1Use env vars for secrets.
  • 2Use parameterized queries / ORM as appropriate.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 118

MySQL Get Started

Learn MySQL Get Started with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

mysql-get-started.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
name = "Mana"Assigns a value.
score = 86Assigns a value.
print(f"{name} passed with {score}")Outputs text to stdout.
🏢Real-world
  • 1Read/write application data and build CRUD services.
  • 2Use parameterized queries to avoid SQL injection.
Common Mistakes
  • 1Hardcoding credentials in code.
  • 2Building SQL via string concatenation.
Best Practices
  • 1Use env vars for secrets.
  • 2Use parameterized queries / ORM as appropriate.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 119

MySQL Create Database

Learn MySQL Create Database with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

mysql-create-database.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
print("Use a DB driver (mysql-connector / pymongo) in real projects")Outputs text to stdout.
🏢Real-world
  • 1Read/write application data and build CRUD services.
  • 2Use parameterized queries to avoid SQL injection.
Common Mistakes
  • 1Hardcoding credentials in code.
  • 2Building SQL via string concatenation.
Best Practices
  • 1Use env vars for secrets.
  • 2Use parameterized queries / ORM as appropriate.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 120

MySQL Create Table

Learn MySQL Create Table with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

mysql-create-table.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
print("Use a DB driver (mysql-connector / pymongo) in real projects")Outputs text to stdout.
🏢Real-world
  • 1Read/write application data and build CRUD services.
  • 2Use parameterized queries to avoid SQL injection.
Common Mistakes
  • 1Hardcoding credentials in code.
  • 2Building SQL via string concatenation.
Best Practices
  • 1Use env vars for secrets.
  • 2Use parameterized queries / ORM as appropriate.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 121

MySQL Insert

Learn MySQL Insert with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

mysql-insert.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
print("Use a DB driver (mysql-connector / pymongo) in real projects")Outputs text to stdout.
🏢Real-world
  • 1Read/write application data and build CRUD services.
  • 2Use parameterized queries to avoid SQL injection.
Common Mistakes
  • 1Hardcoding credentials in code.
  • 2Building SQL via string concatenation.
Best Practices
  • 1Use env vars for secrets.
  • 2Use parameterized queries / ORM as appropriate.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 122

MySQL Select

Learn MySQL Select with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

mysql-select.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
print("Use a DB driver (mysql-connector / pymongo) in real projects")Outputs text to stdout.
🏢Real-world
  • 1Read/write application data and build CRUD services.
  • 2Use parameterized queries to avoid SQL injection.
Common Mistakes
  • 1Hardcoding credentials in code.
  • 2Building SQL via string concatenation.
Best Practices
  • 1Use env vars for secrets.
  • 2Use parameterized queries / ORM as appropriate.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 123

MySQL Where

Learn MySQL Where with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

mysql-where.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
print("Use a DB driver (mysql-connector / pymongo) in real projects")Outputs text to stdout.
🏢Real-world
  • 1Read/write application data and build CRUD services.
  • 2Use parameterized queries to avoid SQL injection.
Common Mistakes
  • 1Hardcoding credentials in code.
  • 2Building SQL via string concatenation.
Best Practices
  • 1Use env vars for secrets.
  • 2Use parameterized queries / ORM as appropriate.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 124

MySQL Order By

Learn MySQL Order By with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

mysql-order-by.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
print("Use a DB driver (mysql-connector / pymongo) in real projects")Outputs text to stdout.
🏢Real-world
  • 1Read/write application data and build CRUD services.
  • 2Use parameterized queries to avoid SQL injection.
Common Mistakes
  • 1Hardcoding credentials in code.
  • 2Building SQL via string concatenation.
Best Practices
  • 1Use env vars for secrets.
  • 2Use parameterized queries / ORM as appropriate.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 125

MySQL Delete

Learn MySQL Delete with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

mysql-delete.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
path = "demo.txt"Assigns a value.
with open(path, "w", encoding="utf-8") as f:Context manager (ensures cleanup).
f.write("Hello file\n")Python statement.
with open(path, "r", encoding="utf-8") as f:Context manager (ensures cleanup).
print(f.read())Outputs text to stdout.
🏢Real-world
  • 1Read/write application data and build CRUD services.
  • 2Use parameterized queries to avoid SQL injection.
Common Mistakes
  • 1Hardcoding credentials in code.
  • 2Building SQL via string concatenation.
Best Practices
  • 1Use env vars for secrets.
  • 2Use parameterized queries / ORM as appropriate.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 126

MySQL Drop Table

Learn MySQL Drop Table with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

mysql-drop-table.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
print("Use a DB driver (mysql-connector / pymongo) in real projects")Outputs text to stdout.
🏢Real-world
  • 1Read/write application data and build CRUD services.
  • 2Use parameterized queries to avoid SQL injection.
Common Mistakes
  • 1Hardcoding credentials in code.
  • 2Building SQL via string concatenation.
Best Practices
  • 1Use env vars for secrets.
  • 2Use parameterized queries / ORM as appropriate.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 127

MySQL Update

Learn MySQL Update with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

mysql-update.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
from datetime import datetimeImports a module.
now = datetime.now()Assigns a value.
print(now.strftime("%Y-%m-%d %H:%M"))Outputs text to stdout.
🏢Real-world
  • 1Read/write application data and build CRUD services.
  • 2Use parameterized queries to avoid SQL injection.
Common Mistakes
  • 1Hardcoding credentials in code.
  • 2Building SQL via string concatenation.
Best Practices
  • 1Use env vars for secrets.
  • 2Use parameterized queries / ORM as appropriate.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 128

MySQL Limit

Learn MySQL Limit with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

mysql-limit.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
print("Use a DB driver (mysql-connector / pymongo) in real projects")Outputs text to stdout.
🏢Real-world
  • 1Read/write application data and build CRUD services.
  • 2Use parameterized queries to avoid SQL injection.
Common Mistakes
  • 1Hardcoding credentials in code.
  • 2Building SQL via string concatenation.
Best Practices
  • 1Use env vars for secrets.
  • 2Use parameterized queries / ORM as appropriate.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 129

MySQL Join

Learn MySQL Join with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

mysql-join.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
print("Use a DB driver (mysql-connector / pymongo) in real projects")Outputs text to stdout.
🏢Real-world
  • 1Read/write application data and build CRUD services.
  • 2Use parameterized queries to avoid SQL injection.
Common Mistakes
  • 1Hardcoding credentials in code.
  • 2Building SQL via string concatenation.
Best Practices
  • 1Use env vars for secrets.
  • 2Use parameterized queries / ORM as appropriate.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
Python MongoDB
∙ Chapter 130

Python MongoDB

Learn Python MongoDB with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-mongodb.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
print("Use a DB driver (mysql-connector / pymongo) in real projects")Outputs text to stdout.
🏢Real-world
  • 1Read/write application data and build CRUD services.
  • 2Use parameterized queries to avoid SQL injection.
Common Mistakes
  • 1Hardcoding credentials in code.
  • 2Building SQL via string concatenation.
Best Practices
  • 1Use env vars for secrets.
  • 2Use parameterized queries / ORM as appropriate.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 131

MongoDB Get Started

Learn MongoDB Get Started with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

mongodb-get-started.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
name = "Mana"Assigns a value.
score = 86Assigns a value.
print(f"{name} passed with {score}")Outputs text to stdout.
🏢Real-world
  • 1Read/write application data and build CRUD services.
  • 2Use parameterized queries to avoid SQL injection.
Common Mistakes
  • 1Hardcoding credentials in code.
  • 2Building SQL via string concatenation.
Best Practices
  • 1Use env vars for secrets.
  • 2Use parameterized queries / ORM as appropriate.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 132

MongoDB Create DB

Learn MongoDB Create DB with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

mongodb-create-db.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
print("Use a DB driver (mysql-connector / pymongo) in real projects")Outputs text to stdout.
🏢Real-world
  • 1Read/write application data and build CRUD services.
  • 2Use parameterized queries to avoid SQL injection.
Common Mistakes
  • 1Hardcoding credentials in code.
  • 2Building SQL via string concatenation.
Best Practices
  • 1Use env vars for secrets.
  • 2Use parameterized queries / ORM as appropriate.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 133

MongoDB Collection

Learn MongoDB Collection with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

mongodb-collection.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
print("Use a DB driver (mysql-connector / pymongo) in real projects")Outputs text to stdout.
🏢Real-world
  • 1Read/write application data and build CRUD services.
  • 2Use parameterized queries to avoid SQL injection.
Common Mistakes
  • 1Hardcoding credentials in code.
  • 2Building SQL via string concatenation.
Best Practices
  • 1Use env vars for secrets.
  • 2Use parameterized queries / ORM as appropriate.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 134

MongoDB Insert

Learn MongoDB Insert with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

mongodb-insert.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
print("Use a DB driver (mysql-connector / pymongo) in real projects")Outputs text to stdout.
🏢Real-world
  • 1Read/write application data and build CRUD services.
  • 2Use parameterized queries to avoid SQL injection.
Common Mistakes
  • 1Hardcoding credentials in code.
  • 2Building SQL via string concatenation.
Best Practices
  • 1Use env vars for secrets.
  • 2Use parameterized queries / ORM as appropriate.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 135

MongoDB Find

Learn MongoDB Find with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

mongodb-find.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
print("Use a DB driver (mysql-connector / pymongo) in real projects")Outputs text to stdout.
🏢Real-world
  • 1Read/write application data and build CRUD services.
  • 2Use parameterized queries to avoid SQL injection.
Common Mistakes
  • 1Hardcoding credentials in code.
  • 2Building SQL via string concatenation.
Best Practices
  • 1Use env vars for secrets.
  • 2Use parameterized queries / ORM as appropriate.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 136

MongoDB Query

Learn MongoDB Query with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

mongodb-query.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
print("Use a DB driver (mysql-connector / pymongo) in real projects")Outputs text to stdout.
🏢Real-world
  • 1Read/write application data and build CRUD services.
  • 2Use parameterized queries to avoid SQL injection.
Common Mistakes
  • 1Hardcoding credentials in code.
  • 2Building SQL via string concatenation.
Best Practices
  • 1Use env vars for secrets.
  • 2Use parameterized queries / ORM as appropriate.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 137

MongoDB Sort

Learn MongoDB Sort with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

mongodb-sort.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
nums = [3, 1, 4, 1, 5]Assigns a value.
target = 4Assigns a value.
idx = -1Assigns a value.
for i, x in enumerate(nums):Loop: repeats code.
if x == target:Conditional branch.
idx = iAssigns a value.
breakPython statement.
print("found at", idx)Outputs text to stdout.
🏢Real-world
  • 1Read/write application data and build CRUD services.
  • 2Use parameterized queries to avoid SQL injection.
Common Mistakes
  • 1Hardcoding credentials in code.
  • 2Building SQL via string concatenation.
Best Practices
  • 1Use env vars for secrets.
  • 2Use parameterized queries / ORM as appropriate.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 138

MongoDB Delete

Learn MongoDB Delete with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

mongodb-delete.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
path = "demo.txt"Assigns a value.
with open(path, "w", encoding="utf-8") as f:Context manager (ensures cleanup).
f.write("Hello file\n")Python statement.
with open(path, "r", encoding="utf-8") as f:Context manager (ensures cleanup).
print(f.read())Outputs text to stdout.
🏢Real-world
  • 1Read/write application data and build CRUD services.
  • 2Use parameterized queries to avoid SQL injection.
Common Mistakes
  • 1Hardcoding credentials in code.
  • 2Building SQL via string concatenation.
Best Practices
  • 1Use env vars for secrets.
  • 2Use parameterized queries / ORM as appropriate.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 139

MongoDB Drop Collection

Learn MongoDB Drop Collection with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

mongodb-drop-collection.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
print("Use a DB driver (mysql-connector / pymongo) in real projects")Outputs text to stdout.
🏢Real-world
  • 1Read/write application data and build CRUD services.
  • 2Use parameterized queries to avoid SQL injection.
Common Mistakes
  • 1Hardcoding credentials in code.
  • 2Building SQL via string concatenation.
Best Practices
  • 1Use env vars for secrets.
  • 2Use parameterized queries / ORM as appropriate.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 140

MongoDB Update

Learn MongoDB Update with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

mongodb-update.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
from datetime import datetimeImports a module.
now = datetime.now()Assigns a value.
print(now.strftime("%Y-%m-%d %H:%M"))Outputs text to stdout.
🏢Real-world
  • 1Read/write application data and build CRUD services.
  • 2Use parameterized queries to avoid SQL injection.
Common Mistakes
  • 1Hardcoding credentials in code.
  • 2Building SQL via string concatenation.
Best Practices
  • 1Use env vars for secrets.
  • 2Use parameterized queries / ORM as appropriate.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 141

MongoDB Limit

Learn MongoDB Limit with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

mongodb-limit.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
print("Use a DB driver (mysql-connector / pymongo) in real projects")Outputs text to stdout.
🏢Real-world
  • 1Read/write application data and build CRUD services.
  • 2Use parameterized queries to avoid SQL injection.
Common Mistakes
  • 1Hardcoding credentials in code.
  • 2Building SQL via string concatenation.
Best Practices
  • 1Use env vars for secrets.
  • 2Use parameterized queries / ORM as appropriate.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
Python Reference
∙ Chapter 142

Python Reference

Learn Python Reference with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-reference.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
print("Practice: edit this example")Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 143

Python Overview

Learn Python Overview with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-overview.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
print("Practice: edit this example")Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 144

Python Built-in Functions

Learn Python Built-in Functions with a small example you can edit and run.

📝Syntax
def name(arg):
    return value
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-built-in-functions.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
def greet(name: str) -> str:Defines a function.
return f"Hello, {name}!"Python statement.
print(greet("Developer"))Outputs text to stdout.
nums = [1, 2, 3]Assigns a value.
for x in nums:Loop: repeats code.
print(x)Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 145

Python String Methods

Learn Python String Methods with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-string-methods.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
name = "Mana"Assigns a value.
streak = 7Assigns a value.
print(f"{name} has a {streak}-day streak")Outputs text to stdout.
print(name.upper())Outputs text to stdout.
print(name[0:2])Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 146

Python List Methods

Learn Python List Methods with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-list-methods.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
nums = [1, 2, 2, 3]Assigns a value.
print("list:", nums)Outputs text to stdout.
print("unique set:", set(nums))Outputs text to stdout.
user = {"name": "Mana", "level": 2}Assigns a value.
user["level"] += 1Assigns a value.
print("dict:", user)Outputs text to stdout.
🏢Real-world
  • 1Store and transform collections (filtering, grouping).
  • 2Use dicts for fast lookups.
Common Mistakes
  • 1Mutating lists unintentionally.
  • 2Using a list where a set/dict would be faster.
Best Practices
  • 1Choose the right container: list vs set vs dict.
  • 2Keep data transformations clear and readable.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 147

Python Dictionary Methods

Learn Python Dictionary Methods with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-dictionary-methods.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
nums = [1, 2, 2, 3]Assigns a value.
print("list:", nums)Outputs text to stdout.
print("unique set:", set(nums))Outputs text to stdout.
user = {"name": "Mana", "level": 2}Assigns a value.
user["level"] += 1Assigns a value.
print("dict:", user)Outputs text to stdout.
🏢Real-world
  • 1Store and transform collections (filtering, grouping).
  • 2Use dicts for fast lookups.
Common Mistakes
  • 1Mutating lists unintentionally.
  • 2Using a list where a set/dict would be faster.
Best Practices
  • 1Choose the right container: list vs set vs dict.
  • 2Keep data transformations clear and readable.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 148

Python Tuple Methods

Learn Python Tuple Methods with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-tuple-methods.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
nums = [1, 2, 2, 3]Assigns a value.
print("list:", nums)Outputs text to stdout.
print("unique set:", set(nums))Outputs text to stdout.
user = {"name": "Mana", "level": 2}Assigns a value.
user["level"] += 1Assigns a value.
print("dict:", user)Outputs text to stdout.
🏢Real-world
  • 1Store and transform collections (filtering, grouping).
  • 2Use dicts for fast lookups.
Common Mistakes
  • 1Mutating lists unintentionally.
  • 2Using a list where a set/dict would be faster.
Best Practices
  • 1Choose the right container: list vs set vs dict.
  • 2Keep data transformations clear and readable.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 149

Python Set Methods

Learn Python Set Methods with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-set-methods.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
nums = [1, 2, 2, 3]Assigns a value.
print("list:", nums)Outputs text to stdout.
print("unique set:", set(nums))Outputs text to stdout.
user = {"name": "Mana", "level": 2}Assigns a value.
user["level"] += 1Assigns a value.
print("dict:", user)Outputs text to stdout.
🏢Real-world
  • 1Store and transform collections (filtering, grouping).
  • 2Use dicts for fast lookups.
Common Mistakes
  • 1Mutating lists unintentionally.
  • 2Using a list where a set/dict would be faster.
Best Practices
  • 1Choose the right container: list vs set vs dict.
  • 2Keep data transformations clear and readable.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 150

Python File Methods

Learn Python File Methods with a small example you can edit and run.

📝Syntax
with open('file.txt', 'r', encoding='utf-8') as f:
    data = f.read()
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-file-methods.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
path = "demo.txt"Assigns a value.
with open(path, "w", encoding="utf-8") as f:Context manager (ensures cleanup).
f.write("Hello file\n")Python statement.
with open(path, "r", encoding="utf-8") as f:Context manager (ensures cleanup).
print(f.read())Outputs text to stdout.
🏢Real-world
  • 1Read configuration files and write reports/logs.
  • 2Process CSV/text files in automation.
Common Mistakes
  • 1Forgetting to close files (fixed by `with open(...)`).
  • 2Mixing encodings and getting weird characters.
Best Practices
  • 1Always use `with open(..., encoding=\"utf-8\")`.
  • 2Keep file paths configurable.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 151

Python Keywords

Learn Python Keywords with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-keywords.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
print("Practice: edit this example")Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 152

Python Exceptions

Learn Python Exceptions with a small example you can edit and run.

📝Syntax
try:
    ...
except Exception as e:
    ...
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-exceptions.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
try:Error handling block.
int("not-a-number")Python statement.
except ValueError as e:Error handling block.
print("Error:", e)Outputs text to stdout.
🏢Real-world
  • 1Handle invalid user input and network failures gracefully.
  • 2Wrap risky parsing with clear errors.
Common Mistakes
  • 1Catching bare `except:` and hiding bugs.
  • 2Swallowing errors without logging.
Best Practices
  • 1Catch specific exceptions (ValueError, KeyError, etc.).
  • 2Log context when something fails.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 153

Python Glossary

Learn Python Glossary with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-glossary.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
print("Practice: edit this example")Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
Module Reference
∙ Chapter 154

Module Reference

Learn Module Reference with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

module-reference.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
print("Use venv + pip for clean environments")Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 155

Built-in Modules

Learn Built-in Modules with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

built-in-modules.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
print("Use venv + pip for clean environments")Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 156

Random Module

Learn Random Module with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

random-module.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
print("Use venv + pip for clean environments")Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 157

Requests Module

Learn Requests Module with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

requests-module.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
print("Use venv + pip for clean environments")Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 158

Statistics Module

Learn Statistics Module with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

statistics-module.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
print("Use venv + pip for clean environments")Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 159

Math Module

Learn Math Module with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

math-module.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
a = 7Assigns a value.
b = 3Assigns a value.
print("a+b =", a + b)Outputs text to stdout.
print("a//b =", a // b)Outputs text to stdout.
print("float('3.14') =", float('3.14'))Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 160

cMath Module

Learn cMath Module with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

cmath-module.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
a = 7Assigns a value.
b = 3Assigns a value.
print("a+b =", a + b)Outputs text to stdout.
print("a//b =", a // b)Outputs text to stdout.
print("float('3.14') =", float('3.14'))Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
Python How To
∙ Chapter 161

Python How To

Learn Python How To with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

python-how-to.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
nums = [1, 2, 2, 3]Assigns a value.
print(list(dict.fromkeys(nums))) # remove duplicates, keep orderOutputs text to stdout.
s = "mana"Assigns a value.
print(s[::-1]) # reverse stringOutputs text to stdout.
print(7 + 5)Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 162

Remove List Duplicates

Learn Remove List Duplicates with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

remove-list-duplicates.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
nums = [1, 2, 2, 3]Assigns a value.
print("list:", nums)Outputs text to stdout.
print("unique set:", set(nums))Outputs text to stdout.
user = {"name": "Mana", "level": 2}Assigns a value.
user["level"] += 1Assigns a value.
print("dict:", user)Outputs text to stdout.
🏢Real-world
  • 1Store and transform collections (filtering, grouping).
  • 2Use dicts for fast lookups.
Common Mistakes
  • 1Mutating lists unintentionally.
  • 2Using a list where a set/dict would be faster.
Best Practices
  • 1Choose the right container: list vs set vs dict.
  • 2Keep data transformations clear and readable.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 163

Reverse a String

Learn Reverse a String with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

reverse-a-string.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
name = "Mana"Assigns a value.
streak = 7Assigns a value.
print(f"{name} has a {streak}-day streak")Outputs text to stdout.
print(name.upper())Outputs text to stdout.
print(name[0:2])Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
∙ Chapter 164

Add Two Numbers

Learn Add Two Numbers with a small example you can edit and run.

📝Syntax
statement
Example (Edit & Run)

Edit the Python code below and click Run. The output panel shows stdout and errors.

add-two-numbers.py
📝 Edit Code
👁 Output
💡 Tip: run often. If you get an error, read the line number first.
🔍Line-by-line
LineMeaning
a = 7Assigns a value.
b = 3Assigns a value.
print("a+b =", a + b)Outputs text to stdout.
print("a//b =", a // b)Outputs text to stdout.
print("float('3.14') =", float('3.14'))Outputs text to stdout.
🏢Real-world
  • 1Automation scripts, data processing, and backend services.
Common Mistakes
  • 1Indentation errors and missing colons (`:`) in blocks.
Best Practices
  • 1Write small functions and test often.
📖Summary & Practice
  • 1Practice the concept in a tiny script, then reuse it in a real project.
  • 2Read error messages carefully—Python is usually very clear.
💡Practice: answer the questions below, then modify the example to match your answers.
  • 1Change one line and predict the output before running.
  • 2Add one more case (edge case) to the example.
  • 3Explain the result in 1 sentence.
PreviousBack to Home
🎉 Python Tutorial Complete (164 topics)!
Next UpSQL Basics →