"""
the method shown in textbook is not possible in python.
We will implement in a different way
"""
print "Enter a string. Enter quit to stop"
my_str = ""
while True:
c = raw_input()
if c == "quit":
break
my_str = my_str + c + " "
print "String you entered is: ", my_str
#Do.. While loop
row = 1
column = 1
while row <= 3:
column = 1
while column <= 3:
y = row * column
print " ", y,
column += 1
print ""
row += 1
print "2 to power-n n 2 to power n"
p = 1
for n in range(0,10):
if n == 0:
p = 1
else:
p = p * 2
q = float(1.0/p)
print q," ",n," ",p
states = ["TamilNadu", "AndhraPradesh", "UttarPradesh", "Rajasthan"]
for i in range(0, len(states)):
print "Standard for-loop: state name: ", states[i]
print ""
for state in states:
print "Enhanced for-loop: state name: ", state
print ""
cities = []
cities.append("Delhi")
cities.append("Mumbai")
cities.append("Calcutta")
cities.append("Chennai")
for i in range(0, len(cities)):
print "Standard for-loop: state name: ", cities[i]
print ""
for city in cities:
print "Enhanced for-loop: enhanced name: ", city
print "\nIn Collection"
for i in cities:
print i
for i in range(1,100):
print " "
if i >= 10:
break
for j in range(1, 100):
print " * ",
if j == i:
break