MCQs / Computer Science / Unit 3: Programming Fundamentals
Unit 3: Programming Fundamentals MCQs — Computer Science (page 3) 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.
51. Which is NOT a reason why programming is important? Automating repetitive tasks Computers can work without any instructions Developing logical thinking Building solutions for many fields Answer: B) Computers can work without any instructions
Explanation: Computers need programs; they cannot work without instructions. SLO CS-11-C-01
Discuss this question
52. At the start, the turtle is at (0, 0) facing: east (0°) north (90°) south (270°) west (180°) Answer: A) east (0°)
Explanation: The default heading is 0°, pointing right (east). SLO CS-11-C-03
Discuss this question
53. What does this code print? python print(range(1, 10, 2)) 0 2 4 6 8 1 3 5 7 9 1 3 5 7 9 11 1 2 3 4 5 Answer: B) 1 3 5 7 9
Explanation: range(1, 10, 2) starts at 1, steps by 2 and stops before 10. SLO CS-11-C-02
Discuss this question
54. Lists are said to be mutable because: they cannot be changed they are sorted automatically they hold only numbers their items can be changed after creation Answer: D) their items can be changed after creation
Explanation: Items can be modified, added and removed. SLO CS-11-C-05
Discuss this question
55. Which command installs a third-party library? python get matplotlib download matplotlib import install matplotlib pip install matplotlib Answer: D) pip install matplotlib
Explanation: pip downloads and installs packages from PyPI. SLO CS-11-C-04
Discuss this question
56. What is printed? (count even numbers with a while loop) python nums = [3, 8, 10, 7, 4] i = even = 0 while i < len(nums): if nums[i] % 2 == 0: even += 1 i += 1 print(even) 2 4 3 5 Answer: C) 3
Explanation: 8, 10 and 4 are even. SLO CS-11-C-05
Discuss this question
57. The main benefit of moving duplicated code into a function is: functions cannot have errors global variables are removed code is written once and reused, making it shorter and easier to fix the program runs without RAM Answer: C) code is written once and reused, making it shorter and easier to fix
Explanation: DRY – Don't Repeat Yourself; one fix updates every use. SLO CS-11-C-06
Discuss this question
58. Choosing an SDLC model whose requirements can change in every sprint for a canteen pre-order app means choosing: V-model only Waterfall Big-bang Agile Answer: D) Agile
Explanation: Agile suits changing requirements and frequent feedback. SLO CS-11-C-01
Discuss this question
59. t.circle(50, 180) draws: a circle of diameter 50 a full circle of radius 180 180 circles a semicircle of radius 50 Answer: D) a semicircle of radius 50
Explanation: The second argument is the extent in degrees. SLO CS-11-C-03
Discuss this question
60. A program runs without any message but gives the wrong answer. This is a: syntax error runtime error logical error indentation error Answer: C) logical error
Explanation: Logical errors produce incorrect results with no error message. SLO CS-11-C-07
Discuss this question
61. What is printed? python import math print(math.sqrt(49)) 3.5 7.0 49 7 Answer: B) 7.0
Explanation: math.sqrt returns a float. SLO CS-11-C-04
Discuss this question
62. Using a misspelled variable name that was never assigned gives: NameError ZeroDivisionError ValueError no error Answer: A) NameError
Explanation: Python cannot find the name. SLO CS-11-C-07
Discuss this question
63. For a regular octagon the turning angle is: 60° 135° 40° 45° Answer: D) 45°
Explanation: 360°/8 = 45°. SLO CS-11-C-03
Discuss this question
64. 10 / 0 in Python causes: IndexError SyntaxError ZeroDivisionError NameError Answer: C) ZeroDivisionError
Explanation: Division by zero is a runtime error. SLO CS-11-C-07
Discuss this question
65. Evaluate (2 + 3 2 + 4 // 2 5 % 3 - 1) 2 30 20 24 22 Answer: D) 22
Explanation: 32 = 9; 4//25%3 = 10%3 = 1; (2 + 9 + 1 − 1) × 2 = 22. SLO CS-11-C-02
Discuss this question
66. What is printed? python print([i for i in range(1, 11) if i % 3 != 0]) 3 6 9 1 2 1 2 3 4 5 6 7 8 9 10 1 2 4 5 7 8 10 Answer: D) 1 2 4 5 7 8 10
Explanation: Multiples of 3 are skipped (continue), the rest are printed. SLO CS-11-C-02
Discuss this question
67. The website where Python third-party packages are published is: github.com/pip only pypi.org python.exe turtle.org Answer: B) pypi.org
Explanation: The Python Package Index (PyPI) hosts packages installed with pip. SLO CS-11-C-04
Discuss this question
68. The value passed to a function when it is called is called a(n): variable type argument return parameter Answer: B) argument
Explanation: Parameters appear in the definition; arguments are the actual values. SLO CS-11-C-06
Discuss this question
69. What is printed? python print(2 3 2) 64 512 81 9 Answer: B) 512
Explanation: is right-associative: 3 2 = 9, then 2 9 = 512. SLO CS-11-C-02
Discuss this question
70. Which function moves the turtle directly to the point (100, 50)? t.move(100, 50) t.goto(100, 50) t.forward(100, 50) t.setheading(100, 50) Answer: B) t.goto(100, 50)
Explanation: goto(x, y) moves to absolute coordinates. SLO CS-11-C-03
Discuss this question
71. What is printed? (meant to sum 1 to 5) python t, i = 0, 1 while i < 5: t += i i += 1 print(t) 5 14 15 10 Answer: D) 10
Explanation: i < 5 misses 5 – an off-by-one error; the fix is i <= 5. SLO CS-11-C-07
Discuss this question
72. Which library is commonly used to draw charts in Python? random math matplotlib turtle only Answer: C) matplotlib
Explanation: matplotlib.pyplot draws bar, line, pie charts and more. SLO CS-11-C-04
Discuss this question
73. What is printed? python x = 20.5 print(type(x)) <class 'str' 20.5 <class 'float' <class 'int' Answer: C) <class 'float'
Explanation: 20.5 is a decimal number, so its type is float. SLO CS-11-C-02
Discuss this question
74. Which operator checks equality in a condition? := === = == Answer: D) ==
Explanation: = assigns; == compares. SLO CS-11-C-02
Discuss this question
75. In a debugger, "step into" means: skip the rest of the program delete a breakpoint restart the computer enter the function called on the current line Answer: D) enter the function called on the current line
Explanation: Step into follows execution into a function call. SLO CS-11-C-07
Discuss this question
Previous Page 3 of 5 Next
Practise Unit 3: Programming Fundamentals MCQs
More Computer Science chapters