lundi 14 décembre 2020

Python not letting me print only once when getting the average marks

hi so im new to python basically im trying to get the average of the marks but it print 3 times is there any way to print the average in function and only once

student = {
"name" : "Ali",
"program" :"computer programming",
"marks1":38,
"marks2":39,
"marks3": 40
}

def average():
    mark1 =student["marks1"] 
    mark2 = student["marks2"]
    mark3 = student["marks3"]
    averagemarks = mark1+mark2+mark3
    averagemarks = averagemarks/3
    print(averagemarks)
    return averagemarks



def result():
    if(average()>=90):
        print("Excellent")
    elif(50 <= average() <= 89):
        print("very good")
    elif(average()<=49):
        print("fail")

result()

Aucun commentaire:

Enregistrer un commentaire