1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
dmitriy555 [2]
3 years ago
15

Define a function max_n(arr, n) that takes in an array and an integer as arguments. Your function will then return the n largest

values from that array as an array containing n elements. It is safe to assume that arr will have at least n elements. The resulting array should have the largest number on the end and the smallest number at the beginning.
Computers and Technology
1 answer:
NikAS [45]3 years ago
4 0

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

You might be interested in
List and discuss five economic growth indicators
patriot [66]
Strong employment numbers. To see economic growth there needs to be an increase in Gross Domestic Product (GDP). ...
Stable Inflation. ...
Interest rates are rising. ...
Wage Growth. ...
High Retail Sales. ...
Higher New Home Sales. ...
Higher Industrial Production.
5 0
2 years ago
In web developing, what are the differences between front-end developer, back-end developer and full stuck developer?
Ilia_Sergeevich [38]

When it comes to front end, back end and full stack developer, the difference is determined by :

front end (the visible parts of a website)

back end (the “under the hood” databases and infrastructure)

full stack (a hybrid of both)

And front end developers work on technologies that are used to build front end(which is what clients visiting that website see)of application like HTML,CSS, Javascript ( Node js, Angular are also now used ).

Similarly back end developers work on back end technologies like Node js.

Full stack developers work on both front end and back end developers and know  both end technologies as well.

For example :

MEAN Stack developer where

M stands for Mongoose ( Back end database technology )

E stands for Express ( Back end technology)

A stands for angular ( front end technology)

N stands for Node ( back end technology)

8 0
3 years ago
A large retailer is asking each customer at checkout for their zip code. if the zip code is the only recorded variable, what is
Varvara68 [4.7K]

Answer:

Nominal

Explanation:

  • So while singing the question, let's further move to the answer. So let's see here and there.
  • The first option is B. S, which corrects gross sectional data, And the 2nd 1 of Nominal, C. Is correct nominal. So here are the buddha points which are given in the question.
  • The first one, option B is correct cross-sectional data, And the 2nd 1, is option C. Is correct nominal.

To learn more about it, refer

to brainly.com/question/25458754

#SPJ4

7 0
2 years ago
Can you please make a simple python program? I will give you 20 points and branliest if it is good! It must include:
alekssr [168]

Answer:

# Solve the quadratic equation ax**2 + bx + c = 0

# import complex math module

import cmath

a = 1

b = 5

c = 6

# calculate the discriminant

d = (b**2) - (4*a*c)

# find two solutions

sol1 = (-b-cmath.sqrt(d))/(2*a)

sol2 = (-b+cmath.sqrt(d))/(2*a)

print('The solution are {0} and {1}'.format(sol1,sol2))

Hope This Helps!!!

3 0
2 years ago
Read 2 more answers
Why was Windows 1.0 considered an operating environment rather than an operating system?
wolverine [178]

Windows 1.0 was only a shell program

The operating system for Windows 1.0 was MS-DOS

4 0
3 years ago
Read 2 more answers
Other questions:
  • One of the difficult decisions a systems analyst has to make when it comes to software is whether to recommend making, buying, o
    8·1 answer
  • Which of the following terms are aspect ratios for devices? 'select all that apply
    11·1 answer
  • Where would the information needed to start a computer be stored
    10·1 answer
  • Reasons for the growth of decision-making systems include:
    13·1 answer
  • The refresh or reload button is in the browser toolbar and usually looks like a pair of curved arrows. Clicking it will ________
    14·2 answers
  • Cual es la definición de grouded?​
    7·1 answer
  • Please help ASAP!
    5·1 answer
  • If the three operations were combined, O(logN) + O(N) * O(logN) + 1, the overall algorithm cost would be:________
    6·1 answer
  • Write a function that dynamically allocates an array of integers. The function should accept an integer argument indicating the
    8·1 answer
  • A Python file that contains variables and functions and can be used in other programs is called a
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!