Level 1 — RecognitionIntroduction to Programming (Python)

Introduction to Programming (Python)

20 minutes30 marksprintable — key stays hidden on paper

Level: 1 — Recognition (MCQ + Matching + True/False with justification) Time Limit: 20 minutes Total Marks: 30


Section A — Multiple Choice (1 mark each) — 10 marks

Q1. What is the data type of the value returned by input() in Python?

  • (a) int
  • (b) float
  • (c) str
  • (d) depends on what the user types

Q2. What is the result of 17 // 5?

  • (a) 3.4
  • (b) 3
  • (c) 2
  • (d) 4

Q3. Which of the following is an invalid Python variable name?

  • (a) _count
  • (b) count2
  • (c) 2count
  • (d) Count

Q4. What does "ab" * 3 evaluate to?

  • (a) "ababab"
  • (b) "aaabbb"
  • (c) "ab3"
  • (d) TypeError

Q5. Given s = "python", what is s[-2]?

  • (a) "o"
  • (b) "n"
  • (c) "h"
  • (d) "t"

Q6. What is the value of 5 & 3 (bitwise AND)?

  • (a) 7
  • (b) 1
  • (c) 8
  • (d) 0

Q7. Which built-in function pairs elements from two lists into tuples?

  • (a) map()
  • (b) zip()
  • (c) filter()
  • (d) enumerate()

Q8. What does len({1, 2, 2, 3, 3, 3}) return?

  • (a) 6
  • (b) 3
  • (c) 2
  • (d) 1

Q9. A recursive function that lacks a base case will most likely cause:

  • (a) a SyntaxError
  • (b) a RecursionError (stack overflow)
  • (c) an infinite loop that returns None
  • (d) nothing — it runs fine

Q10. What is the output of bool("") ?

  • (a) True
  • (b) False
  • (c) None
  • (d) ""

Section B — Matching (1 mark each) — 6 marks

Q11. Match each operator/function in Column X to its correct description in Column Y. Write the pairs (e.g. 1→c).

Column X Column Y
1. % a. Repetition of a string
2. ** b. Remainder after division
3. * (on strings) c. Exponentiation (power)
4. != d. Logical negation
5. not e. Not-equal comparison
6. // f. Floor division

Section C — True / False with Justification (2 marks each: 1 for T/F, 1 for reason) — 14 marks

Q12. Tuples are mutable, so you can change their elements after creation. (True/False + justify)

Q13. The expression 3 < 5 and 10 > 20 evaluates to False. (True/False + justify)

Q14. In Python, type(3.0) returns int. (True/False + justify)

Q15. A list comprehension [x*x for x in range(4)] produces [0, 1, 4, 9]. (True/False + justify)

Q16. The break statement skips the current iteration and continues the loop, while continue exits the loop entirely. (True/False + justify)

Q17. In short-circuit evaluation, False and print("hi") will still print "hi". (True/False + justify)

Q18. Dictionary keys must be unique; assigning a value to an existing key overwrites the old value. (True/False + justify)

Answer keyMark scheme & solutions

Section A — MCQ (1 mark each)

Q1 — (c) str. input() always returns a string regardless of what is typed; conversion (int(), float()) is needed for numeric use. (1)

Q2 — (b) 3. Floor division // divides and rounds toward negative infinity: 17/5=3.4317/5 = 3.4 \Rightarrow 3. (1)

Q3 — (c) 2count. Variable names cannot begin with a digit. Underscores and letters are valid starters; names are case-sensitive. (1)

Q4 — (a) "ababab". String * int repeats the string, here 3 copies of "ab". (1)

Q5 — (a) "o". Negative indexing counts from the end: s[-1]="n", s[-2]="o". (1)

Q6 — (b) 1. 5=10125 = 101_2, 3=01123 = 011_2; AND = 0012=1001_2 = 1. (1)

Q7 — (b) zip(). zip() aggregates corresponding elements of iterables into tuples. (1)

Q8 — (b) 3. A set stores only unique elements: {1,2,3}. (1)

Q9 — (b) RecursionError. Without a base case, recursion never stops and exceeds the recursion depth limit → stack overflow (RecursionError). (1)

Q10 — (b) False. An empty string is falsy; bool("") is False. (1)

Section B — Matching (1 mark each)

Q11:

  • 1→b (% remainder)
  • 2→c (** exponentiation)
  • 3→a (string * repetition)
  • 4→e (!= not-equal)
  • 5→d (not negation)
  • 6→f (// floor division)

(1 mark each correct pair, 6 total)

Section C — True/False with Justification (2 marks each)

Q12 — False (1). Tuples are immutable; their elements cannot be changed after creation. Attempting item assignment raises TypeError. (reason 1)

Q13 — True (1). 3 < 5 is True, 10 > 20 is False; True and FalseFalse. (reason 1)

Q14 — False (1). type(3.0) returns float because the decimal point makes it a floating-point literal; only 3 (no decimal) is int. (reason 1)

Q15 — True (1). range(4) yields 0,1,2,3; squaring gives 0,1,4,9. (reason 1)

Q16 — False (1). The roles are reversed: break exits the loop entirely; continue skips to the next iteration. (reason 1)

Q17 — False (1). With and, if the left operand is False, the right is never evaluated (short-circuit), so print("hi") does not run; the expression is False. (reason 1)

Q18 — True (1). Dict keys are unique; re-assigning d[k]=v for an existing key replaces the previous value rather than adding a duplicate. (reason 1)

[
  {"claim":"17 // 5 equals 3", "code":"result = (17 // 5 == 3)"},
  {"claim":"5 & 3 equals 1", "code":"result = (5 & 3 == 1)"},
  {"claim":"list comp squares of range(4) is [0,1,4,9]", "code":"result = ([x*x for x in range(4)] == [0,1,4,9])"},
  {"claim":"3 < 5 and 10 > 20 is False", "code":"result = ((3 < 5 and 10 > 20) == False)"},
  {"claim":"len of set with duplicates is 3", "code":"result = (len({1,2,2,3,3,3}) == 3)"}
]