def double(sequence):
result = []
for element in sequence:
result = result + [element*2]
return result
double([1,10,5]++)
File "/tmp/ipykernel_8229/1792737275.py", line 1 double([1,10,5]++) ^ SyntaxError: invalid syntax
double([1,10,5])
[2, 20, 10]
double([-42,0,42])
[-84, 0, 84]
double([24])
[48]
double([])
[]
double()
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) /tmp/ipykernel_8229/2608569975.py in <module> ----> 1 double() TypeError: double() missing 1 required positional argument: 'sequence'
double means that the calculator doubles the amount/number contained in the squared brackets
x=[1,2,3]
double(x)
[2, 4, 6]
double(5)
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) /tmp/ipykernel_8229/1555949217.py in <module> ----> 1 double(5) /tmp/ipykernel_8229/838696399.py in double(sequence) 1 def double(sequence): 2 result = [] ----> 3 for element in sequence: 4 result = result + [element*2] 5 return result TypeError: 'int' object is not iterable
triple(5)
--------------------------------------------------------------------------- NameError Traceback (most recent call last) /tmp/ipykernel_8229/1069537581.py in <module> ----> 1 triple(5) NameError: name 'triple' is not defined
thrice([5])
x=[1,2,3]
double(3x)
File "/tmp/ipykernel_8229/4268276446.py", line 1 double(3x) ^ SyntaxError: invalid syntax
def thriple (sequence):
result = []
for element in sequence:
result=result+[element*3]
return result
thriple([1,2,3])
[3, 6, 9]
def half (sequence):
result=[]
for element in sequence:
result=result+[element/2]
return result
half([8,10,12])
[4.0, 5.0, 6.0]
def squared (sequence):
result=[]
for element in sequence:
result=result+[element*element]
return result
squared([2,4,5])
[4, 16, 25]
4+4.5+0.375
8.875
1500*0,08875
File "/tmp/ipykernel_8229/1334303866.py", line 1 1500*0,08875 ^ SyntaxError: invalid token
1500*0.08875
133.125
995.50*0.08875
88.350625
def tax(subtotal):
return subtotal*0.08875