def lineno(): #to print lineno
return inspect.currentframe().f_back.f_lineno
x=10
print 'First call to assert ' #assert
assert(x==10)
print 'Second call to assert '
#assert(x!=10) assertion failed will be seen
#print 'Done '
SIZE=3
str=['ab12cd','34ef56','gh78jk'] #str array declared
NoofAlphabets=[0,0,0]
temp=0
for i in range(SIZE):
NoofAlphabets[i]=0
temp=str[i]
for j in range(len(temp)):
if temp[j].isalpha(): #isalpha to find if its alphabet
NoofAlphabets[i]=NoofAlphabets[i]+1
print 'Number of alphabets in string : ',str[i],
print 'is',NoofAlphabets[i]
import math
PI=3.1415926535
x=PI/2.0
y=4.5
z=2.30258093
n=0
print 'sine of PI/2 is',
print int(math.sin(x))
print 'cosine of PI/2 is',
print math.cos(x)
print 'exponent of %.5f'%z,'is',
print math.exp(z)
#frexp() take single argument and return a pair of values,rather than returning their second return value through output parameters
#therefore no such thing occurs in python
def sum(first): #function declared to compute the sum
j=1
i=first[0]
s=0
while not i==-1:
s+=i
i=first[j]
j+=1
return s
print 'sum is: ',sum([2,3,4,-1]) #function called
print 'sum is: ',sum([5,7,9,11,-1])
print 'sum is: ',sum([-1])