Task 1- Random list of integers and computing the average Two functions you need to implement: generateRandomList( list size, maximum integer value) [returns a list] - This function should generate a list of random integers (between 0 and some maximum size). - The function has two parameters: (1) the size of the list and the maximum integer values. - The function should return the random list For example: if size = 3 and max int = 5 a valid random list would be [5, e, 1] computeAverage( a list ) [returns a float] This function takes in a list of integers. It should return the average value of all the elements in the list>

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter17: Linked Lists
Section: Chapter Questions
Problem 18PE
icon
Related questions
Question

This should be in Python, Thank you!!

Task 1- Random list of integers and computing the average
Two functions you need to implement:
generateRandomList( list size,
- This function should generate a list of random integers (between 0 and some maximum size).
maximum integer value) [returns a list]
- The function has two parameters: (1) the size of the list and the maximum integer values.
- The function should return the random list
For example: if size = 3 and max int = 5 a valid random list would be [5, 0, 1]
computeAverage( a list ) [returns a float]
This function takes in a list of integers. It should return the average value of all the elements in the list>
You may assume the list has one or more items in it.
For example, the list [5, 0, 1] would return 5.3333..
Task 1 functionality
1. Ask the user to input the size of the list (assume the input is a number 1 or greater)
2. Ask the user to input the maximum size of the integer allowed in the list
3. Generate a random list using the function above
4. Compute the average of the random list using the function above
5. Print the generated list
6. Print out the average with four decimal places (i.e., XX.XXXX) [see below]
Examples of task 1 (user input in red)
TASK 1: Random List
Input list size: 10
Input max int: 100
Generated list
[13, е, 10, 84, 57, 8, 99, зе, зе, 15]
Average value = 34.6000
<- format your output the same
TASK 1: Random List
Input list size: 1
Input max int: 5
Generated list
[5]
Average value = 5.0000
Transcribed Image Text:Task 1- Random list of integers and computing the average Two functions you need to implement: generateRandomList( list size, - This function should generate a list of random integers (between 0 and some maximum size). maximum integer value) [returns a list] - The function has two parameters: (1) the size of the list and the maximum integer values. - The function should return the random list For example: if size = 3 and max int = 5 a valid random list would be [5, 0, 1] computeAverage( a list ) [returns a float] This function takes in a list of integers. It should return the average value of all the elements in the list> You may assume the list has one or more items in it. For example, the list [5, 0, 1] would return 5.3333.. Task 1 functionality 1. Ask the user to input the size of the list (assume the input is a number 1 or greater) 2. Ask the user to input the maximum size of the integer allowed in the list 3. Generate a random list using the function above 4. Compute the average of the random list using the function above 5. Print the generated list 6. Print out the average with four decimal places (i.e., XX.XXXX) [see below] Examples of task 1 (user input in red) TASK 1: Random List Input list size: 10 Input max int: 100 Generated list [13, е, 10, 84, 57, 8, 99, зе, зе, 15] Average value = 34.6000 <- format your output the same TASK 1: Random List Input list size: 1 Input max int: 5 Generated list [5] Average value = 5.0000
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Linked List Representation
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning