vendredi 23 octobre 2020

How to solve a basic Richter Scale problem using only If, elif statements

I am a complete beginner but working through an exercise to write a program that reads input and displays the descriptor.

For the below code:

  • Expected result is "Meteoric"
  • Current result is "Very Minor"

I am aware this is basic but gotta start somewhere.

What am I doing wrong?

mag = float(10)

# Determine the richter 

if mag < float(2.0):
    print("Micro")
elif mag >= float(2.0) < float(3.0):
    print("Very Minor")
elif mag >= float(3.0) < float(4.0):
    print("Minor")
elif mag >= float(4.0) < float(5.0):
    print("Light")
elif mag >= float(5.0) < float(6.0):
    print("Moderate")
elif mag >= float(6.0) < float(7.0):
    print("Strong")
elif mag >= float(7.0) < float(8.0):
    print("Major")
elif mag >= float(8.0) < float(10.0):
    print("Great")
elif mag >= float(10.0):
    print("Meteoric")
else:
    print("Error")

Aucun commentaire:

Enregistrer un commentaire