Answered step by step
Verified Expert Solution
Link Copied!

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 program7_1.py
The script should include a main function and a custom value-returning 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 50 random integers all from 1 to 30, inclusive. These represent the ages of a population of 50 dogs.
Pass the list as the sole argument to the custom value-returning 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 5 by 10 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 bailt-in 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 puppy-aged dogs whose ages are less than 2. Use a built-in function with the list as an
argument to determine the count of puppy-aged dogs and print the count.
Do the same for senior-age dogs whose ages are greater than 10.
And do the same for adult-aged dogs whose ages are greater or equal to 2 and less than or equal to 10.
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 built-in functions and methods
Clear and well-structured code
The program should handle input and output correctly, with prompts and output formatted as in the example input/output.
EXAMPLE INPUT/OUTPUT
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

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

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Refactoring Databases Evolutionary Database Design

Authors: Scott Ambler, Pramod Sadalage

1st Edition

0321774515, 978-0321774514

More Books

Students also viewed these Databases questions

Question

Define span of management or define span of control ?

Answered: 1 week ago

Question

What is meant by formal organisation ?

Answered: 1 week ago

Question

What is meant by staff authority ?

Answered: 1 week ago

Question

Discuss the various types of policies ?

Answered: 1 week ago