Section 2A Summary Questions


Previous: 2A.09 - Files




Table 1 shows some the descriptions of five variables.

Table 1

Variable Data Type
Name  
Age  
Height (m)  
Phone number  
Employed?  

Complete Table 1 by adding the most appropriate data types. [5]

Tap/click to reveal Name:   String ✓   (names are collections of characters)
Age:   Integer ✓   (an age is usually represented as a whole number)
Height:   Float / Real ✓   (height in metres is usually a number with a decimal part)
Phone number:   String ✓   (phone numbers start with a 0, which would not be possible to represent as an integer)
Employed?:   Boolean ✓   (there are only two possible options here: true or false)



Which of the following can be changed as a program runs? [1]
  (a) The data type of a variable
  (b) The data type of a constant
  (c) The value of a variable
  (d) The value of a constant

Tap/click to reveal (c) The value of a variable ✓




Example 1 shows an algorithm written in pseudo-code.

Example 1
date ← "Thu, 1 Jan 1970"
OUTPUT LEN(date)
OUTPUT POSITION(date, 'a')
OUTPUT SUBSTRING(1, 7, date)

What is the output of Example 1? [3]

Tap/click to reveal 15
8
"hu, 1 J"



What is the output of NOT(59 OR 4 > 7) XOR (62 AND 8 < 1) ? [1]

Tap/click to reveal True



Give two reasons why a developer might want to include random number in their game. [2]

Tap/click to reveal Any two from:
- So that the game is different every time it is played ✓
- To simulate something that is random in real life ✓
- So that the game is unpredictable and challenging ✓
- [Other valid answers] ✓



Why would a 2D array be used to store the top three athletes in each event at a sports day? [1]

Tap/click to reveal Because the data is split by two categories: in each event there is a list of three athletes to store. ✓





Next: 2B.01 - Subroutines



© Rujul Nayak 2024-