Jan-28-2019, 05:15 AM
I've tried everything to write this program and I keep getting stuck and getting a syntax error. Can someone please tell me how they would tackle this problem? Thank you
![[Image: media%2Fd70%2Fd70806bb-1b47-4d5d-9b47-5f...kvKqAD.png]](https://media.cheggcdn.com/media%2Fd70%2Fd70806bb-1b47-4d5d-9b47-5f5d79e33e55%2FphpkvKqAD.png)
Help!! Please
|
Jan-28-2019, 05:15 AM
I've tried everything to write this program and I keep getting stuck and getting a syntax error. Can someone please tell me how they would tackle this problem? Thank you
![]()
Jan-28-2019, 08:08 AM
(Jan-28-2019, 05:15 AM)leokraz Wrote: I've tried everything to write this program and I keep getting stuck and getting a syntax error. Please, post your code in python tags, full traceback in error tags and ask questions about where you feel stuck. We are glad to help and guide you, but we are not going to write it for you. The last three sentences are pretty clear what needs to be done step by step
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link Create MCV example Debug small programs
Jan-28-2019, 01:19 PM
and use a meaningful subject title. It should summarize your main question
Recommended Tutorials:
Jan-28-2019, 09:10 PM
I apologize, after messing around a little with the code I got it to work the only problem now is that. My code is displaying both results. Standard Shipping and Express shipping at the same time. What am I doing wrong?
print ("Welcome to Delivery Express please enter S for Standard shipping or E for Express") shipping_option = input("Delivery Option:") shipping_option = shipping_option.upper() if shipping_option == "S" or "E": pounds = float(input("Please Enter Weight:")) if pounds <= 4: pounds = pounds * 1.05 print (pounds) elif pounds == 5 or pounds == 7 or pounds == 8: pounds = pounds * 0.95 print (pounds) elif pounds == 9 or pounds == 10 or pounds == 11 or pounds == 12 or pounds ==13 or pounds == 14 or pounds ==15: pounds = pounds * 0.85 print (pounds) elif pounds >= 16: pounds = pounds * 0.80 print (pounds) else: if shipping_option == "S" or "E": pounds = float(input("Please Enter Weight:")) if pounds <= 2: pounds = pounds * 3.25 print(pounds) elif pounds == 3 or pounds == 4 or pounds == 5: pounds = pounds * 2.95 print(pounds) elif pounds == 6 or pounds == 7 or pounds == 8 or pounds == 9 or pounds == 10: pounds = pounds * 2.75 print(pounds) elif pounds >= 11: pounds = pounds * 2.55 print(pounds)
Jan-29-2019, 01:01 PM
There are two central problems:
Also, the logic statements can be simplified. Instead of using "or" repeatedly, these can be written to check the pounds against the smallest and largest figures only. print ("Welcome to Delivery Express please enter S for Standard shipping or E for Express") shipping_option = input("Delivery Option:") shipping_option = shipping_option.upper() pounds = float(input("Please Enter Weight:")) if shipping_option == "S": if pounds <= 4: pounds *= 1.05 elif 5 <= pounds <= 8: pounds *= 0.95 elif 9 <= pounds <= 15: pounds *= 0.85 elif pounds >= 16: pounds *= 0.80 if shipping_option == "E": if pounds <= 2: pounds *= 3.25 elif 3 <= pounds <= 5: pounds *= 2.95 elif 6 <= pounds <= 10: pounds *= 2.75 elif pounds >= 11: pounds *= 2.55 print(pounds) |
|