Untitled8 Ipynb
Untitled8 Ipynb
ipynb - Colaboratory
a = [1,2,3,4]
b = [sum(a[0:x+1]) for x in range (0, len(a))]
print(b)
[1, 3, 6, 10]
t = '%(a)s%(b)s %(c)s'
print(t % dict(a='Welcome', b='to', c='Turing'))
---------------------------------------------------------------------------
<ipython-input-3-472a7fec4f3c> in <module>()
l = [1,2,3,4,5]
m = map (lambda x: 2**x, l)
print(list(m))
class Welcome:
def __init__(self, name):
self.name = name
def say_hello(self):
print('Welcome to', self.name)
cw = Welcome ('Turing')
cw.say_hello()
Welcome to Turing
def f(x,l=[]):
for i in range(x):
l.append(i*i)
print(l)
f(2)
f(3,[3,2,1])
f(3)
[0, 1]
[3, 2, 1, 0, 1, 4]
[0, 1, 0, 1, 4]
https://colab.research.google.com/drive/1b_L4pbta3svUhHfuRYpogz7KOTQ-8A5x#printMode=true 1/2
05/06/2022, 02:07 Untitled8.ipynb - Colaboratory
y=
https://colab.research.google.com/drive/1b_L4pbta3svUhHfuRYpogz7KOTQ-8A5x#printMode=true 2/2