Why is my code running twice?

Ela E 1 Reputation point
2021-03-09T11:49:21.043+00:00

Hello! I am learning python and I recently got assigned a homework assignment. I wrote the code and got the results I wanted but the code is running twice.

Could you help me find the mistake please?

def main():    
    mt1=60
    mt2=50
    mt3=40
    av1 = drop_minimum(mt1,mt2,mt3)
    av2 = change_weights(mt1,mt2,mt3)
    result = compare_results(av1,av2)
    print('Result for drop_minimum is',av1)
    print('Result for change_weights is',av2)
    print('Final grade is',result)

def drop_minimum(grade1, grade2, grade3):
    if grade1<grade2 and grade1<grade3:
        av1=(grade2+grade3)/2
    elif grade2<grade1 and grade2<grade3:
        av1=(grade1+grade3)/2
    elif grade1==grade2 and grade2==grade3:
        av1=(grade1+grade2+grade3)
    else:
        av1=(grade1+grade2)/2
    return av1  

def change_weights(grade1, grade2, grade3):
    av2=(grade1*0.45)+(grade2*0.30)+(grade3*0.25)
    return av2

def compare_results(average1, average2):
    if average1>average2:
        best_avg= average1
    else:
        best_avg= average2 
    return best_avg

main()
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,694 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Ryan Hill 28,091 Reputation points Microsoft Employee
    2021-03-09T15:40:04.463+00:00

    When you say it's running twice, are you saying it's running twice on an Azure App Service @Ela E . I lifted you code and ran it locally and I only got a single set of results

    75927-image.png

    Regards,
    Ryan

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.