- 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)))

19th Nov 2018, 7:26 AM
Priyanshu Ghatiya
Priyanshu Ghatiya - avatar
7 ответов
+ 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
19th Nov 2018, 8:23 AM
Kishalaya Saha
Kishalaya Saha - avatar
+ 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
19th Nov 2018, 8:26 AM
KrOW
KrOW - avatar
+ 2
The output is 44. Did you try running it in the code playground?
19th Nov 2018, 7:29 AM
Kishalaya Saha
Kishalaya Saha - avatar
+ 2
i know that answer is 44 but please explain it.I want explanation
19th Nov 2018, 8:07 AM
Priyanshu Ghatiya
Priyanshu Ghatiya - avatar
0
answer is 44
10th Feb 2020, 8:14 PM
Disha Prajapati
Disha Prajapati - avatar
0
no it is not 44
24th Jul 2021, 5:50 AM
Judson Leo
Judson Leo - avatar
0
44 is the right answer
1st Jan 2023, 2:53 PM
Arpita Karmakar
Arpita Karmakar - avatar