Master Python programming through hands-on coding challenges. Write real code, get instant feedback, and build practical skills.
Write actual Python code to solve each challenge. Your code is validated for correctness.
'text' or double quotes "text". Strings are used for text data and are immutable (cannot be changed after creation).type(age) to verify it's an int.0.1 + 0.2 may not exactly equal 0.3 due to floating-point representation.True or False to indicate student status. Note: Python booleans are capitalized (True/False), not lowercase like in some other languages. Booleans are actually a subtype of integers where True == 1 and False == 0.print() to display each variable with a descriptive label. You can use f-strings (formatted string literals) for clean output: print(f"Name: {name}"). Alternatively, use string concatenation with + or comma separation.is_student not isStudent)type(variable) to check a variable's typeName: Alice Johnson
Age: 28
Height: 1.65
Is Student: True
name = "Alice" or name = 'Alice'age = 28 (no type keyword needed)height = 1.65 (include decimal point)is_student = True (capital T/F)print(f"Age: {age}")print(type(name)) outputs <class 'str'>Review feedback below
grade = "" or assign it within the conditionals.if score >= 90: → Grade A (Excellent - top performers)elif score >= 80: → Grade B (Good - above average)elif score >= 70: → Grade C (Average - meets expectations)elif score >= 60: → Grade D (Below Average - needs improvement)else: → Grade F (Failing - below 60)elif not else if: are required after if/elif/else statements60 <= score < 70status = "PASSED" if score >= 60 else "FAILED"and, or, not for logical operators (not &&, ||, !)Score: 85
Grade: B
Status: PASSED
if score >= 90: (don't forget the colon!)elif score >= 80:>= > < <= == !=result = "A" if score >= 90 else "F"and, or, not (lowercase)Review feedback below
for i in range(1, 21):range(1, 21) generates numbers 1 through 20 (end value is exclusive!)range(start, stop) - stop is NOT includedrange(21) gives 0-20, but we want 1-20i % 3 == 0, then i divides evenly by 3 (no remainder), meaning i IS divisible by 3.9 % 3 = 0 (divisible), 10 % 3 = 1 (not divisible), 15 % 5 = 0 (divisible)and not &&: if i % 3 == 0 and i % 5 == 0:i % 15 == 0 (since 15 = 3 × 5)1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
FizzBuzz
for i in range(1, 21): (21 not included, so goes 1-20)if i % 3 == 0 and i % 5 == 0:if i % 15 == 0: (15 = 3 × 5)print(i)Review feedback below