In [2]:
if True:
print("true")
In [3]:
x = False
In [4]:
if x == True:
print("True")
else:
print("False")
In [10]:
x = "isadacici"
if x == "Axis":
print("This is a {} BANK".format(x))
elif x == "icici":
print("This is an {} BANK".format(x))
elif x == "Hdfc":
print("This is an {} BANK".format(x))
else:
print("out of bound")
In [14]:
l = [1,2,3,4,5]
l
Out[14]:
In [18]:
for item in l:
print(item)
In [19]:
l = [1,2,3,4,5,6,7,8,9,10]
In [21]:
for n in l:
if n%2 == 0:
print("{} is an Even Number".format(n))
else:
print("{} is an odd Number".format(n))
In [25]:
l = [1,2,3,4,5]
In [26]:
listsum = 0
for i in l:
listsum += i
print("The Total value of listSum is {}".format(listsum))
In [27]:
# tuple unpacking
In [28]:
t = (1,2,3)
In [29]:
for i in t:
print(i)
In [30]:
l = [(1,2),(3,4),(5,6),(7,8)]
In [33]:
for t1,t2 in l:
#print(t1)
print(t2)
In [34]:
d = {"K1":1,"K2":2,"K3":3}
In [38]:
for k,v in d.iteritems():
print(k,v)
In [39]:
for t1,t2 in l:
print(t1+t2)
In [45]:
x = 0
while x < 10:
print("x is currently {}".format(x))
x += 1
In [49]:
x = 0
while x <10:
print("x is {} and less than 10".format(x))
print("Adding 1 to x")
x +=1
if x == 3:
print("x is equal to 3")
break
else:
print("continuing...")
continue
In [ ]: