0
的,我需要做的是有功能的程序:功能:计算价格在Python-价格抽屉
接受抽屉的办公桌从键盘输入的号码。该函数返回main()函数的抽屉数量。
接受作为输入并返回木材的类型 - 'm'为桃花心木,'o'为橡木或'p'为松木。
是需要的参数有抽屉和木材种类的数量,并计算办公桌
显示所有的细节和最终价格的成本。
主要功能
我已经只有主要功能的成本。我只是不知道如何将它分成四个不同的功能。 这里是我的代码:
def main():
r = int(input("Enter number of drawers >> ")) #prompting user for input
extra = 30 * r
drawers = input("Enter type of wood - m, o, or p >> ")
if drawers == 'm':
ans = 180 + extra
if r == 1: #if statement
print("You have ordered a mahogany desk with 1 drawer")
else:
print("You have ordered a mahogany desk with",r,"drawers")
if drawers == 'p':#if statement
ans = 100 + extra
if r == 1:#if statement
print("You have ordered a pine desk with 1 drawer")
else:
print("You have ordered a pine desk with",r,"drawers")
if drawers == 'o':#if statement
ans = 140 + extra
if r == 1:#if statement
print("You have ordered a oak desk with 1 drawer")
else:
print("You have ordered a oak desk with",r,"drawers")
elif drawers == 'o':
ans = 140 + extra
elif drawers == 'p':
ans = 100 + extra
print("Total price is $"+str(ans)) #printing total price
main()