Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Write a function named create_list that takes in a list size and returns a list of random numbers from 1-6. i.e., calling create_list(5) should return

Write a function named create_list that takes in a list size and returns a list of random numbers from 1-6. i.e., calling create_list(5) should return 5 random numbers from 1-6. (Remember, Chapter 7 has code showing how to do something similar, creating a list out of five numbers the user enters. Here, you need to create random numbers rather than ask the user.) To test, use this code against the function you wrote:

my_list = create_list(5)

print(my_list)

And you should get output of five random elements that looks something like:

[2,5,1,6,3] 

Write a function called count_list that takes in a list and a number. Have the function return the number of times the specified number appears in the list. To test, use this code against the function you wrote:

count = count_list([1,2,3,3,3,4,2,1],3)

print(count)

And you should get output something like:

3 

Write a function called average_list that returns the average of the list passed into it. To test, use this code against the function you wrote:

avg = average_list([1,2,3])

print(avg)

And you should get output something like:

2

(10 pts) Now that the functions have been created, use them all in a main program that will:

Create a list of 10,000 random numbers from 1 to 6. This should take one line of code. Use the function you created earlier in the lab.)

Print the count of 1 through 6. (That is, print the number of times 1 appears in the 10,000. And then do the same for 2-6.)

Print the average of all 10,000 random numbers.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions