Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Ignore the part below 'Using test program', Write the function with Python, Thanks!!!!! Question 1: 3 Marks Let X=?1,22, An be a sequence of numbers.

image text in transcribed

Ignore the part below 'Using test program', Write the function with Python, Thanks!!!!!

Question 1: 3 Marks Let X=?1,22, An be a sequence of numbers. The average or mean of the sequence is defined as ??l i Question 1: Write a function count_less_than_average(x): that returns the number of elements in x that are (strictly) less than the average of x. For example: If x [1, 2. 3, 4. 5], count_less than average(x) should return 2, since the average of x is 3 and there are two elements in x less than 3. If (1, 2, 3, 4. 100), count_less than average(x) should return 4, since the average of x is 22 and there are four elements in x less than 22. If x , count less_than average(x) should return 0 since the average of an empty sequence is undefined. A skeleton file called problem1.py is provided (t will be on the desktop). You should write your solution into this file. You can assume that x is a sequence (e-g. a list, tuple, ete.) of numbers. . You can not assume that x is non-empty The function must return an integer (type int) between 0 and the length of x. The function must not modify the argument sequence. You must write your solution in the file called problen1.py found on the desktop. The function that you write must be named count less_than_average and it must take a single parameter Remember that your solution file must contain only function definitions, comments, and optionally import statements. If it contains anything else, it is invalid and you will receive zero marks. If you run the testing program, it will tell you if your file is invalld Using the testing program The testing program for this problem is called test_problem1.py. It is also found on the desktop. To run the testing program, you only need to run test problen1.py The program will test the implementation of the function named count less thanaverage in the file problem1.py (in the same directory). You should not make any changes to the testing program. Levels This question does not have multiple levels

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

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

Recommended Textbook for

Database Systems Design Implementation And Management

Authors: Peter Robb,Carlos Coronel

5th Edition

061906269X, 9780619062699

More Books

Students also viewed these Databases questions

Question

2. What do you believe is at the root of the problem?

Answered: 1 week ago