Data acquisition

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

Data acquisition

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Which describes data acquisition?
A Capturing data from a source and bringing it into a solution in a usable form
B Deleting old data from a database to free up space
2. A student is building a school canteen app. Which is the better first step in data acquisition?
A Design the app's colour scheme
B Choose a suitable source, such as the canteen's sales records
3. Which choice of source fits this need: the current temperature at a weather station?
A A sensor or API that gives live readings
B A survey of students done last year
4. Which approach captures data more accurately?
A Reading values directly from a sensor or form field as they are produced
B Retyping the values from memory later
5. A survey form lets students type their year level as free text. What is the likely problem?
A The data will always be perfectly consistent
B Entries like 'Yr 11', 'eleven' and '11' will be inconsistent

Match the Pairs

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

Left columnRight column
1data = read_csv("sensor_log.csv") AThe data is stored straight away without being checked on arrival, so errors and missing values go into the solution.
2if reading >= 0 and reading <= 50 then BBrings data from a chosen file source into the solution so it can be used
3Choosing a source: the solution gets its weather data from an open data portal through an API CThe input is used without confirming it is a number. Typed input is text, so the data was not captured in a usable form.
4Capturing accurately: typed survey answers are entered twice and compared Dif entry1 = entry2 then accept(entry1)
5data <- read_file("survey.csv") store(data) EChecks the data on arrival to see if it is reasonable before accepting it
6age <- input() age <- age + 1 Fsource <- "https://data.example.gov.au/weather"

Definitions

data acquisition

Fill in the Blanks

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

1.
print "Enter the temperature" _____ temp
2.
line ← readLine(file) fields ← _____(line, ",")
3.
if temp < -10 __ temp > 50 then print "Reading rejected" end if
4.
if name _ "" then print "Missing value" end if
5.
repeat input score _____ score >= 0 and score <= 100

Spot the Error

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

Question 1
A f = open("temps.csv")
B lines = f.readlines()
C f.close
D print(len(lines))
Question 2
A data = []
B for line in open("a.csv")
C data.append(line.strip())
Question 3
A age = int(input("Age: "))
B if age < 0 and age > 120:
C print("Invalid age")
Question 4
A line = "Ava,7,Red"
B parts = line.split(",")
C year = int(parts[3])
D print(year)
Question 5
A import csv
B f = open("marks.csv", "w")
C reader = csv.reader(f)
D rows = list(reader)

Answer Key

Data acquisition
Section A: Quick Questions
Q1
A — Capturing data from a source and bringing it into a solution in a usable form
Q2
B — Choose a suitable source, such as the canteen's sales records
Q3
A — A sensor or API that gives live readings
Q4
A — Reading values directly from a sensor or form field as they are produced
Q5
B — Entries like 'Yr 11', 'eleven' and '11' will be inconsistent
Section B: Match the Pairs
Q1
data = read_csv("sensor_log.csv") → Brings data from a chosen file source into the solution so it can be used
Q2
if reading >= 0 and reading <= 50 then → Checks the data on arrival to see if it is reasonable before accepting it
Q3
Choosing a source: the solution gets its weather data from an open data portal through an API → source <- "https://data.example.gov.au/weather"
Q4
Capturing accurately: typed survey answers are entered twice and compared → if entry1 = entry2 then accept(entry1)
Q5
data <- read_file("survey.csv") store(data) → The data is stored straight away without being checked on arrival, so errors and missing values go into the solution.
Q6
age <- input() age <- age + 1 → The input is used without confirming it is a number. Typed input is text, so the data was not captured in a usable form.
Section C: Definitions
Q1
data acquisition — Capturing data from a source and bringing it into a solution in a usable form: choose the source, capture it accurately, then check it on arrival.
Section D: Fill in the Blanks
Q1
print "Enter the temperature" input temp
Q2
line ← readLine(file) fields ← split(line, ",")
Q3
if temp < -10 or temp > 50 then print "Reading rejected" end if
Q4
if name = "" then print "Missing value" end if
Q5
repeat input score until score >= 0 and score <= 100
Section E: Spot the Error
Q1
C — Without brackets, f.close only names the method and never calls it, so the file stays open. It should be f.close().
Q2
B — A for loop header must end with a colon. It should be for line in open("a.csv"):
Q3
B — No age can be below 0 and above 120 at the same time, so 'and' never catches bad data. The reasonableness check needs 'or'.
Q4
C — The line splits into 3 fields, indexes 0 to 2, so parts[3] is out of range. The year level is in parts[1].
Q5
B — Mode "w" opens the file for writing and wipes the existing data. To read the source data, open it normally or with "r".