In [3]:
a, b = 0, 1
while b < 1000:
print(b,end=',')
a, b = b, a+b
# new line arranged accoriding to usage frequency
In [17]:
#this is for pointer and data copy issues
words=['set','me','up','for', 'a', 'win']
words[:]
crowds=words
In [19]:
for i in crowds[:]:
print(i,len(i))
crowds.insert(0,i)
In [20]:
crowds
Out[20]:
In [21]:
words
Out[21]:
In [22]:
hurds=crowds
In [23]:
words = ['wow','what','a','coincedence']
In [25]:
hurds
Out[25]:
In [31]:
print(range(0,5,30))
In [37]:
testarray=range(0,5,30)
In [38]:
testarray
Out[38]:
In [42]:
list(testarray)
list(range(10))
Out[42]:
In [11]:
cnt=0
for g in ['susie','mary','lisa']:
cnt=cnt+1
if g =='mary':
continue
print(cnt)
In [56]:
def fib(n): # write Fibonacci series up to n
"""Print a Fibonacci series up to n."""
a, b = 0, 1
while a < n:
print(a, end=',')
a, b = b, a+b
print()
return(b-a)
fib(5000)
Out[56]:
In [57]:
'this' in ['that','this','it']
Out[57]:
In [59]:
def listCheck(a, L=None):
if L is None:
L = []
L.append(a)
return L
listCheck(1,[2,3,4])
Out[59]:
In [61]:
listCheck(2)
Out[61]:
In [6]:
anotherList=[1,4]
range(*anotherList)
Out[6]:
In [7]:
d={"what":"My parrot","this":"is a green bird "}
In [8]:
def aFunc(what="I dont know",this=" this item"):
print(what,this)
aFunc()
In [9]:
aFunc(**d)
In [10]:
print('I am working with the result of previous interpretation. Result =',_,end=' ')
In [ ]:
from collections import deque
queue = deque(["Eric", "John", "Michael"])