0
Why wouldn't the first list be 55,44,42
(nums [:2]),abs (-42)) would be part of the same list?
6 odpowiedzi
+ 3
It could be recommended to give a link to the lesson or code you are referring, but I think I know which lesson you are talking about.
+ 1
The quiz asked about the result of this code:
nums = [55, 44, 33, 22]
print(max(min(nums[:2]), abs(-42)))
It is just about solving those functions, from the innermost to the outermost.
print(max(min(nums[:2]), abs(-42)))
- - - - nums[:2] - -> [55, 44]
- - - - abs(-42) - -> 42
print(max(min([55, 44, 33]), 42))
- - - - min([55, 44]) - -> 44
print(max(44, 42))
- - - - max(44, 42) - -> 44
print(44)
+ 1
nums[:2] is a slice from [55, 44, 33, 22]
[:2] refers on taking the first 2 items from the list:
[55, 44]
It has nothing to do with abs(-42).
min(nums[:2]) and abs(-42) are only 2 independent arguments for function max.
0
Sorry. First time commenting on this app. That is the one though!
0
Okay I see. I was thinking it became a list in itself inside of the function. Thank you for clarifying that!