Professional Documents
Culture Documents
PRACTICAL RECORD
Name : ...............................................................................................................
Class : ...............................................................................................................
Certified that this is abonafide work done by the above student during
TEACHER PRINCIPAL
1
INDEX
2 ODD OR EVEN
5 SENIOR CITIZEN
6 DIVISIBLE BY 5 AND 11
8 NUMBER IN WORDS
9 VOWEL OR NOT
20 COMPOUND INTEREST
25 PALINDROME STRING
26 LIST OPERATIONS
2
3
PYTHON
PROGRAMMING
4
Write a program to find whether the number is +ve or -ve.
5
Ex.No.: 01
+ve or –ve NUMBER
Date :
6
7
SOURCE CODE:
print("\nProgram to find whether the number is +ve or -ve")
N=int(input("Enter N: "))
if N>0:
print(N,"is +ve")
else:
print(N,"is -ve")
print("Program ends")
RESULT:
Thus the python program has been executed and output verified successfully.
8
Write a program to find whether the number is odd or even.
9
Ex.No.: 02
ODD OR EVEN
Date :
10
11
SOURCE CODE:
print("\nProgram to find whether the number is even or odd")
N=int(input("Enter N: "))
if N%2==0:
print(N,"is even.")
else:
print(N,"is odd.")
print("Program ends.")
RESULT:
Thus the python program has been executed and output verified successfully.
12
Write a program to find elder one among two persons.
13
Ex.No.: 03
ELDER ONE AMONG TWO PERSONS
Date :
14
15
SOURCE CODE:
print("Program to find elder one among two persons")
name1=input("Enter 1st person's name: ")
A=int(input("Enter 1st person's age: "))
name2=input("Enter 2nd person's name: ")
B=int(input("Enter 2nd person's age: "))
if A>B:
print(name1,"is elder.")
else:
print(name2,"is elder.")
print("Program ends.")
RESULT:
Thus the python program has been executed and output verified successfully.
16
Write a program to find whether the given year is leap year or not.
17
Ex.No.: 04
LEAP YEAR OR NOT
Date :
18
19
SOURCE CODE:
print("Program to find whether the given year is leap year or not")
year=int(input("Enter the year: "))
if year%4==0:
print(year,"is a leap year")
else:
print(year,"is a non-leap year")
RESULT:
Thus the python program has been executed and output verified successfully.
20
Write a program to find whether the person is a senior citizen.
21
Ex.No.: 05
SENIOR CITIZEN
Date :
22
23
SOURCE CODE:
print("Program to find whether the person is a senior citizen")
name=input("Enter your name: ")
age=int(input("Enter your age: "))
if age>=60:
print("Hi",name,"..! You are a senior citizen ..!!")
else:
print("Hi",name,"..! You are not a senior citizen ..!!")
RESULT:
Thus the python program has been executed and output verified successfully.
24
Write a program to find whether a number is divisible by 5 and 11.
25
Ex.No.: 06
DIVISIBLE BY 5 AND 11
Date :
26
27
SOURCE CODE:
print("Program to find whether a number is divisible by 5 and 11.")
n=int(input("Enter the number: "))
if n%5==0 and n%11==0:
print(n,"is divisible by 5 and 11.")
else:
print(n,"is not divisible by 5 and 11.")
RESULT:
Thus the python program has been executed and output verified successfully.
28
Write a program to find whether the given number is in the list.
29
Ex.No.: 07
FIND THE NUMBER IN THE LIST
Date :
30
31
SOURCE CODE:
print("Program to find whether the given number is in the list")
n=int(input("Enter N: "))
if n in [0,1,2,3,4,5,6,7,8,9]:
print("You have entered",n)
else:
print("You have entered some other thing")
RESULT:
Thus the python program has been executed and output verified successfully.
32
Write a program to display the number in words.
33
Ex.No.: 08
NUMBER IN WORDS
Date :
34
35
SOURCE CODE:
print("Program to display the number in words")
num=int(input("Enter the number: "))
if num==0:
print("You have entered ZERO")
elifnum==1:
print("You have entered ONE")
elifnum==2:
print("You have entered TWO")
elifnum==3:
print("You have entered THREE")
elifnum==4:
print("You have entered FOUR")
elifnum==5:
print("You have entered FIVE")
elifnum==6:
print("You have entered SIX")
elifnum==7:
print("You have entered SEVEN")
elifnum==8:
print("You have entered EIGHT")
elifnum==9:
print("You have entered NINE")
else:
print("You have entered",num)
RESULT:
Thus the python program has been executed and output verified successfully.
36
Write a program to check whether the given character is vowel or not.
37
Ex.No.: 09
VOWEL OR NOT
Date :
38
39
SOURCE CODE:
print("Program to check whether the given character is vowel or not")
ch=input("Enter a character: ")
#if ch=='a' or ch=='e' or ch=='i' or ch=='o' or ch=='u': # or otherwise we can give -
if ch in ['a','e','i','o','u']:
if ch in ['a','e','i','o','u']:
print("You have entered a vowel")
else:
print("You have entered a consonant")
RESULT:
Thus the python program has been executed and output verified successfully.
40
Write a menu driven program to find the area of shapes.
41
Ex.No.: 10
AREA OF SHAPES (MENU DRIVEN)
Date :
42
43
SOURCE CODE:
print("Menu driven program to find the area of shapes")
st=True
while st:
print("1.Area of Circle")
print("2.Area of Square")
print("3.Area of Rectangle")
print("Any other value to Quit")
ch=int(input("Enter you choice: "))
if ch==1:
rad=int(input("Enter the radius of the circle: "))
area=3.14*rad*rad
print("Area of Circle is",area)
print("\n")
elifch==2:
side=int(input("Enter the measurement of a side in the square: "))
area=side*side
print("Area of Square is",area)
print("\n")
elifch==3:
length=int(input("Enter the length of the rectangle: "))
breadth=int(input("Enter the breadth of the rectangle: "))
area=length*breadth
print("Area of Rectangle is",area)
print("\n")
else:
print("Exits system")
st=False
RESULT:
Thus the python program has been executed and output verified successfully.
44
Write a menu driven program (one-time) to find the area of shapes.
45
Ex.No.: 11
AREA OF SHAPES (ONE-TIME MENU)
Date :
46
47
SOURCE CODE:
print("Menu driven program (one-time) to find the area of shapes")
print("1.Area of Circle")
print("2.Area of Square")
print("3.Area of Rectangle")
print("Any other value to Quit")
ch=int(input("Enter you choice: "))
if ch==1:
rad=int(input("Enter the radius of the circle: "))
area=3.14*rad*rad
print("Area of Circle is",area)
print("\n")
elifch==2:
side=int(input("Enter the measurement of a side in the square: "))
area=side*side
print("Area of Square is",area)
print("\n")
elifch==3:
length=int(input("Enter the length of the rectangle: "))
breadth=int(input("Enter the breadth of the rectangle: "))
area=length*breadth
print("Area of Rectangle is",area)
print("\n")
else:
print("Exits system")
RESULT:
Thus the python program has been executed and output verified successfully.
48
Write a program to generate even nos. upto N.
49
Ex.No.: 12
EVEN NOS. UPTO N
Date :
50
51
SOURCE CODE:
print("Program to generate even nos. upto N")
N=int(input("Enter a number: "))
for i in range(2,N,2):
print(i,end=' ')
RESULT:
Thus the python program has been executed and output verified successfully.
52
Write a program to generate odd nos. upto N.
53
Ex.No.: 13
ODD NOS. UPTO N
Date :
54
55
SOURCE CODE:
print("Program to generate odd nos. upto N")
N=int(input("Enter a number: "))
for i in range(1,N,2):
print(i,end=' ')
RESULT:
Thus the python program has been executed and output verified successfully.
56
Write a program to store even nos. in a list upto N.
57
Ex.No.: 14
EVEN NOS. IN A LIST UPTO N
Date :
58
59
SOURCE CODE:
print("Program to store even nos. in a list upto N")
N=int(input("Enter a number: "))
EL=[]
for i in range(2,N,2):
EL.append(i)
print("even no. list is",EL)
RESULT:
Thus the python program has been executed and output verified successfully.
60
Write a program to store odd nos. in a list upto N.
61
Ex.No.: 15
ODD NOS. IN A LIST UPTO N
Date :
62
63
SOURCE CODE:
print("Program to store odd nos. in a list upto N")
N=int(input("Enter a number: "))
OL=[]
for i in range(1,N,2):
OL.append(i)
print("odd no. list is",OL)
RESULT:
Thus the python program has been executed and output verified successfully.
64
Write a program to generate nos. from 1 to N and to find sum, average,
product of them.
65
Ex.No.: 16
SUM, AVERAGE, PRODUCT OF NOS. 1 TO N
Date :
66
67
SOURCE CODE:
print("Program to generate nos. from 1 to N and to find sum, average, product of
them")
N=int(input("Enter N: "))
L=[]
for i in range(1,N+1):
item=int(input("Enter the element: "))
L.append(item)
print("List of numbers are",L)
sum=0
length=len(L)
for i in range(length):
sum+=L[i]
print("Sum of list elements",sum)
print("Average is",sum/length)
prod=L[0]
for i in range(1,length):
prod=prod*L[i]
print("Product is",prod)
RESULT:
Thus the python program has been executed and output verified successfully.
68
Write a program to find cube of nos. from 1 to N.
69
Ex.No.: 17
CUBE OF NOS. FROM 1 TO N
Date :
70
71
SOURCE CODE:
print("Program to find cube of nos. from 1 to N")
N=int(input("Enter N: "))
L=[]
for i in range(N): #N=5, i will be 0,1,2,3,4
x=i+1 #x will be 1,2,3,4,5
L.append(x**3)
print(L)
RESULT:
Thus the python program has been executed and output verified successfully.
72
Write a program to find x power n and (x+1) power n.
73
Ex.No.: 18
X POWER N AND (X+1) POWER N
Date :
74
75
SOURCE CODE:
print("Program to find x power n and (x+1) power n")
x=int(input("Enter x: "))
n=int(input("Enter n: "))
print("\nx^nis",x**n)
print("\n(x+1)^n is",(x+1)**n)
RESULT:
Thus the python program has been executed and output verified successfully.
76
Write a program to find two digit nos. from 1 to N.
77
Ex.No.: 19
TWO DIGIT NOS. FROM 1 TO N
Date :
78
79
SOURCE CODE:
print("Program to find two digit nos. from 1 to N")
N=int(input("Enter N: "))
L=[]
for i in range(1,N+1): #N=5, i will be 1,2,3,4,5
L.append(i)
print("List of nos. are",L)
count=0
for i in L:
if i>9 and i<100:
count+=1
if count!=0:
print("\nThereare",count,"TWO digit nos., they are:")
for i in L:
if i>9 and i<100:
print(i,end=' ')
else:
print("\nThere is NO two digit nos. in the list")
RESULT:
Thus the python program has been executed and output verified successfully.
80
Write a program to find compound interest.
81
Ex.No.: 20
COMPOUND INTEREST
Date :
82
83
SOURCE CODE:
print("Program to find A=P*(1+r/100)^n")
P=int(input("Enter P: "))
r=int(input("Enter r: "))
n=int(input("Enter n: "))
A=P*(1+r/100)**n
print("Result is",A)
RESULT:
Thus the python program has been executed and output verified successfully.
84
Write a program to generate even, odd no. list (from m to n) and to find their
sum.
85
Ex.No.: 21
ODD / EVEN LIST WITH SUM
Date :
86
87
SOURCE CODE:
print("Program to generate even, odd no. list (from m to n) and to find their sum")
M=int(input("Enter M: "))
N=int(input("Enter N: "))
if M>N:
print("Numbers cannot be generated")
exit()
EL=[]
OL=[]
for i in range(M,N+1): #i will be having value from M to N
if i%2==0:
EL.append(i)
else:
OL.append(i)
print("Even number list is",EL,"and it has",len(EL),"elements.")
print("Odd number list is",OL,"and it has",len(OL),"elements.")
Esum=0
for i in EL:
Esum=Esum+i
print("Sum of even numbers :",Esum)
Osum=0
for i in OL:
Osum+=i
print("Sum of odd numbers :",Osum)
RESULT:
Thus the python program has been executed and output verified successfully.
88
Write a program to swap two numbers (traditional method).
89
Ex.No.: 22 SWAPPING OF TWO NUMBERS (TRADITIONAL
Date : METHOD)
90
91
SOURCE CODE:
print("Program to swap two numbers (traditional method)")
a=int(input("Enter A: "))
b=int(input("Enter B: "))
print("\nBefore swapping: A =",a,"B =",b)
print("\nSwapping A and B...\n")
t=a
a=b
b=t
print("After swapping: A =",a,"B =",b)
RESULT:
Thus the python program has been executed and output verified successfully.
92
Write a program to swap two numbers (python multiple assignment).
93
Ex.No.: 23 SWAP TWO NUMBERS (PYTHON MULTIPLE
Date : ASSIGNMENT)
94
95
SOURCE CODE:
print("Program to swap two numbers (python multiple assignment)")
a=int(input("Enter A: "))
b=int(input("Enter B: "))
print("\nBefore swapping: A =",a,"B =",b)
print("\nSwapping A and B...\n")
a,b=b,a
print("After swapping: A =",a,"B =",b)
RESULT:
Thus the python program has been executed and output verified successfully.
96
Write a program to find whether the no. is palindrome.
97
Ex.No.: 24
PALINDROME NUMBER
Date :
98
99
SOURCE CODE:
print("Program to find whether the no. is palindrome")
n=int(input("Enter N: "))
num=n
sum=0
while num>0:
rem=num%10
sum=sum*10+rem
num=num//10
print("N =",n,"Reversed number =",sum)
if sum==n:
print(n,"is a palindrome number")
else:
print(n,"is not a palindrome number")
RESULT:
Thus the python program has been executed and output verified successfully.
100
Write a program to find whether the string is palindrome or not.
101
Ex.No.: 25
PALINDROME STRING
Date :
102
103
SOURCE CODE:
print("Program to find whether the string is palindrome or not")
s1=input("Enter the string: ")
s2=s1[::-1]
if s1==s2:
print(s1,"is a palindrome")
else:
print(s1,"is not a palindrome. Reversed string:",s2)
RESULT:
Thus the python program has been executed and output verified successfully.
104
Write a program to merge the float value lists in different ways.
105
Ex.No.: 26
LIST OPERATIONS
Date :
106
107
SOURCE CODE:
print("Program to merge the float value lists in different ways")
L1=list()
L2=[]
M=int(input("Enter the no. of elements for L1: "))
for i in range(M):
item=float(input("Enter the value : "))
L1.append(item)
108
109
print("\nOne element is popped :",L3.pop())
print(L3)
print("\nInserting an element (102) in index-2 i.e., at 3rd position")
L3.insert(2,102)
print(L3)
RESULT:
Thus the python program has been executed and output verified successfully.
110