Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help!! Please
#5
There are two central problems:
  1. The conditional to check delivery option is repeated twice. If the user selects either option, both conditionals are true.
  2. The nesting is incorrect. The second check of shipping option is in the else clause of the if statement and the second check of pounds is not under the else clause.

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)
Reply


Messages In This Thread
Help!! Please - by leokraz - Jan-28-2019, 05:15 AM
RE: Help!! Please - by buran - Jan-28-2019, 08:08 AM
RE: Help!! Please - by metulburr - Jan-28-2019, 01:19 PM
RE: Help!! Please - by leokraz - Jan-28-2019, 09:10 PM
RE: Help!! Please - by stullis - Jan-29-2019, 01:01 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020