Novice · Formatting · 48 of 264
Percentage
Read a score and the maximum score, and print the score as a percentage with one decimal.
Input: score and maximum, whole numbers, one per line. Output: e.g. 87.5%
Examples
Input
35 40
Output
87.5%
Input
1 3
Output
33.3%
Input
50 50
Output
100.0%
One more test checks other inputs when you press Check.
Stuck? The idea behind formatting
An f-string puts values into text: f"{name} is {age}". Inside the braces, a format after a colon controls how the value looks.
:.2f gives two decimal places, :5 makes room for five characters, :>5 lines up to the right, :05 fills with zeros.
price = 3.5
print(f"Total: £{price:.2f}")
print(f"{7:03}") # 007Watch for: round() can drop a trailing zero (3.50 becomes 3.5); :.2f always shows two places.