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 is meant by variable scope?
  1. Where in a program a variable can be accessed
  2. How many bytes a variable stores
  3. The speed at which a variable changes
  4. The colour used to display a variable in an IDE

Question 2

What is defensive design in programming mainly for?
  1. Preventing or handling invalid input and unexpected use
  2. Making comments longer for readability
  3. Replacing all loops with recursion
  4. Ensuring code only runs on one device

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 only
  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

What is the difference between a procedure and a function?
  1. A function returns a value, while a procedure does not
  2. A procedure can use loops but a function cannot
  3. A function can only be written in pseudocode
  4. A procedure must be global but a function must be local

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 in code be meaningful?
  1. They make code easier to understand, test and maintain
  2. They reduce RAM usage significantly
  3. They automatically fix runtime errors
  4. They prevent all syntax mistakes

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 only
  3. Store network routes only
  4. Render 3D models only

Question 18

What is a record used for?
  1. Store related fields about one item
  2. Store only one character
  3. Encrypt all variables
  4. Sort lists automatically

Question 19

What does a range check do in validation?
  1. It checks that data is within set limits
  2. It checks spelling only
  3. It checks internet speed
  4. It checks file size only

Question 20

What is a syntax error?
  1. Code that breaks language rules
  2. Using slow hardware
  3. Choosing weak passwords
  4. Having unsorted input data

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

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