The relational operator used would probably be <=
Answer:
def max_n(arr, n):
arr.sort()
i = len(arr)-n
return arr[i:]
Explanation:
Define a function called max_n that takes two parameters, an array and an integer
Sort the array
In order to get the last n largest values, we need to slice the array. To do that we need a starting point. Our starting point of slicing will be the "lentgh of the array - n". That means, if we start slicing from that index to the last in the sorted array, we will get the last n largest values.
Assume array is 10, 2, 444, 91 initially.
When we sort it, it becomes 2, 10, 91, 444
Now let's say we want last 2 largest values, our sliced array index should start from 2 and go until the end
i = 4 - 2 = 2 → arr[2:] will return us 91 and 444
If you save the input as num,
this will print the input 8 times.
num = input("Enter a number: ")
print(num * 8)
If you want to do actual math calculations,
then the input needs to be a number.
num = float(input("Enter a number: "))
print(num * 8)
This doesn't account for any errors in which the user doesn't input a number, but I don't think that's what you were looking for anyway :)