Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
list
#1
Define the get_funny_average() function which is passed a list of numbers as a parameter and returns the average of some of the numbers in the parameter list. The function returns the average of the remaining numbers (rounded to 1 decimal place) after all the following have been excluded from the parameter list of numbers (if they exist in the list):

all zeroes,
all negative numbers,
and
the two smallest positive numbers

Could someone explain to me how would I go about this without giving the code as I need to abide by the rules
Reply
#2
(May-07-2019, 10:41 AM)ravioli2929 Wrote: all zeroes,
all negative numbers,
and
the two smallest positive numbers

Isn't first two conditions something like less or equal to zero and third one is just sorted list starting from third element.
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply
#3
would i have to use pop()?
Reply
#4
from original list create new list with just the positive (i.e. greater than 0) numbers in the original list. Sort the new list. Calculate average for elements with index 2 and more (hint - use slicing)

EDIT: I have edited my answer - index is 2 not 3 as my original post
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020