Computer Science for IGCSE & O level - Programming (Section 10)

  • 1
    What is the primary function of a selection statement (like IF...THEN...ELSE)?
    Answer
    (C)
    To choose which code block to execute based on a condition.
  • 2
    What is the main advantage of using a CASE statement over a series of IF-ELSE statements?
    Answer
    (B)
    CASE statements are more readable when dealing with multiple conditions.
  • 3
    What is an advantage of using functions in a program?
    Answer
    (B)
    They allow code reusability.
  • 4
    Which of the following is NOT a common characteristic of an IDE?
    Answer
    (D)
    A web browser
  • 5
    What is the exponentiation operator in most programming languages (as per the examples)?
    Answer
    (C)
    ^
  • 6
    In the context of the table of counting operations, what is the purpose of the statement: `NumberOfSacks = NumberOfSacks + 1`?
    Answer
    (C)
    To increase the count of sacks by one.
  • 7
    What will be the output for the following pseudocode? `Total = 10 Total = Total + 5 Output Total`
    Answer
    (C)
    15
  • 8
    Which type of data would be used to store decimal values?
    Answer
    (B)
    REAL
  • 9
    What does the `FOR` loop facilitate in the pseudo-code examples?
    Answer
    (B)
    Iterates through a set of students.
  • 10
    What is a key benefit of writing modular code (using procedures and functions)?
    Answer
    (D)
    It reduces code duplication and improves reusability.
  • 11
    What is meant by a 'maintainable' program?
    Answer
    (B)
    A program that is easily understood, modified, and updated.
  • 12
    What is the key characteristic of a post-condition loop?
    Answer
    (B)
    The loop body is guaranteed to execute at least once.
  • 13
    What is a key benefit of using nested selection statements?
    Answer
    (B)
    It enables the implementation of more complex logic.
  • 14
    Which string method is used to find the number of characters in a string?
    Answer
    (B)
    Length
  • 15
    What is a compiler's main task?
    Answer
    (B)
    To translate source code into machine code.
  • 16
    Which of the following is used to store multiple data items in an array?
    Answer
    (D)
    Elements with the same data type
  • 17
    Within a FOR loop, what dictates the number of times the code inside the loop will execute?
    Answer
    (B)
    The condition specified by the start value, end value, and step.
  • 18
    What is the primary purpose of file handling in programming?
    Answer
    (B)
    To store data permanently.
  • 19
    In the provided pseudo-code, which construct is used to repeat a block of code a specific number of times?
    Answer
    (C)
    FOR loop
  • 20
    What is the term that is often used to define a code block?
    Answer
    (C)
    Function
  • 21
    What does the concept of "sequence" represent in programming?
    Answer
    (A)
    The order of steps in an algorithm
  • 22
    Which of the following is used to denote 'greater than or equal to' in many programming languages?
    Answer
    (C)
    >=
  • 23
    In what kind of loop is the condition checked *before* any of the loop's code is executed?
    Answer
    (B)
    Pre-condition loop
  • 24
    Which string handling method is used to convert a string to lowercase?
    Answer
    (C)
    Lowercase
  • 25
    In a program, what is an example of an output statement?
    Answer
    (B)
    print("Hello")
  • 26
    In a `FOR` loop, what is usually defined at the start?
    Answer
    (C)
    The initial value of a counter.
  • 27
    What does `myFile.close()` do in the Python example?
    Answer
    (C)
    Closes the file
  • 28
    In the `Worked Example`, which part of the code would be executed repeatedly for each student?
    Answer
    A
    C
  • 29
    Which method is typically used to change all characters in a string to lowercase?
    Answer
    (C)
    Lowercase
  • 30
    If we have two conditions, A and B, which logical operator returns TRUE only when *both* A and B are TRUE?
    Answer
    (B)
    AND
  • 31
    What is the purpose of the Step value in a FOR loop, such as `For number = 10 to 50 Step 5`?
    Answer
    (C)
    To determine the increment or decrement for each iteration.
  • 32
    When you open a file in 'r+' mode (read and write), what happens?
    Answer
    (B)
    The file is opened for reading and writing, starting from the beginning.
  • 33
    What would typically be required when defining a function?
    Answer
    A
    B
    C
  • 34
    Which of the following is a characteristic of a variable in a computer program?
    Answer
    (B)
    Its value can change during the execution of the program.
  • 35
    What is the role of comments in programming code?
    Answer
    (B)
    To provide information and explanations for human readers.
  • 36
    In the pseudocode, what is the primary purpose of the line: `TOTAL = 0`?
    Answer
    (C)
    To initialize the 'TOTAL' variable to zero.
  • 37
    What does the keyword `DECLARE` signify in the given code examples?
    Answer
    (A)
    A variable is being defined.
  • 38
    What is the range of valid index values in an array in most programming languages?
    Answer
    (C)
    From 0 to the number of elements in the array - 1.
  • 39
    What is the purpose of a 'FOR' loop when populating arrays?
    Answer
    (C)
    To iterate through the elements of the array and assign values.
  • 40
    In the context of programming, what does "TotalWeight = TotalWeight + Weight" represent?
    Answer
    (B)
    Adding the current value of TotalWeight and the value of Weight and assigning the result to TotalWeight.
  • 41
    What is the function of the 'Substring' method?
    Answer
    (B)
    To extract part of a string.
  • 42
    What statement in pseudocode can be used to get input from the user?
    Answer
    (C)
    INPUT
  • 43
    What is the primary function of the `RETURN` statement inside of a function?
    Answer
    (B)
    To specify the value to be returned.
  • 44
    What is the usual behavior of a CASE statement if there's no matching case and no ELSE (or default) clause?
    Answer
    (C)
    The program continues with the next statement after the CASE block.
  • 45
    Which operation is performed by the following in the given example: `Calculate Number1 + Number2 + Number3 + Number4 + Number5;`?
    Answer
    (C)
    Addition
  • 46
    What is the primary purpose of the programming language that the school has chosen to use?
    Answer
    (D)
    To create an algorithm.
  • 47
    In most programming languages, what typically signifies the end of a multi-line comment?
    Answer
    (B)
    */
  • 48
    What is the primary function of the 'try' and 'catch' blocks?
    Answer
    (B)
    To handle potential errors (exceptions) in a program.
  • 49
    If a variable is declared inside a function, what scope does it have?
    Answer
    (B)
    Local scope
  • 50
    What does the "Step 5" part of the `For` loop control in the given example: `For number to 10 to 50 Step 5`?
    Answer
    (C)
    The increment value for each iteration.