Menu

Records

Card 1 of 20 0 got it 0 still learning
Question
TapClick or press space to see the answer
Answer
All 20 cards in this set
Which term describes a collection of related data items about one thing, stored together as a unit?
Record
What is the name for a single item of data within a record, such as a product ID or a price?
Field
Which term describes a collection of records that all have the same fields?
Table
What is meant by a record?
A collection of related fields that describe one item
What is meant by a two-dimensional array when it is used to store a table of records?
A list of lists in which the first index selects the record and the second index selects the field
In a table that holds records, what does each row and each column represent?
A row is a record and a column is a field
A table of records is stored in a 2D array called stock. What does len(stock[0]) return?
The number of fields in one record
A table is stored in a 2D array with columns 0 ProductID, 1 Name, 2 Price, 3 Stock. What is held in stock[1][2]?
The Price field of the second record
Every field of a record is stored as a string when the record is held in a Python list. Why is this?
An array can hold values of only one data type
This record is held in a list, where item[3] holds the stock. Which condition correctly tests whether the item is out of stock?
if int(item[3]) == 0
A program loops through every record in a table held in a 2D array and adds int(stock[i][3]) to a running total. What does the total represent?
The number of items held in stock
Which line correctly reduces the stock field of record i by one in a table held in a 2D array?
stock[i][3] = str(int(stock[i][3]) - 1)
A program searches a table of records for a matching product ID. Where should the message that no match was found be printed?
After the loop has finished, if no record matched
A shop stores its product data as records. Which is a reason for storing the data in this way?
The data about one product is kept together
A product record holds its ID as text, its price as a real number and its stock as a whole number. What does this show about the fields in a record?
They can hold different data types
This record is held in a list, where item[2] holds the price. Which condition correctly checks that the price is more than 1 pound?
if float(item[2]) > 1
A program asks for a product name in name and searches the table for it, where column 1 holds the name. Which condition correctly finds the matching record?
if stock[i][1] == name
A table holds the records P01 Pencil 0.45 120, P02 Ruler 0.99 40, P03 Eraser 0.30 0 and P04 Glue stick 1.25 15, with ProductID, Name, Price and Stock in that order. A loop prints stock[i][1] when int(stock[i][3]) == 0. What is printed?
Eraser
A program totals a numeric field into totalItems and then prints 'Items in stock: ' + str(totalItems). Why is str() used?
To turn the number into text that can be joined on
A table of records is held in a 2D array. Why must the program know which field is held in each column?
Each column is found by its index, not by its name