1. Which keyword is used to use a library in a Python program?
- include
- using
- require
- import
Answer: D) import
Explanation: e.g. import math, import turtle, import matplotlib.pyplot as plt. SLO CS-11-C-04 · Knowledge
MCQs / Computer Science / Unit 3: Programming Fundamentals
116 multiple-choice questions on Unit 3: Programming Fundamentals from Computer Science, each with the correct answer and, where available, a teacher's explanation. Read through them to revise the chapter, then practise the same questions one by one to test yourself.
Answer: D) import
Explanation: e.g. import math, import turtle, import matplotlib.pyplot as plt. SLO CS-11-C-04 · Knowledge
Answer: A) Computer English
Explanation: break exits the loop as soon as x is 'Physics', before printing it. SLO CS-11-C-02 · Application
Answer: D) Event handling
Explanation: The function draw runs when the event (a mouse click) happens. SLO CS-11-C-03 · Understanding
Answer: B) Each function can be called with test inputs and its return value checked
Explanation: Unit tests call a function and compare the result with the expected value. SLO CS-11-C-07 · Understanding
Answer: B) 16
Explanation: Negative indexes count from the end; -1 is the last item. SLO CS-11-C-05 · Application
Answer: C) screen.bgcolor('yellow')
Explanation: Screen methods control the window; turtle methods control the pen. SLO CS-11-C-03 · Knowledge
Answer: B) <class 'float'
Explanation: 20.5 has a decimal point, so it is a float. SLO CS-11-C-02 · Application
Answer: A) None
Explanation: Python functions return None by default. SLO CS-11-C-06 · Understanding
Answer: B) 16
Explanation: findmax(4, 9) = 9 and findmax(7, 2) = 7; 9 + 7 = 16. SLO CS-11-C-06 · Application
Answer: B) 7.0
Explanation: math.sqrt returns a float. SLO CS-11-C-04 · Application
Answer: D) for i in range(6): t.forward(80); t.left(60)
Explanation: The turtle turns by the exterior angle 360° div 6 = 60° at each corner. SLO CS-11-C-03 · Application
Answer: D) Logical error
Explanation: Logic errors are found by testing and dry runs, not by the interpreter. SLO CS-11-C-07 · Understanding
Answer: A) [1, 4, 9, 16]
Explanation: range(1, 5) gives 1–4; each square is appended. SLO CS-11-C-05 · Application
Answer: A) 10 5
Explanation: Inside the function, x is a new local variable; the global x stays 5. SLO CS-11-C-06 · Application
Answer: C) 1 3 5
Explanation: continue skips the rest of the loop body for even numbers. SLO CS-11-C-02 · Application
Answer: B) VS Code
Explanation: VS Code (offline) and replit.com (online) are IDEs named in the curriculum. SLO CS-11-C-02 · Knowledge
Answer: D) To avoid duplication and make the code easier to test and reuse
Explanation: Functions support decomposition and reuse. SLO CS-11-C-06 · Understanding
Answer: A) Any whole number from 1 to 6, including both
Explanation: Unlike range, randint(a, b) includes both ends — like a dice. SLO CS-11-C-04 · Knowledge
Answer: D) ZeroDivisionError
Explanation: Division by zero is a run-time error. SLO CS-11-C-07 · Knowledge
Answer: D) 1 4 7
Explanation: range(1, 10, 3) starts at 1, steps by 3 and stops before 10. SLO CS-11-C-02 · Application
Answer: A) penup() then forward()
Explanation: Lift the pen with penup(), move, then pendown() to draw again — useful for compound shapes. SLO CS-11-C-03 · Knowledge
Answer: D) Input → Process → Output
Explanation: Programs use the computer's components to take input, process it and produce output. SLO CS-11-C-01 · Knowledge
Answer: B)
Explanation: Python ignores everything after on a line. SLO CS-11-C-02 · Knowledge
Answer: D) Turns the turtle 90° anticlockwise
Explanation: left() and right() rotate the turtle; forward()/backward() move it. SLO CS-11-C-03 · Understanding
Answer: B) IndexError
Explanation: Indexes are 0, 1, 2 — index 3 is out of range. cities[-1] or cities[2] gives Lahore. SLO CS-11-C-05 · Application
Page 1 of 5 Next
Practise Unit 3: Programming Fundamentals MCQs