a = int(raw_input("\nEnter two integers : "))
b = int(raw_input(""))
xptr = id(a)
yptr = id(b)
#There is no pointer concept in python
s = a + b
print "\nSum = ",s
a = int(raw_input("\nEnter two integers : "))
b = int(raw_input(""))
xptr = id(a)
yptr = id(b)
#There is no pointer concept in python
if a > b:
big = a
else:
big = b
print "\nBiggest number is ",big
def add10(x,y):
#There is no pointer concept in python
x = x + 10
y = y + 10
print "\n\nInside the function a = ",x," b = ",y
return x,y
a = 25
b = 10
print "\nBefore function call a = ",a," b = ",b
a,b = add10(a,b)
print "\nAfter function call a = ",a," b = ",b
def swap(x,y):
#There is no pointer concept in python
temp = x
x = y
y = temp
return x,y
a = int(raw_input("\nEnter two integers : "))
b = int(raw_input(""))
print "\nBefore function call a = ",a," b = ",b
a,b = swap(a,b)
print "\n\nAfter function call, values are exchanged as \n a = ",a," b = ",b
import sys
x = [0.0 for i in range(0,10)]
n = int(raw_input("\nHow many values ? "))
print "\nEnter all values in the list\n"
for i in range(0,n):
x[i] = float(raw_input(""))
sum1 = 0.0
#Since sum is a predefined function in python, sum1 is used
for i in range(0,n):
sum1 = sum1 + x[i]
#There is no pointer concept in python
mean = sum1/n
sys.stdout.write("\nArithmetic mean = %0.3f"%(mean))
import sys
xp = [0 for i in range(0,10)]
n = int(raw_input("\nHow many values ? "))
#There is no pointer concept in python
print "\nEnter all values\n"
for i in range(0,n):
xp[i] = int(raw_input(""))
print "\nThe reversed list is\n"
for i in range(n-1,0-1,-1):
sys.stdout.write("%6d"%(xp[i]))
import sys
a = [[0 for i in range(0,10)]for i in range(0,10)]
b = [[0 for i in range(0,10)]for i in range(0,10)]
c = [[0 for i in range(0,5)]for i in range(0,5)]
m = int(raw_input("\nFor A matrix \nHow many rows and columns ? "))
n = int(raw_input(""))
print "\nEnter A matrix values\n"
for i in range(0,m):
for j in range(0,n):
a[i][j] = int(raw_input(""))
n = int(raw_input("\nFor B matrix\nHow many rows and columns ? "))
l = int(raw_input(""))
for i in range(0,n):
for j in range(0,l):
b[i][j] = int(raw_input(""))
for i in range(0,m):
for j in range(0,l):
c[i][j] = 0
for k in range(0,l):
c[i][j] = c[i][j] + (a[i][k] * b[k][j])
print "\nResultant matrix is \n"
for i in range(0,m):
for j in range(0,l):
sys.stdout.write("%6d"%(c[i][j]))
sys.stdout.write("\n")
count = 0
st = raw_input("\nEnter a string : ")
sptr = st
i = 0
while i < len(st):
if st[i].upper() == 'A' or st[i].upper() == 'E' or st[i].upper() == 'I' or st[i].upper() == 'O' or st[i].upper() == 'U':
count = count + 1
i = i + 1
print "\nNumber of vowels = ",count
def sort_names(sn,n):
for i in range(0,n):
for j in range(i+1,n):
if sn[i] > sn[j]:
temp = sn[i]
sn[i] = sn[j]
sn[j] = temp
n = int(raw_input("\nHow many names ?"))
snames = ["" for i in range(0,10)]
print "\nEnter all names \n"
for i in range(0,n):
snames[i] = raw_input("")
sort_names(snames,n)
print "\nThe name list in alphabetical order"
for i in range(0,n):
print snames[i]
print "\nEnter a string : "
st = raw_input("")
rst = ['' for i in range(0,80)]
rst = st[::-1]
if st == rst:
print st," is a palindrome string"
else:
print st," is not a palindrome string"
print "\nEnter a string : "
st = raw_input("")
#There is no pointer concept in python
city = st
print "\nThe copied string : ",city
#class is used instead of structure in python
class student():
rno = 0
sname = ''
tot = 0
sptr = student()
sptr.rno = int(raw_input("\nEnter register No.:"))
sptr.sname = raw_input("\nEnter student name : ")
sptr.tot = int(raw_input("\nEnter total marks : "))
print "\n\tDetails entered are \n"
print "\nReg.No, : ",sptr.rno
print "\nName : ",sptr.sname
print "\nTotal : ",sptr.tot
#There is no pointer concept in python
def add(x,y):
return x+y
def multiply(x,y):
return x*y
a = int(raw_input("\nEnter two integers : "))
b = int(raw_input(""))
sum1 = add(a,b)
print "Sum a + b = ",sum1
product = multiply(a,b)
print "\nProduct a * b = ",product