买苹果增强版演练
# 1. 輸入蘋果的單價
price_str = input("蘋果的單價:")# 2. 輸入蘋果的重量
weight_str = input("蘋果的重量:")# 3. 計算支付的總金額
# 注意:兩個字符串變量之間是不能直接用乘法的
# money = price_str * weight_str
# 1> 將價格轉換成小數
price = float(price_str)# 2> 將重量轉換成小數
weight = float(weight_str)# 3> 用兩個小數來計算最終的金額
money = price * weightprint(money)
?
超強干貨來襲 云風專訪:近40年碼齡,通宵達旦的技術人生總結