Remember: A variable forgets when the program stops, but a file keeps its rows. A program reads a file one row at a time, and a mistake in a row shows in the chart.
Read and answer
Read the story, then answer.
Bo's stepsEvery morning, Bo walks a loop around the school while Zoe counts the steps. Zoe types each day's number into a variable, but when the program stops, the variable is empty the next morning. Ms. Okoro says a variable forgets, but a file remembers, because a file is saved on the computer. Think of a file as a folder full of rows, where each row is one line of data, like Monday and one thousand steps. Ravi's program opens the file, reads a row and uses it, then reads and uses the next row until there are no more rows. At the end it closes the file. Soon the screen draws a bar chart of the whole week, but one bar is taller than the screen.
1
Which one keeps its data after the program stops?
📦A variable📁A file on the computer🧠A number held in memory
2
A program reads a file one at a time, from the top.
pagerowkey
3
A variable keeps its value after the program stops.
TrueFalse
4
Look at the rows. Which day would make a bar much taller than the others?
TuesdayFridayWednesday
5
Which day has fewer steps than Monday?
TuesdayThursdayFriday
6
If a row in the file has a mistake, the chart will show it.
TrueFalse
Match, order and fix
7
Join each word to what it is.
1a variable
2a file
3a row
4a bar
Adrawn from one row of the file
Bone line of data, like a day and its steps
Cforgets when the program stops
Dkeeps data after the program stops
8
Ravi's program draws the chart. Put its steps in order.
Open the file
Close the file
Use the row to draw a bar
Read a row
9
Wednesday's row says 10000 steps. What is the mix-up to fix?
The day is spelled wrongIt has an extra zero, and it should say 1000It should say 1200
10
Circle every one that keeps its data after the program stops.
A saved notebook of rowsA variableA file on the computerA number held in memory
11
At the end, the program the file so everything stays safe and tidy.
readsopenscloses
12
Write one row for your own notebook file: the day, and one number, like pages you read.
13
Draw a bar for each day of Bo's week, using the rows in the table.
Scan the code at the top to mark this sheet on screenTake a photo of your answers or type them. It is marked for you automatically, and your score is kept.
Answer key · Set A
Bo's week of steps
1A file on the computer A variable forgets when the program stops. A file is saved.
2row A file is a folder full of rows, and a program reads one row at a time.
3False A variable empties when the program stops. A file remembers.
4Wednesday Wednesday has 10000 steps, far more than the other days.
5Friday Friday has 900 steps and Monday has 1000, so Friday is fewer.
6True Each bar comes from one row, so an odd row makes an odd bar.
71-C, 2-D, 3-B, 4-A A variable forgets and a file remembers. Each row is one line, and each bar comes from one row.
81, 4, 3, 2 Open the file first, read and use the rows, and close it last.
9It has an extra zero, and it should say 1000 An extra zero made the number ten times too big. Fix the row and the bar looks normal.
10A saved notebook of rows, A file on the computer Saved things keep their data. A variable and a number in memory are gone when the program stops.
11closes Last, the program closes the file.
12Your own words: a grown-up reads it.
Mark each answer, count the right ones and write the score on the sheet.