How Many Pizzas?
Time for a small project! In this checkpoint, you'll write a whole program on your own, using what you've learned in the first two lessons: variables, arithmetic, f-strings and conditions.
The exercises here are a bit different from the ones so far. The instructions say what the program should print, not how to write it. There are many correct ways, so pick the one that makes sense to you. If you get stuck, look back at the lesson where you learned what you need.
The project. You're having a party and ordering pizza for your friends. Over three exercises, your program will work out how many pizzas to order, what they cost, and whether the pizzeria takes orders right now. Each exercise continues where the previous one ended: the editor starts with a finished program from the previous step, which may look different from yours. That's fine.
The data. The variables at the top of the program hold what you know about the party: how many guests are coming, how many slices each of them eats, and how many slices one pizza has. In a real app, the user would type these in. Here, the program gets them from the variables, and your code should work with the variables, not with their numbers copied into it: when you change a variable, the program should still print the right result. To check that, each exercise also runs your program with other values, and it has to get those right too.
The task. The pizzeria sells only whole pizzas, so you have to order enough of them for all the slices, even if some are left over. 12 guests who eat 3 slices each need 36 slices. 4 pizzas have only 32 slices, which isn't enough, so you order 5, and 4 slices are left over. The program prints:
Slices: 36
Pizzas: 5
Left over: 4 slicesA tip: remember // and % from the first lesson. One tells you how many whole pizzas the slices fill, the other whether some slices are left that need one more pizza.
Watch out for a party whose slices fill the pizzas exactly. With guests = 8, the 24 slices fill 3 pizzas, and no slice is left over.
Instructions
Print how many slices the party needs and how many pizzas to order, as in the example.
Below that, print how many slices will be left over.
Start programming for free
1/3