Skip to content

Course home

Algorithms

Algorithms

EasyMediumHard
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
Question 45

Alister owns a small community bookshop.

This program analyzes the daily visitor counts over a 4-day period.

The only inputs from the data file to the program are: 145, 280, 75, and 195.

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 visitors = 0
2 low = 500
3 high = 0
4 line = ""
5
6 file = open("VisitorData.txt", "r")
7 for line in file:
8     visitors = int(line)
9     if visitors < low:
10        low = visitors
11    if visitors > high:
12        high = visitors
13 print(low, high)
14 file.close()
visitorslowhighDisplay
[6]
Markscheme

Algorithms Questions

  1. GCSE
  2. /Computer Science
  3. /Algorithms

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.

Question bank