Initializing Core...
Initializing Core...
Operational
Now that you know variables, data structures, and functions, letβs build some small projects.
Uses variables + functions.
def add(a, b): return a + bdef sub(a, b): return a - bdef mul(a, b): return a * bdef div(a, b): return a / ba = int(input("Enter first number: "))b = int(input("Enter second number: "))print("Addition:", add(a, b))print("Subtraction:", sub(a, b))print("Multiplication:", mul(a, b))print("Division:", div(a, b))
Uses dictionaries + functions.
def add_student(name, branch, year):return {"name": name, "branch": branch, "year": year}student1 = add_student("Zarine", "ECE", 2)print(student1)
Uses lists + loops.
tasks = []def add_task(task):tasks.append(task)def show_tasks():print("Your Tasks:")for i, t in enumerate(tasks, 1):print(f"{i}. {t}")add_task("Study Python")add_task("Complete Assignment")show_tasks()
Uses strings + functions.
def word_count(text):words = text.split()return len(words)sentence = "Python makes programming fun"print("Word count:", word_count(sentence))
Uses loops + conditions + random module.
import randomsecret = random.randint(1, 10)guess = int(input("Guess a number (1-10): "))if guess == secret:print("π Correct!")else:print("β Wrong! The number was", secret)