question

ElaE-4245 avatar image
0 Votes"
ElaE-4245 asked ·

Why is my code running twice?

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-webapps
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

ryanchill avatar image
0 Votes"
ryanchill answered ·

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

75927-image.png

Regards,
Ryan


image.png (246.4 KiB)
·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.