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
Dvinal [7]
3 years ago
5

The function below takes a single parameters: a list of numbers called num_list. Return a new list containing just the three lar

gest numbers (in any order). Your function shouldn't modify the original list. You can assume that the list always contains at least 3 numbers. The easiest way to accomplish this is to sort the provided data and then slice, but you'll need to make a copy of the data (so that you don't modify the original list).
print.py 1. hef three_largest numbers(num_list):
Computers and Technology
1 answer:
yarga [219]3 years ago
8 0

Answer:

  1. def three_largest_numbers(num_list):
  2.    sort_list = num_list
  3.    sort_list.sort(reverse=True)
  4.    return sort_list[0:3]
  5.    
  6. print(three_largest_numbers([5, 7, 1, 8, 9, 3, 6]))

Explanation:

Firstly, we declare a function that will take one input list, num_list (Line 1). To avoid modifying the original num_list, we create a copy of num_list and assign it to a new list, sort_list (Line 2) in the function. Next, we use Python list  sort function to sort the list in descending order (Line 3). At last, return the first three elements of the sort_list as output (Line 4).

We test the function using a sample list (Line 6) and we shall get [9, 8, 7] printed in terminal.

You might be interested in
Should organizations fear websites where consumers post negative messages about products or services? What actions can companies
pickupchik [31]

Answer:

This is something that actually helps organizations to improve their work and subsidiaries by people's real time assessement.

Explanation:

When consumers post negative messages, whether they are true or not, organizations have the opportunity to have an online conversation with consumers and provide help in real time communication. This improves communication within a company and with other subsidiaries by evaluating honest and threatening comments related to e-commerce real life development. There are a lot of people who do not use products according to the comments available on their marketing webpages, such as myself. These are all important for everyone to assess if it is worth to buy a product or not, and to keep up an online community in which people help each other by suggestions and recommendations, and organizations can take a lot of advantages from that, such as increasing their number of consumers.

5 0
2 years ago
Write a program that reads an unspecified number of integers, determines how many positive and negative values have been read, a
GarryVolchara [31]

Answer:

<em>C++</em>

////////////////////////////////////////////////////////////////////////////////////////////////////////

#include <iostream>

#include <vector>

using namespace std;

int main() {

  vector<int> v;

   int n = 1;

   while (n != 0) {

       cout<<"Enter an integer, the input ends if it is 0: ";

       cin>>n;

       v.push_back(n);

   }

   cout<<endl;

   ///////////////////////////////////////////////////////////

   int sum = 0;

   int num_positives = 0, num_negatives = 0;

   for (int i=0; i<v.size()-1; i++) {

       if (v[i] > 0)

           ++num_positives;

       else

           ++num_negatives;

           

       sum = sum + v[i];

   }

   //////////////////////////////////////////////////////////

   cout<<"The number of positives is "<<num_positives<<endl;

   cout<<"The number of negatives is "<<num_negatives<<endl;

   cout<<"The total is "<<sum<<endl;

   cout<<"The average is "<<(float)sum/(v.size()-1);

   ///////////////////////////////////////////////////////////

   return 0;

}

5 0
3 years ago
Write a recursive method named binarySearch that accepts a sorted array of integers and an integer target value and uses a recur
djyliett [7]

Answer:

10

-1

Process finished with exit code 0

Explanation: see code bellow

public class BinarySearchRecursive {

   public static int binarySearch(int[] a, int key) {

       return binarySearchRecursiveHelper(a, key, 0, a.length - 1);

   }

   public static int binarySearchRecursiveHelper(int[] arr, int target, int start, int end) {

       if (start > end) {

           return -1;

       }

       int mid = (start + end) / 2;

       if (arr[mid] == target) {

           return mid;

       } else if (target < arr[mid]) {

           return binarySearchRecursiveHelper(arr, target, start, mid - 1);

       } else {

           return binarySearchRecursiveHelper(arr, target, mid + 1, end);

       }

   }

   public static void main(String[] args) {

       int[] a = {-4, 2, 7, 10, 15, 20, 22, 25, 30, 36, 42, 50, 56, 68, 85, 92, 103};

       int index = binarySearch(a, 42);   // 10

       System.out.println(index);

       index = binarySearch(a, 66);   // -1

       System.out.println(index);

   }

}

6 0
2 years ago
A popular encryption method used to protect data that travel over a wireless network is ___
ddd [48]

Answer:

The most serious threat to offshore industrial systems is external access to control systems. Unwanted access to the human/machine interface (HMI) can allow third parties full control of a system. Zybersafe provides protection of the integrity of data that traverses the Ethernet connection between a company’s headquarters and a remote system.

4 0
3 years ago
Using the functions from problems 1 and 2, write a MATLAB script to compare the laminar results from to the turbulent results. C
suter [353]

To start combining, select the Merge Mode option on the Comparison tab. Next, click the button next to the line you wish to merge in order to replace content from the right pane with content from the left pane.

<h3>How is boundary layer thickness calculated?</h3>
  • Where x is a position parallel to the wall, y is a coordinate normal to the wall, v is a (small) viscosity, u = (u, v) is the velocity, is the vorticity, and so on. The boundary conditions are as follows: u(x,y = +,t) = U, and u(x,y = 0,t) = 0.
  • To gauge the overall pressure, a vertically sliding Pitot tube is employed. So that the growth of the boundary layer in the flow direction can be seen, the total pressures can be recorded at various distances from the plate surface. Static pressure is gauged at a different measurement location.
  • To start combining, select the Merge Mode option on the Comparison tab. Next, click the button next to the line you wish to merge in order to replace content from the right pane with content from the left pane. Alternatively, you can pick a discrepancy and choose Replace Content from the Comparison tab.        

To learn more about Boundary conditions refer to:

brainly.com/question/23802083

#SPJ4

6 0
1 year ago
Other questions:
  • Which of the following is important to do when downloading a game to your
    8·1 answer
  • Litmus-type test strips are used to test coolant for freeze protection and ?
    12·1 answer
  • This information is generally included on a fax cover sheet.
    15·1 answer
  • What will the output be from the following program?
    5·1 answer
  • #11. Write a program that prompts the user to input a four-digit positive integer. The program then outputs the digits of the nu
    6·1 answer
  • Assume that an array named salarySteps whose elements are of type int and that has exactly five elements has already been declar
    12·1 answer
  • How to change color of object in photoshop?
    10·2 answers
  • Kellyn needs to move Slide 8 of his presentation up so that it becomes Slide 6. What best describes how he can do this using the
    11·2 answers
  • How to convert binary to decimal <br> Please it’s so hard and what is digital and analogue
    9·1 answer
  • Which of the following is an example of an incremented sequence?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!