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/05/09 15:58:53
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/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