Lesson 2.1 · Write it
Pass mark
A whole programPython or Java5 tests, 3 of them hidden
On a phone? Put the lines in order instead
Write a program that reads a mark (a whole number, 0 to 100) and prints a result.
- Always print
Mark:followed by the mark on the first line. - If the mark is 50 or more, print
Passon the next line. - Print nothing else. Spaces at the end of a line are ignored.
Your program is run several times. Only what it prints is checked.
In Python, use int to convert the typed line. In Java, use Integer.parseInt.
Running Java here comes later. You can put this answer's lines in order instead. You can still write your Java answer (it stays while this page is open) and compare it with our worked solution. Or try this exercise in Python.
Examples
Your program is run 5 times: the 2 examples below, and 3 hidden ones that check the rules above. Only what it prints is checked.
above 50: the mark then Pass (rules 1 and 2)
You type
- typed: 75
It prints
Mark: 75 Pass
below 50: only the mark (rule 1)
You type
- typed: 30
It prints
Mark: 30