# 输入苹果单价
price_str = input("苹果的单价:")
# 输入苹果的重量
weight_str = input("苹果的重量:")
# 转换
price = float(price_str)
weight = float(weight_str)
# 总金额
money = price * weight
print(money)
第一次敲Python的代码,实现了用户输入可以进行操作。
# 输入苹果单价
price_str = input("苹果的单价:")
# 输入苹果的重量
weight_str = input("苹果的重量:")
# 转换
price = float(price_str)
weight = float(weight_str)
# 总金额
money = price * weight
print(money)
第一次敲Python的代码,实现了用户输入可以进行操作。