Created
August 9, 2016 01:15
-
-
Save andymccurdy/ec110381a2dab1f689e995c198030ae2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def purify(numbers): | |
return [i for i in numbers if i % 2 == 0] |
..
def purify(x):
total = []
if x in total is int.odd:
x -= int.odd
else:
x += total
def product(x, y):
x = int(x)
y = int(y)
numbers = []
for i in numbers:
numbers *= ??
def product(numbers):
numbers = []
for i in numbers:
numbers *= numbers.append[]
return numbers
def product(numbers):
start = 1
for i in numbers:
start *= i
return start
def remove_duplicates(x):
new_list = []
if x == the same thing that is already x:
fucking remove it
add the single digits to the new_list
return new_list
def remove_duplicates(numbers):
new_list = []
for x in numbers:
if x not in new_list:
new_list.append(x)
return new_list
def median(x):
med_list = []
for i in x:
if x not in med_list:
med_list.append(x)
med_list = sorted(med_list)
Essentially, I need to put the numbers that come through 'x' into a list. Next I need to sort said list...which I believe i've done both. Now what I don't know how to do is take the middle number, or if it's an even value of numbers, taking the middle two numbers, dividing them, and outputting the median.
def median(x):
med_list = sorted(x)
if len(med_list) % 2 == 1:
return the middle index
else:
figure out how to divide the middle indexes and return it
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
long hand: