jeudi 1 juillet 2021

why am I getting Python syntax error in if statement? [closed]

Python gives me an error on line 33 saying : File "main.py", line 33 if scoreValue > maximum : ^ SyntaxError: invalid syntax I'm trying to do the following code enter image description here

enter image description here

and this my code

def getChoice():
    print("-" * 44)
    print("1. Read scores")
    print("2. Convert scores to a letter grade and display it")
    print("3. Show statistics (minimum, maximum, and average)")
    print("4. Exit")
    print("-" * 44)
    choice = input("Choose from the above menu: ")
    
    if choice == "1" :
      readScores()
    elif choice == "2" :
      showLetterGrade()
    elif choice == "3" :
      showStatistics()
    elif choice == "4" :  
      exit()
    else :
      getChoice() 

def readScores() :
  numberOfScores = float(int(input("Enter the number of score: ")))
  minimum = 100
  maximum = 0
  scoreSum = 0
  for i in range (1,numberOfScores + 1) :
    scoreValue = float(input("Insert the score[0-100]: ")
    if scoreValue > maximum:
      maximum = scoreValue
    if scoreValue < minimum :
      minimum = scoreValue
    scoreSum = scoreSum + scoreValue
    scoreAverage = scoreSum / numberOfScores
  getChoice()

def showLetterGrade() :
    if scoreAverage > 90 :
        letterGrade = "A"
    elif scoreAverage > 80 :
        letterGrade = "B"
    elif scoreAverage > 70 :
        letterGrade = "C"
    elif scoreAverage > 60 :
        letterGrade = "D"
    else :
        letterGrade = "F"
                         
    print("The letter grade is:  " + letterGrade)
    getChoice()

def showStatistics() :
    print("The average score is: " + "%.1f"%scoreAverage)
    print("The minimum score is: " + "%.1f"%minimum)
    print("The maximum score is: " + "%.1f"%maximum)
    getChoice()

def exit() :
    yesOrNo = input("Do you want to exit:")               
    if yesOrNo != "y" and yesOrNo != "Y" :
        getChoice()

so could someone please resolve my issue?

Aucun commentaire:

Enregistrer un commentaire