我一直在尝试制作一个类似收银机的代码,用户可以在其中输入产品名称、价格和数量。我有四种产品。在做了所有这些添加,我需要得到5%的GST,然后打印出包括GST在内的总金额。这就是到目前为止我可以得到的,而且我对python还不太熟悉,这就是为什么我不知道很多错误和其他关键字的原因。我得到了和ut,但当我乘法时,它说它不能乘以字符串和整数。我试着改变变量名,做了其他所有的事情,但没有给出总数。在name1 =raw_input('What Item do you have: ')
price1 = float(input('What is the price of your item: '))
quantity1 = float(input('How many are you buying: '))
name2 = raw_input('What Item do you have: ')
price2 = float(input('What is the price of your item: '))
quantity2 = float(input('How many are you buying: '))
name3 = raw_input('What Item do you have: ')
price3 = float(input('What is the price of your item: '))
quantity3 = float(input('How many are you buying: '))
name4= raw_input('What Item do you have: ')
price4 = float(input('What is the price of your item: '))
quantity4 = float(input('How many are you buying: '))
sum_total= (price1 * quantity1), (price2 * quantity2), (price3 * quantity3), (price4 * quantity4),
print(' %.2f ' % quantity1+quantity2+quantity3,' X ', name1+name2+name3,' @ %.2f ' %
price1+ price2+price3,' = %.2f ' % total)
divv = sum_total / 100
percent = divv * 0.05
gst = sum_total + percent
print('The suggested gst is %.2f '% percent )
print('That will be a total of: %.2f '% gst)