Generating sample test data

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Generating sample test data

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. You want to practise spreadsheet formulas but have no real data yet. What could you use?
A A sensor that has been switched off
B A data generator
2. Which statement describes data made by a data generator?
A It is real data collected from people
B It is random test data
3. When using a data generator, you choose the fields. What is a field?
A A column type such as Name, Age or Score
B The total number of rows in the file
4. You set a data generator to make 50 rows. What does this control?
A How many records are created
B How many columns are created
5. Which is the best way to use generated data in a spreadsheet?
A Export it as a file, then open or import it
B Retype each cell by hand from memory

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1Fields: Name, Age, Year AGenerated data is random test data, not real data. It must not be used as real survey results.
2Rows: 50 BFilename: test_data.csv
3Export the generated data so it can be opened and practised on in a spreadsheet CA row count of 0 makes no data, so there is nothing to practise with. Choose a number such as 50.
4Generated data is only test data, so the file name should show it is not real DExport as CSV
5Rows: 0 ETells the data generator to make 50 records of sample data
6Use test_data.csv as our real survey results FChooses the columns (fields) that each generated record will have

Definitions

data generator

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
=___________(1,100)
2.
=______(RANDBETWEEN(1,2),"Red","Blue")
3.
=ROUND(____()*100,1)
4.
Save as: sampledata.___
5.
=COUNTA(A2:A__)

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A rows == 50
B fields = ['Name', 'Age']
C data = make_data(fields, rows)
D export(data, 'test.csv')
Question 2
A from random import randint
B ages = []
C for i in range(30)
D a = randint(11, 14)
E ages.append(a)
Question 3
A fields: Name, Age, Score
B rows: 100
C export: CSV
D note: real student data
Question 4
A import random
B names = ['Ava', 'Liam', 'Mia']
C pick = random.choose(names)
D print(pick)
Question 5
A import csv
B f = open('test.csv', 'r')
C w = csv.writer(f)
D w.writerow(['Name', 'Age'])

Answer Key

Generating sample test data
Section A: Quick Questions
Q1
B — A data generator
Q2
B — It is random test data
Q3
A — A column type such as Name, Age or Score
Q4
A — How many records are created
Q5
A — Export it as a file, then open or import it
Section B: Match the Pairs
Q1
Fields: Name, Age, Year → Chooses the columns (fields) that each generated record will have
Q2
Rows: 50 → Tells the data generator to make 50 records of sample data
Q3
Export the generated data so it can be opened and practised on in a spreadsheet → Export as CSV
Q4
Generated data is only test data, so the file name should show it is not real → Filename: test_data.csv
Q5
Rows: 0 → A row count of 0 makes no data, so there is nothing to practise with. Choose a number such as 50.
Q6
Use test_data.csv as our real survey results → Generated data is random test data, not real data. It must not be used as real survey results.
Section C: Definitions
Q1
data generator — A tool that makes random sample data, with fields and rows you choose, to practise with when real data is not available. You can export it to a spreadsheet. It is test data, not real data.
Section D: Fill in the Blanks
Q1
=RANDBETWEEN(1,100)
Q2
=CHOOSE(RANDBETWEEN(1,2),"Red","Blue")
Q3
=ROUND(RAND()*100,1)
Q4
Save as: sampledata.csv
Q5
=COUNTA(A2:A21)
Section E: Spot the Error
Q1
A — A single = stores the row count in the variable. Two equals signs (==) compare values, so rows would never be set. It should be rows = 50.
Q2
C — A for loop line must end with a colon. Without it the generator will not run. It should be for i in range(30):
Q3
D — Generated data is made up, so it is test data, not real data. The note should say that it is test data, not real data.
Q4
C — The function that picks a random item from a list is random.choice(), not random.choose(). It should be pick = random.choice(names).
Q5
B — 'r' opens the file for reading only, so the generator cannot save data to it. To export, open it for writing with 'w'.