180 min read
Programming Practice Exam
A full practice exam in the same format as the unit examination: 20 multiple-choice questions, then three flowchart-and-Python questions — with a separate answer sheet.
About This Paper
This practice exam has the same format as the Programming with Python examination: Section I has 20 multiple-choice questions (2 marks each), and Section II has three questions where you draw a flowchart and then write the Python code (20 marks each). Time yourself: allow 3 hours, and work without notes.
Work on paper (or on your computer for practical tasks), just as you would in the real assignment. Show all your working. When you have finished, mark your work with the answer sheet.
Section I — Multiple Choice (20 × 2 marks)
1. Consider these sets of identifiers: (I) total_marks, mark2, 3rd_mark (II) _count, itemPrice, TAX_RATE (III) first name, last-name, age (IV) while, value1, sum_ (V) Price, price, PRICE. Which sets contain only valid Python identifiers?
- A) (II) only
- B) (II) and (V)
- C) (I), (II) and (V)
- D) (IV) and (V)
2. In a flowchart, which shape represents input or output?
- A) Diamond
- B) Rectangle
- C) Parallelogram
- D) Oval
3. What is pseudocode?
- A) A language that runs on any computer
- B) An algorithm written as structured, English-like steps
- C) Machine code
- D) A flowchart symbol
4. In structured programming, which control structure repeats a set of steps?
- A) Sequence
- B) Selection
- C) Iteration
- D) Modularity
5. Which is a benefit of modular programming?
- A) Modules can be tested separately and reused
- B) The whole program is one large block
- C) Testing is not needed
- D) It needs more global variables
6. What does WHILE … ENDWHILE do in pseudocode?
- A) Runs a block exactly once
- B) Repeats a block as long as a condition is true
- C) Chooses between two blocks
- D) Ends the program
7. A program stops while running with the message ZeroDivisionError: division by zero. What type of error is this?
- A) Syntax error
- B) Runtime error
- C) Logic error
- D) Compilation error
8. Which statement about logical values in C is TRUE?
- A) Only 1 is true
- B) −5 is treated as false
- C) 0 is false and any non-zero value is true
- D) Logical operators return 2 for true
9. In C, the values 'B', 7, 7.5, "B" are respectively:
- A) char, int, float, string
- B) string, int, double, char
- C) char, float, int, string
- D) string, int, float, string
10. In C, which operator cannot be used with float values?
- A)
+ - B)
* - C)
% - D)
/
11. Python shows NameError: name 'totl' is not defined. What is the most likely cause?
- A) A missing colon
- B) A misspelt variable name
- C) Wrong indentation
- D) Dividing by zero
12. What does the oval (terminator) show in a flowchart?
- A) Start or Stop
- B) Input or output
- C) A calculation
- D) A decision
Use Flowchart F for questions 13, 14 and 15.
Flowchart F
Read this flowchart as text
- Terminator: Start (then → OUTPUT "Enter a mark (0-100)")
- Input/output: OUTPUT "Enter a mark (0-100)" (then → INPUT mark)
- Input/output: INPUT mark (then → mark is 0 to 100?)
- Decision: mark is 0 to 100? (X → mark >= 40?; No → OUTPUT "Invalid mark")
- Input/output: OUTPUT "Invalid mark" (then → Stop)
- Decision: mark >= 40? (No → [blank Y]; Yes → [blank Z])
- Input/output: [blank Y] (then → Stop)
- Input/output: [blank Z] (then → Stop)
- Terminator: Stop
13. In Flowchart F below, what is the best label for blank X?
- A) No
- B) Yes
- C) Stop
- D) Invalid
14. In Flowchart F, what should blank Y be?
- A) OUTPUT "Pass"
- B) OUTPUT "Invalid mark"
- C) OUTPUT "Fail"
- D) INPUT mark
15. In Flowchart F, what should blank Z be?
- A) OUTPUT "Fail"
- B) OUTPUT "Pass"
- C) OUTPUT "Invalid mark"
- D) mark = 40
16. Which of these is a correct comment in Python?
- A)
// total - B)
# total - C)
<!-- total --> - D)
/* total */
17. Which keyword sends a value back from a Python function?
- A) print
- B) def
- C) return
- D) send
18. A function is defined as def greet(name): print("Hello", name). Which line correctly calls it?
- A)
greet - B)
def greet("Ravi") - C)
greet("Ravi") - D)
call greet
19. Which is a correct way to create a variable in Python?
- A)
int count = 0 - B)
count = 0 - C)
var count = 0 - D)
$count = 0
20. What does this print? for i in range(1, 8, 3): print(i, end=" ")
- A) 1 4 7
- B) 1 4 7 10
- C) 1 2 3
- D) 3 6
Section II — Flowcharts and Python (3 × 20 marks)
Question 1 (20 marks)
(a) Draw a flowchart that inputs a student's ID, name and monthly class fee. The student receives a 15% sibling discount. Calculate the discount and the amount to pay, and display both. (10 marks)
(b) Write the Python code for your flowchart. (10 marks)
Question 2 (20 marks) — A laundry offers these services (use a nested if):
| Laundry services | ||
|---|---|---|
(a) Draw a flowchart that inputs the service type and the quantity from the keyboard and calculates the total cost. If the service type is not 1, 2 or 3, display "Invalid service". (10 marks)
(b) Write the Python code for your flowchart. (10 marks)
Question 3 (20 marks)
(a) Draw a flowchart that prints all the multiples of 3 from 0 to 30 (0 and 30 included). (10 marks)
(b) Write the Python code for your flowchart. (10 marks)
More lessons in Python Programming · Next: Programming Practice Exam: Answer Sheet · Previous: Python Worksheet
