Skip to main content

← back to the guide

O-Level Computing (7155) Programming in Python quiz: variables, data types, selection, loops, lists, strings, functions quiz

15questions. Pick an answer and you'll see why right away.

  1. Which programming language is used in the lab-based Paper 2 of O-Level Computing 7155?

  2. What data type does Python's input() function always return?

  3. Which line correctly reads a whole number from the user so it can be used in arithmetic?

  4. Which of these is the bool data type?

  5. A program sets mark = 60. The first branch runs if mark is at least 75 and prints A; the elif runs if mark is at least 50 and prints B; otherwise it prints C. What is printed?

  6. Which operator tests whether two values are equal in Python?

  7. When is a for loop most appropriate?

  8. What is the main risk of a while loop?

  9. What value does total hold after this code? total = 0; for n in range(1, 4): total = total + n

  10. What is the index of the first item in a Python list?

  11. Given word = "CODE", what does word[0:2] return?

  12. Which method adds an item to the end of a Python list?

  13. What does len(scores) return if scores = [70, 85, 60, 90]?

  14. Why are functions useful in a program?

  15. What does this function return? def add(a, b): return a + b -- called as add(3, 4)