有人可以幫助我修復我的代碼嗎,我是 python 新手并學習基礎知識,但是我不知道為什么我不能讓“稅”部分列印一個值?即使按照教程一步一步完成。
完整腳本:
################### Item Descriptions ###################
lovely_loveseat_description = "Lovely Loveseat. Tufted polyester blend on wood. 32 inches high x 40 inches wide x 30 inches deep. Red or white."
lovely_loveseat_price = 254.00
stylish_settee_description = "Stylish Settee. Faux leather on birch. 29.50 inches high x 54.75 inches wide x 28 inches deep. Black."
stylish_settee_description = 180.50
luxurious_lamp_description = "Luxurious Lamp. Glass and iron. 36 inches tall. Brown with cream shade."
luxurious_lamp_price = 52.15
################### Total Formulas ###################
sales_tax = int(.884)
customer_one_itemization = "Lovely Loveseat. Tufted polyester blend on wood. 32 inches high x 40 inches wide x 30 inches deep. Red or white."
customer_one_total = " "
customer_one_total = str(lovely_loveseat_price)
customer_one_tax = customer_one_total * sales_tax
################### Prints ###################
print("Customer One Items")
print(customer_one_itemization)
print("Customer One Total")
print(customer_one_total)
print("Customer tax Total")
print(customer_one_tax)
我在輸出中得到以下內容:
Customer One Items
Lovely Loveseat. Tufted polyester blend on wood. 32 inches high x 40 inches wide x 30 inches deep. Red or white.
Customer One Total
254.0
Customer tax Total
(THIS SHOULD PRINT THE TAX TOTAL)
uj5u.com熱心網友回復:
這應該有效:
################### Item Descriptions ###################
lovely_loveseat_description = "Lovely Loveseat. Tufted polyester blend on wood. 32 inches high x 40 inches wide x 30 inches deep. Red or white."
lovely_loveseat_price = 254.00
stylish_settee_description = "Stylish Settee. Faux leather on birch. 29.50 inches high x 54.75 inches wide x 28 inches deep. Black."
stylish_settee_description = 180.50
luxurious_lamp_description = "Luxurious Lamp. Glass and iron. 36 inches tall. Brown with cream shade."
luxurious_lamp_price = 52.15
################### Total Formulas ###################
sales_tax = .088
customer_one_itemization = "Lovely Loveseat. Tufted polyester blend on wood. 32 inches high x 40 inches wide x 30 inches deep. Red or white."
customer_one_total = lovely_loveseat_price
customer_one_tax = customer_one_total * sales_tax
################### Prints ###################
print("Customer One Items")
print(customer_one_itemization)
print("Customer One Total")
print(customer_one_total)
print("Customer tax Total")
print(customer_one_tax)
輸出:
Customer One Items
Lovely Loveseat. Tufted polyester blend on wood. 32 inches high x 40 inches wide x 30 inches deep. Red or white.
Customer One Total
254.0
Customer tax Total
22.352
您的代碼有幾個我必須修復的錯誤:
customer_one_total您通過將其設定為等于進行初始化""lovely_loveseat_price被添加customer_one_total為strsales_tax不應設定int(.884)為僅為零的值。根據您的評論,您希望它是.088
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/457131.html
標籤:Python python-3.x 变量
上一篇:如何在vb.net中按類控制標簽
