indentation is used
python instead of
Q:8. If numbers=[1, 2, 3, 4, 5), then how
to get the largest value of this list?
1. high(numbers)
2.. max(numbers)
3. large(numbers)
4. sum(numbers)
Must
Answers
Answered by
3
To get the highest value of the list [1, 2, 3, 4, 5] assigned to the variable 'numbers', option (2) max(numbers) would be the answer.
max is a function used to return the highest value in the argument. Its opposite would be min, which returns the lowest element in the argument.
high and large aren't functions/methods in Python. sum however, is a function, that returns the sum of the elements. sum(numbers) would return 15 as 1 + 2 + 3 + 4 + 5 = 15.
Other related list functions include:
- append() - used to add a single element towards the end of a list.
- extend() - used to add multiple elements in the form of a list towards the end of a list.
- sort() - sorts the list in ascending/descending [sort(reverse = True)] order.
- clear() - clears the list/empties the list.
- index() - returns the index position of the element specified.
- insert() - used to insert an element at the specified index position.
Similar questions