Thelarge“economy”sizeofapizzaisnotalwaysabetterbuythanthesmallersize.Pizzasizesaregivenasthediameterofthepizzaininches.However,thequantityofpizzaisdeterminedbytheareaof...
The large “economy” size of a pizza is not always a better
buy than the smaller size. Pizza sizes are given as the diameter of the pizza in inches.
However, the quantity of pizza is determined by the area of the pizza. Most people cannot easily estimate the difference in area between a ten-inch pizza and a twelve-inch pizza, and thus, cannot easily determine which size is the best buy.
Write a program that compares two sizes of pizza to determine which pizza is the better buy. You should ask the user for the diameter in inches and the price for each of the two pizzas. The output of your program will give the cost per square inch of each pizza and will tell which the better buy is.
Your program should make use of one function called unit_price. This function should have two parameters, the diameter of the pizza and its price. It should return the price per square inch of a pizza.
You should break your program down into several parts and make sure each part is working before you continue to the next part. Here is a division of the program into parts:
1. Get the input data for both the small and large pizzas from the user.
2. Compute the price per square inch for the small pizza (using the unit_price function).
3. Compute the price per square inch for the large pizza (using the unit_price function).
4. Determine which pizza is a better buy.
5. Print out the results.
就是比较大PIZZA饼和小PIZZA饼哪个实惠.
raw_input 大小PIZZA饼的价格和尺寸,
然后价格除以尺寸.
最后显示性价比高的是大PIZZA还是小PIZZA.
caozhipan1981,谢谢你提醒,管理员把骗子贴删了...
展开