76. A variable created inside a function is:
- constant
- global
- static for the whole program
- local
Answer: D) local
Explanation: It exists only inside that function. SLO CS-11-C-06
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) local
Explanation: It exists only inside that function. SLO CS-11-C-06
Answer: C) str
Explanation: The input is text; convert it with int() or float(). SLO CS-11-C-02
Answer: D) 212.0
Explanation: 100 × 9/5 + 32 = 212.0. SLO CS-11-C-06
Answer: A) 0
Explanation: Indexes start at 0. SLO CS-11-C-05
Answer: B) 7.0
Explanation: Division happens first: 4 + 3.0 = 7.0 – a logical error. SLO CS-11-C-07
Answer: C) break
Explanation: break leaves the loop; continue skips to the next repetition. SLO CS-11-C-02
Answer: C) 4
Explanation: i takes 0, 2, 4, 6 – four repetitions. SLO CS-11-C-02
Answer: A) compound shape
Explanation: Compound shapes combine simple shapes, often using penup/goto. SLO CS-11-C-03
Answer: A) len()
Explanation: len() comes with Python; the others are user-defined. SLO CS-11-C-06
Answer: D) abstraction
Explanation: Abstraction hides implementation details. SLO CS-11-C-04
Answer: A) global
Explanation: The global statement allows assignment to a global variable. SLO CS-11-C-06
Answer: D) Interpreter
Explanation: Python is interpreted line by line and stops at the first error. SLO CS-11-C-01
Answer: C) return
Explanation: return ends the function and gives a value back. SLO CS-11-C-06
Answer: A) ValueError
Explanation: The string cannot be converted to an integer. SLO CS-11-C-07
Answer: D) dry run
Explanation: A dry run (desk check) is done by hand. SLO CS-11-C-07
Answer: A) 3
Explanation: // is floor division: it gives the whole-number part. SLO CS-11-C-02
Answer: A) Input
Explanation: input() takes data from the user. SLO CS-11-C-01
Answer: A) 5 4
Explanation: ceil rounds up, floor rounds down. SLO CS-11-C-04
Answer: B) any whole number from 1 to 6
Explanation: randint includes both end points. SLO CS-11-C-04
Answer: B) Lahore
Explanation: Index −1 is the last item. SLO CS-11-C-05
Answer: D) beginfill() and endfill()
Explanation: Lines drawn between beginfill() and endfill() are filled. SLO CS-11-C-03
Answer: B) processing
Explanation: The CPU executes instructions to process data. SLO CS-11-C-01
Answer: B) 2
Explanation: % gives the remainder: 17 = 5 × 3 + 2. SLO CS-11-C-02
Answer: B) syntax error
Explanation: Syntax errors are found before the program runs. SLO CS-11-C-07
Answer: A) def
Explanation: def name(parameters): defines a function. SLO CS-11-C-06
Practise Unit 3: Programming Fundamentals MCQs