NewsImproved Interactive Lessons

Coding quiz

Python basics quiz

Eight short programs, each with a catch that trips up beginners. Work out what each one does, then see why.

  1. Question 1 of 8

    What does this program print?

    total = 0
    for n in range(1, 4):
        total = total + n
    print(total)
  2. Question 2 of 8

    What does this print?

    print("5" + "3")
  3. Question 3 of 8

    What does this print?

    print(7 // 2)
  4. Question 4 of 8

    The user types 12. What happens?

    age = input("Age? ")
    print(age + 1)
  5. Question 5 of 8

    What does this print?

    score = 40
    if score > 50:
        print("pass")
    print("done")
  6. Question 6 of 8

    What does this print?

    a = [1, 2]
    b = a
    b.append(3)
    print(a)
  7. Question 7 of 8

    What does this print?

    def double(x):
        print(x * 2)
    
    result = double(4)
    print(result)
  8. Question 8 of 8

    Which line checks whether x is 10?

Answer all 8 questions to see your score.

Python basics

Learn Python basics with your own tutor

It finds out what you already know, starts from there, and adapts to every answer. Your first 14 days are free, no card needed.