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
Answer:
see attachment
Explanation:
You have not specified the language, or the details of the I/O form or prompts. Here is a program that does that, written in Wolfram language (the language of Mathematica).
It prompts separately for student name and student score. The minimum score is presumed to be higher than -99999. If only one student name is entered, the second output is that score with no name listed. There is no error checking.
We have elected to keep a list only of the two two scores, and to sort that list again each time a new entry is made.
__
The attachment shows the output of the program below the program listing.
Answer:
The devices that can be used to perform both functions -input and output- are called Dual Devices. These devices are also called Dual Purpose Devices or Both Input/Output Devices. With the help of a dual-purpose device, we can enter data into computers as well as we can output data from the computer to outside world.
Explanation:
hope it hepl u :-)
Clicking Ctrl+a and backspace deletes all letters.<span />
Search has come to be one of the key features of mobile computing. Gone are the days of maps, phone books and a book shelf full of encyclopedias. The users want data at their fingertips and at all times and exploration is how that come to pass. Apple is on the rampage siri which agree to users to connect to yelp and wolfram alpha for searches. The facebook launched graph search which appeals its data from the site. These approaches will most likely never reach the popularity or efficiency of google but, they could succeed in reducing market share of google.