Answered

oe’s Pizza Palace needs a program to calculate the number of slices a pizza of any size can be divided into. The program should perform the following steps: Ask the user for the diameter of the pizza in inches. Calculate the number of slices that may be taken from a pizza of that size. Display a message telling the number of slices. To calculate the number of slices that may be taken from the pizza, you must know the following facts: Each slice should have an area of 14.125 square inches.To calculate the number of slices, simply divide the area of the pizza by 14.125.The area of the pizza is calculated with this formula: Area = "pi r squared" where pi is approximately 3.14159 and r is the radius (half the the diameter). To calculate the number of slices that may be taken from the pizza, you must know the following facts: Each slice should have an area of 14.125 square inches. To calculate the number of slices, simply divide the area of the pizza by 14.125. The area of the pizza is calculated with this formula: Area = "pi r squared" where pi is approximately 3.14159 and r is the radius (half the the diameter).

Answer :

Answer:

# the user is prompted to enter diameter in inch

diameter = int(input("Enter the diameter of the pizza you want (in inch): "))

# the value of PI is saved as a constant

PI = 3.14159

# the area of the pizza is calculated using pi r squared

# the value of r is diameter divide by 2

area = PI * ((diameter / 2) ** 2)

# the value of area is displayed

print(area)

# the number of slice is calculated as area divide by 14.125

# integer division is use to get number of slice

number_of_slice = area // 14.125

# the number of slice is displayed to the user

print("Your number of pizza slice is: ", number_of_slice)

Step-by-step explanation:

The code is written in python and well commented. A sample image of output when code is executed is attached

${teks-lihat-gambar} ibnahmadbello

Other Questions