我在下面编写了程序。
不知何故,即使我只希望执行if distance == "..."
,程序也会执行if pickup_location = "no"
:命令。
我的程序中可能遗漏了一些基本的东西,这些东西使我来到这里,因为我无法修复它并希望寻求您的帮助。
提示我很好,所以我可以找出答案。
#This program calculates the final price, based on the base price of a car's production price
#21.07 Author: 382df7181fcd71a41cfe9b793032c029d139ecb557a4af40ca5de3a148bbbc0d (SHA256)
production_price = int(input("How much did it cost to produce the car?"))
#parameters to be set
sales_margin_percentage = 0.2
tax_rate = 0.23
license_rate = 0.12
dealers_cut = 0.05
delivery_fee_10_100 = 400
delivery_fee_100_250 = 1050
#calculations of extra fees
sales_margin = production_price * sales_margin_percentage
internal_sales_price = production_price+sales_margin
tax = internal_sales_price * tax_rate
license_fee = internal_sales_price * license_rate
pre_external_sales_price = internal_sales_price + tax + license_fee
dealer_prep = pre_external_sales_price * dealers_cut
final_price = pre_external_sales_price + dealer_prep
pickup_location = input("Do you want to collect the car at the dealer ship?")
if pickup_location == "yes":
print("Ok. Then the final price would be.", final_price, "We'll give you a call right away when we see the delivery truck from which point on you are free to"
"collect it at any point in time.")
elif pickup_location == "no":
distance = int(input("How far away do you live away from the dealership in kilometers?"))
if distance <= 10:
print("Nice. Tha:t will mean that you can profit of our free home delivery service and can receive "
"your car for the final price of", final_price, "dollars.")
elif distance > 10 and distance <= 100:
print("Awesome. You can buy and get your car delivered to the front door for the final price of", final_price + delivery_fee_10_100,
"Dollars.")
elif distance > 100 and distance >200:
print("Awesome. That means that you can buy and get the car delivered for the final price of", final_price + delivery_fee_100_250,
" to your front lawn.")
else:
print("I'm sorry. A home delivery is not possible for your location, however, you can pick it up at the dealer ship "
"for the final price of", final_price, "Dollars, should you still want to buy it.")
else:
print("What?")
答案 0 :(得分:0)
这是适用于python 3的工作程序
File "/home/asifkhan69/webapps/rmsapp/lib/python3.6/Django-2.0.7-py3.6.egg/django/forms/fields.py" in to_python 611.
from PIL import Image
Exception Type: ModuleNotFoundError at /admin/vv/institutes/add/
Exception Value: No module named 'PIL'
Request information:
USER: asifkhan
注意:由于#This program calculates the final price, based on the base price of a car's production price
#21.07 Author: 382df7181fcd71a41cfe9b793032c029d139ecb557a4af40ca5de3a148bbbc0d (SHA256)
#parameters to be set
sales_margin_percentage = 0.2
tax_rate = 0.23
license_rate = 0.12
dealers_cut = 0.05
delivery_fee_10_100 = 400
delivery_fee_100_250 = 1050
production_price = int(input("How much did it cost to produce the car?"))
#calculations of extra fees
sales_margin = production_price * sales_margin_percentage
internal_sales_price = production_price+sales_margin
tax = internal_sales_price * tax_rate
license_fee = internal_sales_price * license_rate
pre_external_sales_price = internal_sales_price + tax + license_fee
dealer_prep = pre_external_sales_price * dealers_cut
final_price = pre_external_sales_price + dealer_prep
pickup_location = str(input("Do you want to collect the car at the dealer ship?"))
if pickup_location == "yes":
print("Ok. Then the final price would be.",
final_price,
"We'll give you a call right away when we see the delivery truck from which point on you are free to"
"collect it at any point in time.")
elif pickup_location == "no":
distance = int(input("How far away do you live away from the dealership in kilometers?"))
if distance <= 10:
print("Nice. That will mean that you can profit of our free home delivery service and can receive "
"your car for the final price of", final_price, "dollars.")
elif 10 < distance <= 100:
print("Awesome. You can buy and get your car delivered to the front door for the final price of", final_price + delivery_fee_10_100,
"Dollars.")
elif 100 < distance <= 200:
print("Awesome. That means that you can buy and get the car delivered for the final price of", final_price + delivery_fee_100_250,
" to your front lawn.")
else:
print("I'm sorry. A home delivery is not possible for your location, however, you can pick it up at the dealer ship "
"for the final price of", final_price, "Dollars, should you still want to buy it.")
else:
print("What?")
是多余的,因此我确定了最终距离,我认为您的意思是distance > 100 and distance > 200
。您可能需要在最终的if else语句上修改参数。它们与打印的声明不符(例如<= 200
)。