我正在为我的编程类做一个小代码,我们需要做一个程序来计算建造办公桌的成本。我需要帮助把抽屉数改成整数,而不是字符串!你知道吗
def Drawers():
print("How many drawers are there?")
DrawerAmount = input(int)
print("Okay, I accept that the total amount of drawers is " + DrawerAmount + ".")
return DrawerAmount
def Desk():
print("What type of wood is your desk?")
DeskType = input()
print("Alright, your desk is made of " + DeskType + ".")
return DeskType
def Calculation(DrawerAmount, DeskType):
if "m" in DeskType:
FinalPrice = DrawerAmount * 30 + 180
elif "o" in DeskType:
FinalPrice = DrawerAmount * 30 + 140
elif "p" in DeskType:
FinalPrice = DrawerAmount * 30 + 100
def Total():
print("The final price is " + FinalPrice )
DrawerAmount = Drawers()
DeskType = Desk()
Calculation(DrawerAmount, DeskType)
FinalPrice = Total()
试试这个:
相关问题 更多 >
编程相关推荐