In a make task you use the skills you have learned to create a program from scratch. There is no starter code: you begin with an empty editor.
Write a program called Test Grader.
print
followed by an input() on the next line. Convert their answer to a whole
number and store it in a variable.That mark is too low.That mark is too high.fail. If the mark is less than 40 the test was
failed, so store Y in it. Otherwise the test was passed, so store N in it.
Use one if with an else for this, so that fail is always given one value
or the other.fail. If it is not equal to N, output
Retake required. Otherwise, output Well done, you passed. Use one if
with an else for this, so that exactly one of the two messages is always
output.Ask the question with its own print, exactly as written:
Enter a test mark between 1 and 100:
The question and the four messages are all part of the checked output, and are checked exactly as they are written here:
Enter a test mark between 1 and 100:
That mark is too low
That mark is too high
Retake required
Well done, you passed
Marks are whole numbers, so use int() on the input and never float().
The program carries on after a range message, so a mark of 0 gets both
That mark is too low and Retake required, and a mark of 101 gets both
That mark is too high and Well done, you passed. Nothing tells the program
to stop, and none of the checks after the range check knows that the mark was
out of range: as far as the fail check is concerned, 101 is not less than
40, so it counts as a pass, exactly like 75 does.
A mark that is inside the range and is a pass gets Well done, you passed.
Neither range message applies, and fail holds N, so the retake check is
false and its else branch runs instead. Selection with two outcomes always
runs exactly one of its branches, so every mark produces some output.
A mark just below the pass mark:
Input:
39
Output:
Enter a test mark between 1 and 100:
Retake required
A mark below the allowed range:
Input:
0
Output:
Enter a test mark between 1 and 100:
That mark is too low
Retake required
A comfortable pass:
Input:
75
Output:
Enter a test mark between 1 and 100:
Well done, you passed
75 is inside the allowed range, so neither range message applies, and it is a
pass, so the else branch of the retake check runs instead of the if.
A mark above the allowed range:
Input:
101
Output:
Enter a test mark between 1 and 100:
That mark is too high
Well done, you passed
101 triggers the too-high message, but the fail check only asks whether the
mark is less than 40, so 101 still counts as a pass and gets
Well done, you passed as well.
Make sure that you check for the following things:
:) at the end of every if line and every else line.else.==) in a condition that checks whether
two pieces of data are the same, and != to check that they are different. A
single = stores data in a variable.fail are the letters Y and N inside speech marks,
not variable names.40 is a pass, and a mark
of exactly 1 or exactly 100 is inside the allowed range.input, and the second closing bracket
that int(input()) needs.