Python Interactive Tutorial for Beginners and Beyond
🐍 Python Interactive Tutorial: From Basics to Mastery
Introduction
Python is one of the most versatile programming languages today. In this tutorial, we’ll walk step‑by‑step through Python fundamentals, practice with interactive exercises, and explore real‑world applications.
1. Setting Up Python
Install Python from python.org.
python --version
2. Hello World
print("Hello, World!")
Try it yourself: Change the text to your name and run it.
3. Variables and Data Types
name = "Koikoi"
age = 25
is_student = True
str→ textint→ numbersbool→ True/False
Exercise: Create variables for your favorite food, number of siblings, and whether you like Python.
4. Control Flow (if/else)
score = 85
if score >= 50:
print("Pass")
else:
print("Fail")
Challenge: Write a program that checks if a number is even or odd.
5. Loops
for i in range(5):
print("Iteration:", i)
Try it: Create a loop that prints all numbers from 1 to 10.
6. Functions
def greet(name):
return f"Hello, {name}!"
print(greet("Benjamin"))
Exercise: Write a function that calculates the square of a number.
7. Lists and Dictionaries
fruits = ["apple", "banana", "cherry"]
person = {"name": "Koikoi", "age": 25}
Challenge: Add a new fruit to the list and a new key to the dictionary.
8. File Handling
with open("data.txt", "w") as file:
file.write("Hello, file!")
Try it: Write your name into a file and then read it back.
9. Real‑World Example: Simple Calculator
def calculator(a, b, operation):
if operation == "add":
return a + b
elif operation == "subtract":
return a - b
elif operation == "multiply":
return a * b
elif operation == "divide":
return a / b
print(calculator(10, 5, "add"))
Challenge: Extend the calculator to include modulus (%) and exponentiation (**).
Want to dive deeper? Read my related post on Python Lists Explained .
💻 Programming & Science Books — Only $1 Each
Learn coding, algorithms, and data science with my easy-to-follow tutorials.
Buy on Gumroad Buy on Amazon KDP

Comments
Post a Comment