Question #74500

Write a program to help you feed your friends at a party by doing some math about square pizzas. Assume the grader defines a string inputStr for you, which is a decimal string meaning the side length L of the pizza in cm. The area of the pizza should be computed using the formula A = L*L. Then, assuming that each person needs to eat 100 cm2 of pizza, compute the number of people it can feed, rounded down to the nearest integer.

Expert's answer

1. Condition

Write a program to help you feed your friends at a party by doing some math about square pizzas. Assume the grader defines a string inputStr for you, which is a decimal string meaning the side length L of the pizza in cm. The area of the pizza should be computed using the formula A=LLA = L * L. Then, assuming that each person needs to eat 100 cm² of pizza, compute the number of people it can feed, rounded down to the nearest integer.

2. Solution


#enter the side length of the pizza
inputStr = input('Enter the side length of the pizza: ')
L = float(inputStr)
#calculate the pizza area
A = L*L
#compute the number of people pizza can feed
men = int(A/100)
#print out the number of people
print('Pizza can feed {} people'.format(men))


3. Screnshots of the program


Enter the side length of the pizza: 44.55
Pizza can feed 19 people
(program exited with code: 0)
Press return to continue


Answer provided by AssignmentExpert.com

LATEST TUTORIALS
APPROVED BY CLIENTS