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/12/27 21:15:04
Python练习Ihavethreekindsoffruit:apple:$1.29/lbgrape:$2.29/lborange:$1.5/lb\x05\x05\x05\x05\x05\x05Whi

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