Tech With Galvan

πŸ§ͺ Final Challenge

1-2 hours β€’ Beginner β€’ Module 12

A timed challenge covering all 12 modules β€” 15 questions, from tokens to OOP.

πŸ§ͺ Final Challenge

The exam covering all twelve modules. 15 questions, no peeking at earlier lessons. Write your answers before checking the solutions β€” the gap between β€œI think I know” and β€œI typed it” is the entire course.

Section 1: Foundations (Modules 1–2)

Q1. Who created Python, and why the name?

Q2. Identify every token type in: score = score + 10

Q3. Which are legal identifiers: my-score, _temp, class, Class2, 7up?

Section 2: Variables & Operators (Modules 3–4)

Q4. What does this print?

x = "5"
y = 5
print(x == y, x + "!", y * 2)

Q5. What does this print?

n = 17
print(n % 5, n // 5, 2 ** 3)

Q6. One line each β€” check whether: a) word contains β€œpy” (case-insensitive) b) x is between 1 and 100 (inclusive)

Section 3: Data Structures (Module 5)

Q7. Given data = {"a": [1, 2], "b": [3]} β€” write the line that prints 3.

Q8. Remove all duplicates from [1, 3, 1, 2, 3, 1] in one line, preserving the ability to loop it.

Section 4: Control Flow & Functions (Modules 6–7)

Q9. Write fizzbuzz(n) β€” returns β€œFizz” (divisible by 3), β€œBuzz” (by 5), β€œFizzBuzz” (both), or the number as a string.

Q10. Fix this function so result holds 30:

def double(x):
    print(x * 2)

result = double(15)

Q11. What does this print?

def modify(lst):
    lst.append(99)

nums = [1, 2]
modify(nums)
print(nums)

Section 5: Errors, Files & OOP (Modules 8–9)

Q12. Write the except block that safely handles a user typing β€œabc” into int(input(...)).

Q13. Load scores.json if it exists (else []), append 95, save it back. Three to four lines.

Q14. What does this print?

class A:
    def greet(self):
        return "Hello from A"

class B(A):
    def greet(self):
        return "Hello from B"

x = B()
print(x.greet())

Section 6: Power Tools (Modules 10–11)

Q15. One comprehension each: a) Squares of odd numbers from 1 to 10 b) From names, a dict mapping each name to its length


Solutions

Q1. Guido van Rossum, 1989–1991 β€” named after Monty Python’s Flying Circus, not the snake.

Q2. score (identifier), = (operator), score (identifier), + (operator), 10 (literal).

Q3. _temp βœ…, Class2 βœ… Β· my-score ❌ (hyphen), class ❌ (keyword), 7up ❌ (starts with digit).

Q4.

False 20 55555

Wait β€” y * 2 is 5 * 2 = 10. Correct output: False 20 10. (The trap: "5" == 5 is False β€” different types.)

Q5. 2 3 8 β€” remainder, floor division, exponent.

Q6.

a) "py" in word.lower()
b) 1 <= x <= 100

Q7. print(data["b"][0]) β€” dict key, then list index.

Q8. list(set([1, 3, 1, 2, 3, 1])) β€” set removes duplicates (order not guaranteed; sort if needed).

Q9.

def fizzbuzz(n):
    if n % 15 == 0:
        return "FizzBuzz"
    if n % 3 == 0:
        return "Fizz"
    if n % 5 == 0:
        return "Buzz"
    return str(n)

Q10. print β†’ return:

def double(x):
    return x * 2

Q11. [1, 2, 99] β€” lists are mutable and passed by reference; the function modified the original. (Contrast with numbers/strings, which are copied by value.)

Q12.

try:
    n = int(input("Number: "))
except ValueError:
    print("That's not a number")

Q13.

import json, os
scores = json.load(open("scores.json")) if os.path.exists("scores.json") else []
scores.append(95)
json.dump(scores, open("scores.json", "w"), indent=2)

Q14. Hello from B β€” B overrides A’s method; Python uses the child’s version.

Q15.

a) [n ** 2 for n in range(1, 11) if n % 2 == 1]
b) {name: len(name) for name in names}

πŸ† Scoring yourself

  • 13–15 correct: You didn’t take a course β€” you became a Python programmer. The Streamlit course is your playground now.
  • 9–12: Strong. Revisit the modules behind your misses β€” they’re reference material now.
  • 5–8: Solid foundation; redo the practice sessions of your two weakest modules before the capstone.
  • Below 5: No shame β€” retake the modules in order. The course is free and forever.

Either way: seventy lessons ago, β€œwhat is Python” was a genuine question. Look at you now. 🐍