0

min/max

can someone explain what the min and max functions do?

21st Jan 2021, 10:02 AM
Doggo
Doggo - avatar
13 RĂ©ponses
+ 5
suppose we have this array/list of numbers a = [3,2,4,5] print(min(a)) #output: 2 print(max(a)) #output: 5 min stands for minimum max stands for maximum The Python max() function is used to find the largest value in a list of values. The Python min() function is used to find the lowest value in a list. The list of values can contain either strings or numbers.
21st Jan 2021, 10:04 AM
minirkk
minirkk - avatar
+ 2
It changes positive values to negative Example=27 will change to -27 by using abs function and vice versa
21st Jan 2021, 10:11 AM
Atul [Inactive]
+ 2
abs stands for absolute which returns the absolute value of the given number. eg print(abs(-3)) #output: 3 print(abs(3)) #output: 3
21st Jan 2021, 10:11 AM
minirkk
minirkk - avatar
+ 2
AJ. (INACTIVE) The abs() will return a floating point or an integer depending upon the argument. AJ have a look at the code https://code.sololearn.com/cgrcTC33ox7u/?ref=app
21st Jan 2021, 11:39 AM
BroFar
BroFar - avatar
+ 2
min and max return minimum and maximum value from the list. eg: l = [52,68,46,53,20,43] print(min(l)) #o/p 20 Print (max(l) #o/p 68
21st Jan 2021, 8:42 PM
Surkhab Khan
Surkhab Khan - avatar
+ 2
min() returns the minimum value and max() returns the maximum value of any kind of list a=[5, 2,1,4,6,2,7] Print(min(a)) #output 1 Print(max(a)) #output 7
22nd Jan 2021, 8:10 AM
Dipayan Dasgupta
Dipayan Dasgupta - avatar
+ 1
RKK thanks for the answer, i understand now
21st Jan 2021, 10:07 AM
Doggo
Doggo - avatar
+ 1
RKK thanks for another answer
21st Jan 2021, 10:12 AM
Doggo
Doggo - avatar
+ 1
AJ. (INACTIVE) My pleasure
21st Jan 2021, 10:18 AM
Atul [Inactive]
+ 1
Min function returns the smallest value among two integers while max returns the largest out of two
22nd Jan 2021, 2:37 AM
Aditya Mishra
+ 1
min print the smallest or minimum number of a certain function while max print the highest, biggest and maximum number of a certain function.
22nd Jan 2021, 4:15 PM
Muhammad Abdulmalik
Muhammad Abdulmalik - avatar
0
RKK another question, what does the abs function do?
21st Jan 2021, 10:08 AM
Doggo
Doggo - avatar
0
Atul thanksss
21st Jan 2021, 10:11 AM
Doggo
Doggo - avatar