考虑到圆形物体的直径和价格,我正在尝试计算其每平方的成本。
这是我得到的:
import math
def main():
print("This program calculates the cost per square inch of a circular object.")
diameter = eval(input("What is the diameter of the object? "))
price = eval(input("What is the price of the whole object? "))
cost_per_square = (math.pi * (diameter / 2)**2) / price
print("The cost per square inch is $", round(cost_per_square, 2), sep="")
main()
我不擅长数学,所以我想知道公式是否正确?