Python练习I have three kinds of fruit:apple:$1.29/lbgrape:$2.29/lborange:$1.5/lb\x05\x05\x05\x05\x05\x05Which one do you want?grapeOk,grape.How many pounds do you want?1.5 The cost is $3.44
来源:学生作业帮助网 编辑:作业帮 时间:2024/06/22 09:57:35
![Python练习I have three kinds of fruit:apple:$1.29/lbgrape:$2.29/lborange:$1.5/lb\x05\x05\x05\x05\x05\x05Which one do you want?grapeOk,grape.How many pounds do you want?1.5 The cost is $3.44](/uploads/image/z/14425414-70-4.jpg?t=Python%E7%BB%83%E4%B9%A0I+have+three+kinds+of+fruit%3Aapple%3A%241.29%2Flbgrape%3A%242.29%2Flborange%3A%241.5%2Flb%5Cx05%5Cx05%5Cx05%5Cx05%5Cx05%5Cx05Which+one+do+you+want%3FgrapeOk%2Cgrape.How+many+pounds+do+you+want%3F1.5+The+cost+is+%243.44)
Python练习I have three kinds of fruit:apple:$1.29/lbgrape:$2.29/lborange:$1.5/lb\x05\x05\x05\x05\x05\x05Which one do you want?grapeOk,grape.How many pounds do you want?1.5 The cost is $3.44
Python练习
I have three kinds of fruit:
apple:$1.29/lb
grape:$2.29/lb
orange:$1.5/lb
\x05\x05\x05\x05\x05\x05
Which one do you want?
grape
Ok,grape.How many pounds do you want?
1.5
The cost is $3.44
Python练习I have three kinds of fruit:apple:$1.29/lbgrape:$2.29/lborange:$1.5/lb\x05\x05\x05\x05\x05\x05Which one do you want?grapeOk,grape.How many pounds do you want?1.5 The cost is $3.44
print '''
I have three kinds of fruit:
apple: $1.29/lb
grape: $2.29/lb
orange: $1.5/lb
'''
name=raw_input('Which one do you want? \r\n')
weigt=raw_input('Ok, %s. How many pounds do you want? \r\n'%name)
if name=='apple':
price=1.29*float(weigt)
elif name=='grape':
price=2.29*float(weigt)
elif name=='orange':
price=1.5*float(weigt)
print 'The cost is $%.2f'%price