Dr. Harrison is monitoring the temperature variation of a cryogenic storage unit over a 4-hour period.
The temperature sensor logs hourly integer readings in degrees Celsius. The input values from the log file TempSensor.txt are: -18, 35, -52, and 12.
Complete the trace table showing the execution of the program with these four inputs.
You may not need to use all the rows in the table.
1 temp = 0
2 min_temp = 80
3 max_temp = -80
4 line = ""
5
6 file = open("TempSensor.txt", "r")
7 for line in file:
8 temp = int(line)
9 if temp < min_temp:
10 min_temp = temp
11 if temp > max_temp:
12 max_temp = temp
13 print(min_temp, max_temp)
14 file.close()
| temp | min_temp | max_temp | Display |
|---|---|---|---|
159 exam-style questions on Edexcel GCSE Computer Science Algorithms, covering Constructs for solving problems, Variables, constants and data structures, Arithmetic, relational and logical operators, Tracing algorithm output with trace tables, Types of error and correcting logic errors, Standard algorithms (sorts and searches), and Evaluating algorithm fitness and efficiency. Each one has a worked solution and a mark scheme showing where the marks go.