• Home
  • Blog
  • Using python 3, design a function a function count_less_than_average(x): that returns the number of elements in x that are (strictly) less than the…

Using python 3, design a function a function count_less_than_average(x): that returns the number of elements in x that are (strictly) less than the…

0 comments

Using python 3, design a function 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 x = (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.

About the Author

Follow me


{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}