Python Forum

Full Version: Arithmetic exercice with python
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello Guys,

I have an arithmetic exercice and I am stuck.

"Your program should read the number of students that can hold a room, then the number of students. Finally, it must display the number of rooms to reserve to hold all the students"

Example
entries :
5
29
output :
6

Here is my code : (nbEleveSalle will receive 5 and nbEleve will receive 29)
nbEleveSalle = int(input())
nbEleve = int(input())
résultat = (nbEleve//nbEleveSalle)+1
print(résultat)
The online plateform we use to validate our exercice, tells me this is not correct. Anyone have an idea please ? Thanks a lot
Please post all code, output and errors (in it's entirety) between their respective tags. Refer to BBCode help topic on how. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.

Please, You need to start following the forum rules. You have been previously notified
Hello, sorry, I edited my code. The output only says your programm give 7 instead of 6.
You do have a problem. What if you enter 5 and 30? The correct answer would be 6, and your program gives 7.
Instead of adding 1, you should only add 1 if the they are not evenly divisible. Use the modulo operator as your test.
Thank you Jefsummers. You're right. It's working now.