QuizLander
← All public quizzes

Python — Basics: Syntax, Types & Variables

by Jude · 23/05/2026 · 114 views · 0 shares

Get started with Python: variables, primitives, operators, type conversion, syntax. 20 questions.
20
Questions
🇬🇧 English
Language
Easy
Difficulty
Start the quiz (as a guest or with an account)
Share as image

Questions in this quiz

  1. 1. What does this print?
    x = 7
    y = 2
    print(x // y, x % y)
    1. 3 1
    2. 3.5 1
    3. 3 0
    4. 4 -1
  2. 2. Which is an invalid Python identifier?
    1. _var
    2. var1
    3. 1var
    4. var_1
  3. 3. What does type(3 / 2) return in Python 3?
    1. <class 'int'>
    2. <class 'float'>
    3. <class 'complex'>
    4. <class 'number'>
  4. 4. What is printed?
    a = "3"
    b = 4
    print(a * b)
    1. 12
    2. 7
    3. 3333
    4. TypeError
  5. 5. Which literal has type bool?
    1. "True"
    2. 1
    3. True
    4. [True]
  6. 6. What does bool(0) or bool('') return?
    1. True
    2. False
    3. None
    4. TypeError
  7. 7. Which symbol starts a single-line comment?
    1. //
    2. #
    3. --
    4. /*
  8. 8. What does this print?
    print(2 ** 3 ** 2)
    1. 64
    2. 512
    3. 12
    4. SyntaxError
  9. 9. How do you convert "42" to int?
    1. str(42)
    2. int("42")
    3. float("42")
    4. eval("42.0")
  10. 10. What does len("café") return in Python 3?
    1. 3
    2. 4
    3. 5
    4. TypeError
  11. 11. What is the value?
    x = 0.1 + 0.2
    print(x == 0.3)
    1. True
    2. False
    3. Rounding error raised
    4. None
  12. 12. What does this print?
    a = b = [1, 2]
    a += [3]
    print(b)
    1. [1, 2]
    2. [1, 2, 3]
    3. [3]
    4. Error
  13. 13. What does this print in CPython?
    x = 256; y = 256
    a = 257; b = 257
    print(x is y, a is b)
    1. True True
    2. False False
    3. True False
    4. False True
  14. 14. What does the walrus do here?
    if (n := len(data)) > 10:
        ...
    1. Syntax error
    2. Assigns n = len(data) and uses it in the test
    3. Compares n to len(data)
    4. Defines n as global
  15. 15. What is s?
    s = f"{42:08.3f}"
    print(s)
    1. " 42.000"
    2. "0042.000"
    3. "42.00000"
    4. "00042.000"
  16. 16. Which statement about type annotations in CPython is true?
    1. They are enforced at runtime
    2. They are advisory and not enforced at runtime by CPython (apart from __annotations__)
    3. They cost a lot of memory
    4. They replace isinstance
  17. 17. What does this print?
    print("ab" * 3 + "-" + str(3 * 'ab'))
    1. ababab-ababab
    2. ababab-3ab
    3. ababab-(ab)(ab)(ab)
    4. TypeError
  18. 18. What does this print?
    print("-".join(str(i) for i in range(4)))
    1. 0123
    2. 0-1-2-3
    3. [0,1,2,3]
    4. 0,1,2,3
  19. 19. What does x, *rest, y = [1, 2, 3, 4, 5] bind?
    1. x=1, rest=[2, 3, 4], y=5
    2. x=1, rest=2, y=[3, 4, 5]
    3. x=[1, 2], rest=[3], y=[4, 5]
    4. SyntaxError
  20. 20. What does this print in Python 3.10+?
    def kind(x):
        match x:
            case 0:                return "zero"
            case int() if x > 0:  return "pos"
            case int():            return "neg"
            case _:                return "other"
    print(kind(-3), kind(0), kind(2.5))
    1. neg zero other
    2. neg zero pos
    3. other zero other
    4. SyntaxError
Answer the questions and see my score

Comments

Sign in to comment.

Loading…