Solutions Center

Model answers for every challenge in the curriculum.

Module 1: The Basics (Cards 1-3)

Card 1: Event System
print("Event: Tech Conference")
print("Date: 12th Nov")
print("Tickets: Available")
Card 2: Game Time
total_minutes = 135
hours = total_minutes // 60
minutes = total_minutes % 60
print(str(hours) + " hours " + str(minutes) + " mins")
Card 3: Security System
first = input("First Name: ")
last = input("Last Name: ")
print("Code: " + first + last)

Module 2: Decisions (Cards 4-6)

Card 4: Age Checker
age = int(input("Enter age: "))
is_adult = age >= 18
print("Adult: " + str(is_adult))
Card 5: Triangles
if s1 == s2 or s1 == s3 or s2 == s3:
    print("Isosceles")
else:
    print("Not Isosceles")
Card 6: Alarm Logic
if sensor > 50 and not override:
    print("ALARM")
elif sensor > 20: 
    print("Warning")
else:
    print("Normal")

Module 3: Loops & Lists (Cards 7-13)

Card 7: While Loop
sold = 0
while sold < 5:
    input("Sell ticket...")
    sold = sold + 1
print("Sold Out")
Card 9: Lists
scores = [10, 20, 30]
scores[0] = 15
print(scores[0] + scores[2]) # 45
Card 11: Linear Search
found = False
for item in bag:
    if item == "Gold":
        found = True
print(found)

Module 4: Data (Cards 14-15)

Card 14: Password Gen
# User Gen Challenge
first = input("First: ")
last = input("Last: ")
year = input("Year: ")
# 3 chars first, 3 chars last, year
pw = first[0:3] + last[0:3] + year
print(pw)
Card 15: File Write
name = input("Player: ")
score = input("Score: ")
# Append mode 'a'
file = open("scores.txt", "a")
file.write(name + "," + score + "\n")
file.close()

Module 5: Algorithms (Cards 16-18)

Card 16: Bubble Sort
# Swap Logic
if nums[i] > nums[i+1]:
    temp = nums[i]
    nums[i] = nums[i+1]
    nums[i+1] = temp
Card 17: 2D Grid
# Iterate Row then Col
for r in range(0, 3):
    for c in range(0, 3):
        print(grid[r][c])
Card 18: Validation
choice = int(input("Choice: "))
while choice < 1 or choice > 3:
    print("Invalid")
    choice = int(input("Choice: "))
print("Valid choice")

Module 6: SQL (Card 19)

Gold Challenge
SELECT name, score 
FROM users 
WHERE score > 100 
ORDER BY score
Silver Challenge
SELECT * 
FROM users 
WHERE role = 'Admin'

Module 7: Exam Mastery

Level 1: The Basics

Q1 Input
pin = input("Enter PIN: ")
Q2 Casting
age = int(input("Enter age: "))
Q5 Branching
if grade >= 50:
    print("Pass")
else:
    print("Fail")
Q10 Function
result = double(5)

Level 2: Algorithms

Ticket Function
if tickets > 5:
    price = tickets * 50
else:
    price = tickets * 60
Validation Loop
while age < 0 or age > 100:
    age = int(input("Age: "))
Linear Search
if f == "Nemo":
    print("Found it!")

Level 3: Expert

Ticket Sales
if tickets >= wanted:
    tickets = tickets - wanted
    print("Booked")
else:
    print("Not enough")
Voting System
if vote == "A": countA = countA + 1
elif vote == "B": countB = countB + 1
elif vote == "C": countC = countC + 1
Charging Time
hours = total_mins // 60
minutes = total_mins % 60