0
min/max
can someone explain what the min and max functions do?
13 odpowiedzi
+ 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.
+ 2
It changes positive values to negative
Example=27 will change to -27 by using abs function and vice versa
+ 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
+ 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
+ 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
+ 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
+ 1
RKK thanks for the answer, i understand now
+ 1
RKK thanks for another answer
+ 1
AJ. (INACTIVE) My pleasure
+ 1
Min function returns the smallest value among two integers while max returns the largest out of two
+ 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.
0
RKK another question, what does the abs function do?
0
Atul thanksss