Another make task, and this time the answer is a remainder.
A bakery packs its cupcakes into boxes. Each box holds exactly 6 cupcakes. The bakery needs a program to tell them how many cupcakes will be left over after packing all the full boxes they can.
Write a program that:
print followed by
an input() that collects the answer, and converts the answer to a whole
number,%, and
stores it in a variable,The number of cupcakes in a box is always 6, so it is written into your program, not asked for.
Ask the question with its own print, exactly as written:
Enter the number of cupcakes baked:
The question is part of the checked output, so spelling, capital letters and
punctuation count. The tests also check your code: a program that does not use
the % operator to work out the cupcakes left over does not pass.
One line after the question, where LEFT_OVER is the number you calculated:
Cupcakes left over: LEFT_OVER
Input:
17
Output:
Enter the number of cupcakes baked:
Cupcakes left over: 5
Input:
24
Output:
Enter the number of cupcakes baked:
Cupcakes left over: 0
24 cupcakes fill exactly 4 boxes, so there is nothing left over. The program still says so, with a 0.
Make sure that you check for the following things:
int() before you calculate with it.%, which gives what is left over, and not //, which gives
the number of full boxes.print is wrapped in str().Cupcakes left over: .