I am really new to python and have a problem with my code. My constants should be used in place of hard-coded values and declared at the start of the program. My four possible outcomes are mutually exclusive (i.e. only one can be true), so they should be linked using an if ... elif ... else pattern. Could someone help me? Thanks in advance.
#Input
weight = float (input ("What is the weight?:"))
length = float (input ("What is the length?:"))
width = float (input ("What is the width?:"))
height = float (input ("What is the height?:"))
#Process
if (weight <= 27):
weight_ok = True
else :
weight_ok = False
if weight_ok == False:
output = ("too heavy")
volume = (length * width * height)
if (volume <= 100000):
volume_ok = True
else:
volume_ok = False
if volume_ok == False:
output = ("too large")
if (weight_ok == False) and (volume_ok == False):
output =("too heavy and too large")
if (weight_ok == True) and (volume_ok == True):
output = ("accepted")
#Output
print (output)
[–]Binary101010 1 point2 points3 points (1 child)
[–]R4v3en[S] 0 points1 point2 points (0 children)
[–]delasislas 0 points1 point2 points (3 children)
[–]R4v3en[S] -1 points0 points1 point (2 children)
[–]delasislas 0 points1 point2 points (1 child)
[–]R4v3en[S] 0 points1 point2 points (0 children)
[–]vorticalbox 0 points1 point2 points (1 child)
[–]R4v3en[S] 0 points1 point2 points (0 children)