sh_07_买苹果增强版

 

sh_07_买苹果增强版

 

 1 # 1. 输入苹果的单价
 2 price_str = input("苹果的单价:")
 3 
 4 # 2. 输入苹果的重量
 5 weight_str = input("苹果的重量:")
 6 
 7 # 3. 计算支付的总金额
 8 # 注意:两个字符串变量之间是不能直接用乘法的
 9 # money = price_str * weight_str
10 # 1> 将价格转换成小数
11 price = float(price_str)
12 
13 # 2> 将重量转换成小数
14 weight = float(weight_str)
15 
16 # 3> 用两个小数来计算最终的金额
17 money = price * weight
18 
19 print(money)

 

posted @ 2019-09-05 11:58  俊豪郎  阅读(158)  评论(0编辑  收藏  举报