Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Part 1:  Generate a list of Random Numbers

Write a program in Python that generates 20 random numbers and stores them in a list. The program should store the numbers in an array.  Use the list using the built-in functionality of the print functions.  Your output should look like this:

[22, 47, 71, 25, 28, 61, 79, 57, 89, 3, 29, 41, 99, 86, 75, 98, 4, 31, 22, 33]

Next, write a function that has the list as a parameter, and displays these statistics. Use the built-in min, max, sum, and len functions.

  • The lowest number
  • The highest number
  • The sum of the numbers

The output should look similar to  this:

Highest: 89
Lowest: 3
Sum: 482
Average: 48.2

Part 2: Prime Numbers List

For each number in your list, test to see if it is prime using the is_prime() function you wrote in the Prime Numbers lab. If the number is prime, add it to a new list and delete it from the original list. You'll end up with two lists: one with prime numbers and one with non-primes. Put a test in your code to sum the length of the two lists to be sure there are still 20 numbers in total. Now sort both lists with the built-in sort() function, then print them out. Your output should be similar to this:

Primes:  [47, 71, 61, 79, 57, 89, 3, 29, 41, 31]

Non-primes:  [22, 25, 28, 99, 86, 75, 98, 4, 22, 33]

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M92215553
  • Price:- $20

Priced at Now at $20, Verified Solution

Have any Question?


Related Questions in Computer Engineering

Question suppose you need to manually sort a hand of cards

Question : Suppose you need to manually sort a hand of cards. What techniques, other than a bubble sort, would you implement? Describe one or more algorithms at a high level.

Explain that our ability to secure each computers stored

Explain that our ability to secure each computers stored information is now influenced by the security on each computer to which it is connected.

Questionusing the cost-benefit analysis method estimate how

Question..... Using the cost-benefit analysis method, estimate how much money MidCorp should spend on power protection. You will have to make several assumptions to do this. Your answer should contain an "assumptions" se ...

A sample of 1000 us households is taken and the average

A sample of 1,000 U.S. households is taken and the average amount of newspaper garbage or recycling is found to be 27.8 pounds with a standard deviation of 2 pounds. Estimate, with 90% confidence, the mean amount of news ...

A sample of 1000 us households is taken and the average

A sample of 1,000 U.S. households is taken and the average amount of newspaper garbage or recycling is found to be 27.8 pounds. Assuming the standard deviation of newspaper for garbage or recycling is 2 pounds. Estimate, ...

Question please read this instruction and section 5 and 6

Question: Please read this instruction, and section 5 and 6 in particular, CAREFULLY as it affects all future programming assignments. 1. Setup Android Studio Development Environment 1.1 Download necessary packages using ...

Question specify design and implement a class for a card in

Question : Specify, design, and implement a class for a card in a deck of playing cards. The object should contain methods for setting and retrieving the suit and rank of a card. In C++ please

Question in sql database hospital systems suffer from 4-10

Question : In SQL Database, Hospital Systems suffer from 4-10% duplicate patients in the EHR. Some is that patients do not know the relationships of medical facilities in the same organization. What can you do to identif ...

Question suppose we are interested in studying a dna

Question : Suppose we are interested in studying a DNA sequence which consists of four bases: A, C, G, and T. Write a program that does the following: Create a random DNA string of length 50. Determine how many times A o ...

What is the importance of selling and salesmanship within a

What is the importance of selling, and salesmanship within a small business?

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As