Sharing Pizza
Write a program that asks the user how many people are having pizza and how many slices the pizza is being cut into. The program should then calculate how many slices each person should get. The number of slices per person should then be displayed back to the user, rounded to 0 decimal places.
How many people are eating pizza? 3 How many slices is the pizza being cut into? 9 Each person will get 3.0 slices each.
get number of people eating from user get number of slices pizza is being cut into from user calculate number of slices per person = slices / people print "Each person will get" & slices per person, rounded as integer & "slices each."
people = int(input("How many people are eating pizza? "))
slices = int(input("How many slices is the pizza being cut into? "))
slices_per_person = slices / people
print("Each person will get", round(slices_per_person, 0), "slices each.")
# Ask how many people are eating and store it as people
people = int(input("How many people are eating pizza? "))
# Ask the user how many slices the pizza is being cut into and store it as slices
slices = int(input("How many slices is the pizza being cut into? "))
# Calculate how many slices each person will get
slices_per_person = slices / people
# Print out the number of slices each person will get, but also round it to 0 decimal places
print("Each person will get", round(slices_per_person, 0), "slices each.")
Extension
Extend your program and add a second pizza and ask how many slices that pizza is being cut into.
How many people are eating pizza? 3 How many slices is the first pizza being cut into? 6 How many slices the second pizza being cut into? 7 Each person will get 4.0 slices each.