Interactive practice · 10 questions on Python syntax, types, operators, data structures, and output prediction — easy to hard, with step-by-step explanations.
Press Check answer on each question to see whether you got it right — every check is timestamped and recorded in your Activity log below.
Each attempt is saved under its own name — load, rename, or delete them below. Difficulty / calculator tags are shared across all attempts. Numeric answers accept equivalent forms (e.g. 4/3 or 1.333).
The timer is stopped. Questions are hidden until you resume.
Easy How do you define a function in Python?
Answer: D — def f():
def keyword followed by a colon and an indented body.Easy What does print(2 ** 3) output?
Answer: A — 8
** is exponentiation: 2**3 = 2·2·2 = 8.Easy What does print(7 // 2) output?
prints
Answer: 3
// is floor division — it rounds down to the nearest whole number.7 // 2 = 3.Easy What does print(len("hello")) output?
prints
Answer: 5
len() returns the number of characters: h-e-l-l-o = 5.Medium What is the value of [x*x for x in range(4)]?
Answer: C — [0, 1, 4, 9]
range(4) gives 0,1,2,3.0, 1, 4, 9.Medium Which of these Python types are immutable? Select all that apply.
Answer: A, B
tuple and str cannot be changed after creation.list and dict are mutable.Medium What does print("ab" * 3) output?
Answer: D — ababab
"ab"*3 = "ababab".Medium What does print(type(5)) output?
Answer: D — <class 'int'>
type() returns the class object, printed as <class 'int'>.Hard What does this print?
d = {"a": 1, "b": 2}
print(d.get("c", 0))
prints
Answer: 0
dict.get(key, default) returns the default when the key is missing."c" isn't in the dict, so it returns 0.Hard What does print("python"[1:4]) output?
Answer: C — yth
[1:4] takes indices 1, 2, 3 (stop is excluded).p(0) y(1) t(2) h(3) o(4) n(5) ⇒ yth.