def MIN(a,b):
if a<b:
return a
else:
return b
#Variable declaration
x=10
y=20
#Result
print "The minimum is",MIN(x,y)
def EVEN(a):
if a%2==0:
return 1
else:
return 0
if EVEN(9+1):
print "is even"
else:
print "is odd"
def EVEN(a):
if a%2==0:
return 1
else:
return 0
if EVEN(9+1):
print "is even"
else:
print "is odd"
def MAX():
return 100
if MAX()>10:
print "Extra memory required."
def MAX():
return 6
if MAX()>10:
print "Extra memory required."
else:
print "Current memory OK."
def TOM():
pass
try:
TOM()
except NameError:
print "Programmer is unknown."
else:
print "Programmer is Tom."
try:
RALPH()
except NameError:
print "RALPH not defined."
import inspect
def lineno():
return inspect.currentframe().f_back.f_lineno
print lineno()+200
def mkstr(s):
return str(s)
#Result
print mkstr('I like C++')
def concat(a,b):
return a+b
#Variable declaration
xy=10
#Result
exec("print %s")%concat('x','y')