-1
print("""
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Welcome to the Garden Grass Calculator
Please Follow the instructions, and the size, and cost of your grass 
will be calculated!
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
""")

measurement = str(input("Have you measured in feet, inches, meters, or centimeters?: "))

if measurement == "inches":
    feet2 = float(input("Input your value in inches: "))
    result = (feet2//12)
    print ("Your result is" + (str(result) + (str("feet"))))

elif measurement == "centimeters":
    meters2 = float(input("Input your value in centimeters: "))
    result = (meters2//100)
    print ("Your result is " + (str(result) + (str("meters"))))

    
elif measurement == "meters" or "feet":
    print("Awesome, you know what youre doing!")

else:
    print("That is not a valid measurement: ")

shape = input("What is the Shape of your space?: ")

if "shape" == "square" or "rectangle":
    len = float(input("What is the length of the space?: "))
    width = float(input("What is the width of the space?: "))
    calc = (len*width)
    print(calc)

elif "shape" == "circle":
    rad = float(input("What is your area radius?: "))
    pi = ("3.1415")
    calc2 = (pi*(rad*rad))
    print (calc2)

else:
    print("Please input square, rectangle or circle:")

Im trying to write it so that when i input that my shape is a circle, i can skip straight to the circle elif statement, howerver when i run this, it comes up with an output as if i had written the input as a square. Im certain im just being stupid but its gone unresolved for hours. i only have ~5 hours python experience

1 Answers1

1

First, i think your if statement are not well written. Indeed, instead of : if x =='a' or 'b': you should do if x=='a' or x=='b:'

Secondly you are totally not using the shape variable, instead you are just checking if the string "shape" == "another string" Which will obvisouly returns false

So things you have to change :


shape = input("What is the Shape of your space?: ")

if shape == "square" or shape == "rectangle":
    len = float(input("What is the length of the space?: "))
    width = float(input("What is the width of the space?: "))
    calc = (len*width)
    print(calc)

elif shape == "circle":
    rad = float(input("What is your area radius?: "))
    pi = ("3.1415")
    calc2 = (pi*(rad*rad))
    print (calc2)

else:
    print("Please input square, rectangle or circle:")

Dharman
  • 30,962
  • 25
  • 85
  • 135
Skaddd
  • 153
  • 8