getMinMaxScore function that returns the maximum and minimum values

Asked 2 years ago, Updated 2 years ago, 49 views

mus, fre, ger, phy = 95, 97, 45, 95
def getMinMaxScore(mus, fre, ger, phy):
    # ??
    return ??


MaxScore, MinScore = ( )
print(MaxScore, MinScore)

Run Results: 97, 45

Hello, guys. I found an example while studying functions, but I don't know how to solve it. With two return values, the execution result must be maximum and minimum values. At this time, what code should I put in the middle blank of the example above to make it look like the execution result? I beg you.

function python

2022-09-20 16:39

1 Answers

Variable names and argument names should be different.

Enter values for the mus, fre, ger, phy = 95, 97, 45, 95 # variables.
def getMinMaxScore (mus, fre, ger, phy): Take 4 # values and create a function with a return value.
    arr = [mus, fre, ger, phy] #It's annoying to compare every day, so I put it in the list. 
    Returns the maximum and minimum values using the return max(arr), min(arr) #max and min functions.
MaxScore, MinScore = getMinMaxScore (mus, fre, ger, phy) #Call the function as an argument and 변 put its return in the variable.
print(MaxScore, MinScore) #Output.

https://dojang.io/mod/page/view.php?id=2340


2022-09-20 16:39

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.