Answered step by step
Verified Expert Solution
Question
1 Approved Answer
PROGRAM OBJECTIVE The objective of this assignment is to create a Python program that performs various operations on a list of randomly generated numbers representing
PROGRAM OBJECTIVE
The objective of this assignment is to create a Python program that performs various operations on a list of randomly generated numbers
representing ages of a population of dogs in a kennel. The program should be able to sort, print, and perform calculations on this list to provide
insights on the population's age distribution.
DELIVERABLES
A Python program named programpy
The script should include a main function and a custom valuereturning function
This program shall also meet all requirements stated in the assignment requirements section above and the evaluation criteria stated in the
section below and will be scored using the assignment rubric.
INSTRUCTIONS
In the main function of your script, follow these steps:
Use a list comprebension to generate random integers all from to inclusive. These represent the ages of a population of dogs.
Pass the list as the sole argument to the custom valuereturning function.
In the custom function:
Sort the list in descending order
Return the sorted list to main
Back in main:
Within a for loop, print a by representation of the ages retumed by the custom function. The ages should be in descending order
and evenly spaced. Also, within the same for loop, accumulate the sum of all ages. Print the sum after the loop terminates.
Use bailtin functions to determine the ages of the oldest and youngest dogs, then print them
Determine the average age by making use of the sum of all ages calculated in the for loop above, then print the average age so that two
decimal positions are included
Use a list comprehension to create a list of puppyaged dogs whose ages are less than Use a builtin function with the list as an
argument to determine the count of puppyaged dogs and print the count.
Do the same for seniorage dogs whose ages are greater than
And do the same for adultaged dogs whose ages are greater or equal to and less than or equal to
ADDITIONAL EVALUATION CRITERIA
In addition to the requirements for this module stated in the section above, your program will also be evaluated on the following criteria:
Accuracy of results
Efficiency of your code
Proper use of Python builtin functions and methods
Clear and wellstructured code
The program should handle input and output correctly, with prompts and output formatted as in the example inputoutput
EXAMPLE INPUTOUTPUT
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started