Tally marks are a form of numeral system used for counting. They are most useful in counting or tallying ongoing results, such as the score in a game or sport, as no intermediate results need to be erased or discarded.
For this challenge you will write a Python script that:
- Asks the user to enter a number,
- Converts the user input to an integer,
- Translates this number into tally marks,
- Displays the tally marks on screen.
Note that, as we will be using a text-based output, we will use the following text to represent the tally marks:
1 | 2 | 3 | 4 | 5 | 6 | 7 | … |
| | || | ||| | |||| | ||||- | ||||- | | ||||- || | … |
DIV & MOD
In Python, the // operator and the % operator can be used to calculate the quotient (a.k.a. DIV) and the remainder (a.k.a. MOD) of a division. For instance:
- Quotient: 14 DIV 5 = 14 // 5 = 2
- Remainder: 14 MOD 5 = 14 % 5 = 4
In other words: 14 = 5 * 2 + 4
We will use these operators to find out how many blocks of 5 tallies we need to print and how many tallies are remaining.
Tally Marks Counter – Solved
Your Task
Use a similar approach to:
- Ask the user to type a number of hours and convert this into days and hours knowing that there are 24 hours in a day. So for instance: 54 hours should be displayed as 2 days and 6 hours.
- Ask the user to type a number of days and convert this into years and days assuming that there are 365 days in a year. So for instance: 892 days should be displayed as 2 years and 162 days.
- Ask the user to type a number of seconds and convert this into hours, minutes and seconds knowing that there are 60 minutes in an hour and 60 seconds in a minute. So for instance: 8500 seconds should be displayed as 2 hours and 21 minutes and 40 seconds.
Solution...
The solution for this challenge is available to full members!Find out how to become a member:
➤ Members' Area