Question: This program requires the main function and a custom value-returning function . In the main function, code these basic steps in this sequence : use
This program requires the main function and a custom value-returning function.
In the main function, code these basic steps in this sequence:
use a list comprehension to generate 100 random integers all from 1 to 100, inclusive. These represent the ages of a population of 100 people.
pass the list as the sole argument to the custom value-returning function.
In the custom function:
sort the list in descending order using methods described in Chapter 7
return the sorted list to main
Back in main:
within a for loop to print a 10 by 10 representation of the ages returned by the custom function. As listed in the example output, the ages should be in descending order and evenly spaced. Also, within the same for loop accumulate the sum of all ages.
using a built-in function described in Chapter 7 to determine the age of the oldest person, then print it
using a built-in function described in Chapter 7 to determine the age of the youngest person, then print it
determine the average age by making use of the sum of all ages calculated in the for loop above and a built-in function described in Chapter 7, then print the average age so that two decimal positions are included
within a for loop
count the minor ages that are less than 18
count the senior ages that are greater than 65
print the count of minor ages
print the count of senior ages
use either a loop or a list comprehension to create a list of college ages (ages that are greater or equal to 18 and less than or equal to 21). A bonus of 3 points will be awarded if a list comprehension is employed
print the count of senior ages making use of a built-in function described in Chapter 7
Printed output and messages should be formatted as in the example output.
Example Output
must be exact wording and output
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
