Programming questions

By Interwoven Maths

Programming question collection

Review Programming questions for Computer Science, with correct answers shown and coverage across variables and operators; selection and iteration; procedures and functions.

Back to Programming practice Back to Computer Science

Question 1

What does variable scope determine?
  1. Where the variable can be accessed
  2. Which data type the variable stores
  3. Which value the variable currently holds
  4. How much memory the variable reserves

Question 2

What is defensive design mainly used for?
  1. Handling invalid input and unexpected use
  2. Reducing execution time for valid input
  3. Choosing meaningful names for identifiers
  4. Translating source code into machine code

Question 3

In Python, what does int(4.9) return?
  1. 4
  2. 5
  3. 4.9
  4. Error

Question 4

Which data structure follows First In, First Out (FIFO)?
  1. Queue
  2. Stack
  3. Array
  4. Dictionary

Question 5

Which data structure follows Last In, First Out (LIFO)?
  1. Stack
  2. Queue
  3. Tuple
  4. Hash table

Question 6

In Python file handling, what does mode 'a' do?
  1. Opens a file for appending
  2. Opens a file for reading
  3. Opens a file for writing and overwrites existing content
  4. Creates a read-only temporary copy

Question 7

Which three control structures are fundamental in structured programming?
  1. Sequence, selection and iteration
  2. Input, output and storage
  3. Sort, search and merge
  4. Syntax, semantics and style

Question 8

How does a function differ from a procedure?
  1. A function returns a value to its caller
  2. A procedure returns a value to its caller
  3. A function runs without being called
  4. A procedure receives parameters from its caller

Question 9

In Python, what does list_name.pop() do with no index given?
  1. Removes and returns the last item in the list
  2. Returns the first item without removing it
  3. Sorts the list in descending order
  4. Clears all items from the list

Question 10

Why should identifier names be meaningful?
  1. To make each variable's purpose clear
  2. To show the indentation level
  3. To validate input values
  4. To convert runtime errors into syntax errors

Question 11

Which data type stores whole numbers?
  1. Integer
  2. Real
  3. Boolean
  4. Character

Question 12

Which data type stores true/false?
  1. Boolean
  2. Integer
  3. String
  4. Character

Question 13

Which operator gives the remainder?
  1. MOD
  2. DIV
  3. /
  4. *

Question 14

Which Boolean operator is true only when both conditions are true?
  1. AND
  2. OR
  3. NOT
  4. XOR

Question 15

Which Boolean operator is true when at least one condition is true?
  1. OR
  2. AND
  3. NOT
  4. DIV

Question 16

What is the result of applying NOT to TRUE?
  1. FALSE
  2. TRUE
  3. 1
  4. NULL

Question 17

What is a one-dimensional array used for?
  1. Store multiple values under one identifier
  2. Store one value under one identifier
  3. Store multiple values under two indices
  4. Store multiple values in a permanent file

Question 18

What is a record used for?
  1. Store related fields about one item
  2. Store same-type items under indices
  3. Process items in first-in-first-out order
  4. Process items in last-in-first-out order

Question 19

What does a range check do in validation?
  1. It checks that data is within set limits
  2. It checks that data has the correct type
  3. It checks that required data is not blank
  4. It checks that data has the correct length

Question 20

What is a syntax error?
  1. Code that breaks language rules
  2. Code that runs but gives a wrong result
  3. Code that stops because an operation fails
  4. Input that falls outside validation rules

Question 21

What does type casting do?
  1. Converts a value to another data type
  2. Encrypts a value for storage
  3. Sorts values into order
  4. Deletes invalid values automatically

Question 22

What does string concatenation do?
  1. Joins strings together
  2. Splits a string into characters
  3. Converts text to binary
  4. Counts the length of a string

Question 23

What is validation?
  1. Checking that input data is sensible
  2. Checking entered data against the original source
  3. Correcting invalid data automatically
  4. Testing whether an algorithm is efficient

Question 24

What is verification?
  1. Checking entered data against its source
  2. Checking input against permitted limits
  3. Checking code against language rules
  4. Checking output against an expected result

Question 25

What is a logic error?
  1. Code runs but produces an incorrect result
  2. Code that cannot be parsed
  3. An error that stops a program while it runs
  4. Data outside a permitted input range

Question 26

Why use a local variable?
  1. It is available only within its subroutine
  2. It can be used throughout the whole program
  3. It keeps its value after the program closes
  4. It cannot be assigned a new value

Question 27

What is a two-dimensional array used for?
  1. Store values under row and column indices
  2. Store values under one index
  3. Store one value under one identifier
  4. Store related fields about one item

Question 28

What is boundary test data chosen to check?
  1. Values at the edges of allowed ranges
  2. Typical values well inside allowed ranges
  3. Values copied from the original source
  4. Values stored in a different data type

Question 29

What is iteration?
  1. Repeating a set of instructions
  2. Selecting a path using a condition
  3. Executing instructions in a fixed order
  4. Calling a named subroutine

Question 30

What is normal test data?
  1. Data that should be accepted by a program
  2. Data just outside an allowed boundary
  3. A missing required value
  4. Data chosen to test a boundary

About this topic

Review Programming questions for Computer Science, with correct answers shown and coverage across variables and operators; selection and iteration; procedures and functions.

This topic covers

Example question types