机器学习之路的Python基础篇2

@theme    print格式化输出
@author   lz
@time      2018/11/25

apple_price=float(input(“请输入价格”))#因为input中输入的是系统默认为字符串
apple_number=float(input(“苹果的数量”))#因为input中输入的是系统默认为字符串
money=apple_number*apple_price;
#%.nf表示以浮点数形式输出其中n表示小数点后几位
print(“单价 %.2f 元一斤,购买了 %.2f 斤,花费 %.2f 元”%(apple_price,apple_number,money))

猜你喜欢

转载自blog.csdn.net/weixin_43247522/article/details/84498538