def half(sequence):
result = []
for element in sequence:
result = result + [element / 2]
return result
half([1, 2, 3])
[0.5, 1.0, 1.5]
half([100, 30, 99, 122, 0])
[50.0, 15.0, 49.5, 61.0, 0.0]
def half(sequence):
result = []
for element in sequence:
result = result + [element - element]
return result
half([4, 5, 8])
[0, 0, 0]
def half(sequence):
result = []
for element in sequence:
result = result + [element - element * 0.5]
return result
half([4, 5])
[2.0, 2.5]
half([33, 100, 99, 500])
[16.5, 50.0, 49.5, 250.0]
half([3.3, 10.0, 99.1, 500])
[1.65, 5.0, 49.55, 250.0]