# Program to demonstrate Nested If and Elif approach # Ian Ford - 2019-09-25 # function to show how nested ifs work def useNestIf(): print("Using Nested IFs") cont = "" # variable to allow multiple inputs while cont != "X": theScore = int(input("Exam score (X to finish): ")) if theScore > 80: print("Grade A") else: if theScore > 70: print("Grade B") else: if theScore > 60: print("Grade C") else: print("You failed") print() cont = input("Continue? (X to stop): ").upper() print() # end of useNestIF() function # function to show how elif work def useElseIf(): print("Using ELIF") cont = "" # variable to allow multiple inputs while cont != "X": theScore = int(input("Exam score (X to finish): ")) if theScore > 80: print("Grade A") elif theScore > 70: print("Grade B") elif theScore > 60: print("Grade C") else: print("You failed") print() cont = input("Continue? (X to stop): ").upper() print() # end of useElseIf() function # MAIN PROGRAM print("Exam score program using elif and Nested If") print() option = "" while option != "X": print("""Choose a method Enter 1 to use Nested Ifs Enter 2 to use ELIF Enter X to exit """) option = input("Enter your choice: ").upper() print() if option == "1": useNestIf() #call the function elif option == "2": useElseIf() #call the function #note: no else statement here