def get_a_value():
return float(input())
print "Enter the Length.."
leng=get_a_value()
print "Enter the Width.."
width=get_a_value()
print "Area = ",leng*width
def change_index():
index=5
index=3
print "index = ",index
change_index()
print "index = ",index
def get_a_value():
return float(input())
def calc_area():
global leng,width
return leng*width
print "Enter the Length.."
leng=get_a_value()
print "Enter the Width.."
width=get_a_value()
print "Area = ",calc_area()
def print_value(k):
print k
numb=5
print "Value of Expression : ",
print_value(numb*3+2)
def TOL():
return 0.0001
def sqrt(n):
if n>0.0:
guess=0.0
guess=n/2.0
while True:
if ((guess*guess-n) > TOL()) or ((guess*guess-n) < -TOL()):
temp=guess+n/guess
guess=temp/2.0
else:
break
return guess
else:
return -1.0
numb=float(input("Enter number.."))
print "Square Root of",numb,"is",sqrt(numb)
year=0
def leap(n):
return (n%4 == 0)and(n%100 != 0)or(n%400 == 0)
year=int(input("Enter Year.."))
if leap(year):
print year,"is leap year"
else:
print year,"is not leap year"
def input_value():
return input()
def area(l,w):
return l*w
print "Length = "
length=input_value();
print "Width = "
width=input_value();
print "Area = ",area(length,width)
value=1
def power(n,e):
global value
if(e<0):
return 0
for index in range(0,e):
if(index < e):
value*=n
index+=1
return value
number=int(input("Enter Integer..."))
exponent=int(input("Enter Exponent..."))
while True:
if (exponent<0):
exponent=input("Enter a Non-Negative Integer :")
else:
break
print number,"raised to ",exponent," = ",power(number,exponent)