Advanced Python Tutorials by DarchumsTech
Curated by Darlington Mbawike (Darchums)
Mission: "Empowering future tech minds through practical learning."
Lesson 3: Conditional Statements (if, elif, else)
Concept: Python can make decisions using if
, elif
, and else
based on conditions.
age = 18
if age >= 18:
print("You are an adult.")
else:
print("You are a minor.")
Interactive Prompt:
number = int(input("Enter a number: "))
if number > 0:
print("Positive")
elif number < 0:
print("Negative")
else:
print("Zero")
Quiz: What will this code print?
x = 10
if x < 5:
print("Low")
elif x < 15:
print("Medium")
else:
print("High")
- A) Low
- B) Medium ✅
- C) High
- D) Error
Lesson 4: Loops – for
and while
Concept: Loops help execute code multiple times efficiently.
for i in range(5):
print("Iteration", i)
count = 0
while count < 5:
print("Count is", count)
count += 1
Interactive Prompt:
for num in range(1, 21):
if num % 2 == 0:
print(num)
Quiz: How many times does this loop run?
i = 0
while i < 3:
print(i)
i += 1
- A) 2
- B) 3 ✅
- C) 4
- D) Infinite
Lesson 5: Functions in Python
Concept: Functions let you reuse blocks of code.
def greet(name):
return "Hello, " + name
print(greet("Darchums"))
Interactive Prompt:
def square(num):
return num * num
print(square(4))
Quiz: What is the output?
def add(a, b=5):
return a + b
print(add(3))
- A) 3
- B) 8 ✅
- C) Error
- D) 5
Lesson 6: Lists and List Methods
Concept: Lists can store multiple values, and Python offers many methods to work with them.
fruits = ["apple", "banana", "cherry"]
fruits.append("orange")
print(fruits)
Interactive Prompt:
colors = ["red", "blue", "green", "yellow", "black"]
colors.pop(2)
print(colors)
Quiz: What is the output?
nums = [1, 2, 3]
nums[1] = 10
print(nums)
- A) [1, 10, 3] ✅
- B) [10, 2, 3]
- C) Error
- D) [1, 2, 10]
Lesson 7: Dictionaries in Python
Concept: Dictionaries hold key-value pairs and are excellent for structured data.
person = {"name": "Alice", "age": 25}
print(person["name"])
Interactive Prompt:
profile = {
"name": "Darchums",
"age": 28,
"language": "Python"
}
print("My name is", profile["name"])
Quiz: What does this code return?
d = {"a": 1, "b": 2}
print(d.get("c", 3))
- A) 3 ✅
- B) 1
- C) None
- D) Error
More tutorials coming soon at DarchumsTech!
Comments
Post a Comment