- 1
What is the result of this code? nums = (55, 44, 33, 22) print(max(min(nums[:2]), abs(-42)))
What is the result of this code? nums = (55, 44, 33, 22) print(max(min(nums[:2]), abs(-42)))
7 odpowiedzi
+ 10
nums[:2] creates a new tuple from nums by obtaining the elements whose index is no bigger than 2. min() and max() functions return the minimum and the maximum of their arguments. Similarly, abs() is for absolute value. Putting things together,
max(min(nums[:2]), abs(-42))
= max(min((55, 44)), 42)
= max(44, 42)
= 44
+ 3
Try to resolve the expression:
max(min(nums[:2]), abs(-42)))
nums[:2] ==> [55,44] then
max(min([55,44]), 42))==>
max(44,42) ==> 44
+ 2
The output is 44.
Did you try running it in the code playground?
+ 2
i know that answer is 44 but please explain it.I want explanation
0
answer is 44
0
no it is not 44
0
44 is the right answer