def UPPER(): #set UPPER() as 25
return 25
for i in range(1,UPPER()+1,1):
print "%d\n" % (i)
def PI(): #set PI() as 3.14
return 3.14
r=6.25
area=PI()*r*r
print "Area of circle=%f\n" % (area)
def AND(x,y): #set AND(x,y) for "and" operation
return (x and y)
def OR(a,b): #set OR(a,b) for "or" operation
return (a or b)
f=1
x=4
y=90
if (AND(f<5,OR(x<=20,y<=45))):
print "Your PC will always work fine...\n"
else:
print "In front of the maintenance man\n"
def AND(x,y): #set AND(x,y) for "and" operation
return (x and y)
def ARANGE():
return (AND(a>25,a<50)) #check for a>25 and a<50
a=30
if (ARANGE()):
print "within range\n"
else:
print "out of range\n"
def FOUND():
print "The Yankee Doodle Virus\n"
signature='Y'
if (signature=='Y'):
FOUND()
else:
print "Safe... as yet!\n"
def AREA(x):
return (3.14*x*x)
r1=6.25
r2=2.5
a=AREA(r1)
print "Area of circle=%f\n" % (a)
a=AREA(r2)
print "Area of circle=%f\n" % (a)
r1=6.25
r2=2.5
a=3.14*r1*r1
print "Area of circle=%f\n" % (a)
a=3.14*r2*r2
print "Area of circle=%f\n" % (a)
def ISDIGIT(y):
return (y>=48 and y<=57)
print "Enter any digit"
ch=raw_input()
if (ISDIGIT(ord(ch))):
print "You entered a digit\n"
else:
print "Illegal input\n"
def SQUARE(n):
return (n*n)
j=64/SQUARE(4) #it's function not macros ,so j=4
print "j=%d\n" % (j)
def HLINE():
for i in range(0,79,1):
print "%c" % 45, #characters are bytes and therefore encoding-dependent(non utf-8)
print "\n"
def VLINE(X,Y):
print "%c" % 124 #If you want to write 179 in place of 124 then use utf-8 encoding
HLINE()
for y in range(1,25,1):
VLINE(39,y)
OKAY=False
if OKAY:
import logging
print "statement 1"
print "statement 2" #detects virus
print "statement 3"
print "statement 4" #specific to stone virus
print "statement 5"
print "statement 6"
print "statement 7"
INTEL=False
if INTEL:
print "code suitable for an Intel PC"
else:
print "code suitable for a Motorola PC"
print "code common to both the computers"
INTEL=True
if INTEL:
print "code suitable for a Intel PC"
else:
print "code suitable for a motorola PC"
print "code common to both the computers"
TEST=6
if TEST<=5:
print "statement 1"
print "statement 2"
print "statement 3"
else:
print "statement 4"
print "statement 5"
print "statement 6"
ADAPTER='SVGA'
if ADAPTER=='VGA':
print "code for video graphics array"
else:
if ADAPTER=='SVGA':
print "code for super video graphics array"
else:
print "code for extended graphics array"
ADAPTER='SVGA'
if ADAPTER=='VGA':
print "code for video graphics array"
elif ADAPTER=='SVGA':
print "code for super video graphics array"
else:
print "code for extented graphics adapter"
def fun1():
print "Inside fun1\n"
def fun2():
print "Inside fun 2\n"
def main():
print "Inside main\n"
fun1()
main()
fun2()
def f1():
a=5
def f2(x):
print "Inside f2" #passed parameter is not being used
def f3():
x=6
return x
x+=1 #control can never reach this statement
f1()
f2(7)
f3()