Which of the following best describes the String data type
Text and characters
Which of the following best describes the Integer data type
Whole numbers
Which of the following best describes the Real / Float data type
Fractional numbers
Which of the following best describes the Boolean data type
True or False values
How do you create an empty list in Python?
Using empty square brackets []
Which method adds an item to the end of a list?
append()
How do you remove the last item of a list?
Using the pop() method
How can you remove 'item2' from a list?
Using the remove() method
How do you sort a list in ascending order?
Using the sort() method
How do you access the first item of a list?
Using index 0
How do you create a new list by copying an existing list?
Using the list() function or the [:] syntax
How do you change the value of the first item in a list to 'new value'?
By assigning 'new value' to the first index
How can you add multiple items to a list at once?
Using the extend() method
What does the expression my_list[-1] return?
The last item of the list
Which term describes a data structure that holds items identified using two indices, so that it can be pictured as a table of rows and columns?
Two-dimensional array
What is meant by a one-dimensional array?
A data structure that holds related items under one name and uses a single index for each item
Which term describes a group of related data items that may have different data types, such as a student name, year group and test score stored together?
Record
What is meant by an index in a two-dimensional array?
A value that identifies the position of an item in the structure
What is a row in a two-dimensional array?
A set of items that are related and arranged horizontally, such as all the marks for one student
What is meant by iterating over a two-dimensional array?
Working through every item in the structure in turn
In a 2D array called grid, what does grid[2][4] refer to?
The item in row 2, column 4
A 2D array holds the marks for 3 students, with 5 marks each. How many items does it store?
15
Which task is best suited to storing data in a two-dimensional array?
The marks of several students across several tests
What is used to store one item in a record?
A field
Why can a record hold data of different types?
Each field in the record can have its own data type
A 2D list called students stores each student record in a row. What does students[1][2] access?
The third item of the second record
Which structure is used to process every item in a two-dimensional array?
One loop inside another loop
A two-dimensional array holds 6 marks for each of 5 students, with one student in each row. What does the third column hold?
The third mark for every student
A two-dimensional array holds 5 marks for each student, with one student in each row. A program adds together the items in the first row. What has it found?
The total of the marks for the first student
A two-dimensional list holds one student record in each row, with four fields in each record. Two loops, one inside the other, are used to print every field. What does the outer loop do?
It visits each row, one record at a time
A two-dimensional list called students holds one student record in each row. What does students[1] refer to?
The whole of the second row
What is the name for converting a value from one data type to another?
Casting
Which function converts a string to an integer?
int()
What does the function float do?
Converts a value to a real number with a decimal point
Why is int(input('Enter a number: ')) often used when reading a number from the user?
Input is a string and must be converted before it can be used in a calculation
Which function converts an integer or floating point number to a string?
str()
A variable called age holds a string. Which statement converts the value in age to an integer?
Age = int(age)
Which function converts a number such as 3.14 to a string?
str()
What is the result of the expression int('5') + 2?
7
What is the result of the expression str(3) + str(4)?
'34'
Which function converts a string to a real number that can hold decimal places?
float()
A user types 10 in response to an input statement. What data type is the value stored before any conversion?
String
A program stores the user's score as a string but needs to add points to it. Why is casting required?
The string must be converted to a number before it can be used in a calculation
A program asks the user for the price of an item and the user types 2.5. Which statement converts the input so it can be used in a calculation?
Price = float(input('Enter the price: '))
A program holds a score as an integer and needs to display it joined to the text 'Your score is '. What must the program do to the score?
Convert it to a string before joining it to the text
Which function converts a string such as 'True' to a Boolean value?
bool()
What is the value of the expression 'Total: ' + str(10 + 5)?