i=32
print "Within the outer block: i=%d" % i
#There are no direct blocks in Python. We will do it in different way
print "Within the inner block"
def fu():
j = 10
for i in range(11):
print "i=", i, "j=",j
j -= 1
fu()
print "Within the outer block: i=%d" % i
#Python does'nt provide block creating facility like using just {} with out any name hence i have implemented in this way
def function_1():
x = 1234
y = 1.234567
print "From fuction_1:"
print "x=", x, ", y=", y
x = 4321
function_1()
print "Within the main block:"
print "x=%d, y=%f" %(x, y)
y = 7.654321
function_1()
print "Within the nested block:"
print "x=%d, y=%f" %(x, y)
counter =0
def add_two(x,y):
global counter
counter = counter+1
print "This is the function call of %d," % counter
return (x+y)
j = 5
for i in range(5):
print "The addition of "+ str(i) +" and "+str(j)+" is "+str(add_two(i,j))
j=j-1