def func():
x=-199 #local to func
print x #displays -199
x=10 #local to main
func()
print x #displays 10
def func1():
global count
print "count: ",count #access global count
func2()
def func2():
for count in range(3): #this is local variable
print '.',
count=None #global variables
for i in range(10):
count=i*2
func1()
from ctypes import *
#Variable declaration
j=c_uint(60000)
i=c_int(60000)
#Result
print i.value,j.value
for letter in xrange(ord('Z'),ord('A')-1,-1):
print chr(letter),
print "\n\\\b"
def total(x):
sum=0
for i in xrange(1,x+1):
sum=sum+i
for count in range(10):
print '-',
print "The current sum is",sum
print "Computing summation of 5."
total(5)
print "Computing summation of 6."
total(6)
#Variable declaration
x=10
y=3
print x/y #will display 3
print x%y #will display1, the remainder
x=1
y=2
#Result
print x/y,x%y #will display 0 1
def xor(a,b):
return (a or b)and(not(a and b))
#User-input
print "Enter P(0 or 1):"
p=1
print "Enter Q(0 or 1):"
q=0
#Result
print "P AND Q:",(p and q)
print "P OR Q:",(p or q)
print "P XOR Q:",xor(p,q)
for i in xrange(1,100+1):
print i,"/ 2 is:",float(i)/2