Phylyp has had a fun night out with his friends in a fancy restaurant. He just received the bill — a massive 89 golden coins – and now needs to calculate how much each of the five-member company needs to contribute. Can you help him find out how many coins each pays? Is the result an integer or a float?
1 2 3 4 | Output: Each person pays 17.8 The output after integer division is of type <type 'float'> |
Oh no! The waiter in the restaurant where Phylyp just ate understands no decimals! How can Phylyp repeat his calculation so that the results are integers? Perform a floor division and note the result. Is everyone now paying more or less than before (classic division)?
1 2 3 4 | Output: Each person pays 17 The output after integer floor division is of type <type 'int'> |
The waiter is now complaining that he received 4 coins less than the total bill! How did he arrive at this result? Can you calculate that with just a single operation in Python? (Hint: division remainder).
1 2 3 | Output: If each person pays 17 Then the remaining bill would be 4 |