IMT UNIVERSITY, MEERUT, UTTAR PRADESH
IIMT UNIVERSITY
LAB MANUAL
[2024-25]
SUBMITTED BY: SUBMITTED TO:
NAME: AYUSH GARG Mr. SHASHANK SHARMA
ROLL NO:2366001055
SN INDEX DATE SIGNATURE
1 Write a program of arithmetic operators +,-,*,/,%,**
exponent, // floor division
2 Write a program of comparison /relational operators-
>,<,==,>=,=<
3 Write a program of logical operators- and , or, not
4 Write a program of Assignment operators - = ,
+=,=,*=,/=,**=,//=
5 Write a program of Identity operators - is, is not
6 Write a program of Membership Operators - in , not in
7 Write a program of Bitwise Operators- & and , or ,XOR
8 Write a program to find even or odd number
9 Write a program to class for voting eligible
10 Write a program to find maximum number between two
number
11 Write a program to find maximum number between
three number
12 Write a program to check the is +ve,-ve,0
13 Write a program to find the middle of 3 number of group
14 Write a program to calculate the percentage
15 write a program in python to accept total sale amount
and find the profit @5%
16 WAP in python input sales amount & calculate based on
the given discount rate in python
17 Write a program to swap values of two number
18 write a program in python find the area of rectangle
19 write a program in python find the area of circle
20 write a program in python find the area of square
21 write a program in python find the perimeter of rectangle
22 write a program in python find the perimeter of circle
23 write a program in python find the perimeter of square
24 write a program in python to print no from 1 to 10
25 write a program in python to print no from 10 to 1
26 write a program in python to print no from 2 to 20
27 write a program in python to print no from 1 to n
28 Write a program in python to print no
from n to 1
29 write a program to find the sum of no from 1 to n
30 Write a program to find the sum of
square of no from 1 to n
31 Write a program to find the sum of cube
of no from 1 to n
32 Write a program to print the sum of digit
of entered no
33 write a program to print the product of digit of entered
no
34 write a program to print the sum of square of digit of
entered no
35 write a program to print the sum of cube of digit of
entered no
36 write a program to reverse the entered
no
37 write a program to check whether the no is palindrome
or not
38 write a program to print the factorial of
entered no
39 write a program to print Fibonacci series
40 write a program to print the pattern (1) :- * * *
***
***
41 write a program to print the pattern (2) :-
*
**
***
****
42 write a program to print the pattern (3) :-
*
**
***
43 write a program to print the pattern (4) :-
****
***
**
*
44 write a program to print the pattern (5) :-
****
***
**
*
45 write a program to print the pattern (6) :-
*
**
***
**
*
46 write a program to print the pattern (7) :-
*
***
*****
47 write a program to print the pattern (8) :-
*****
***
*
48 write a program to print the pattern (9) :-
1
2 3
4 5 6
7 8 9 10
49 write a program to print the pattern (10) :-
A
B C
D E F
G H I J
51 write a program to perform string concatination
52 write a program to perform string replication
53 write a program to perform string comparison
54 write a program to print the string from selected index to
selected index .
55 write a program to find the length of a string.
56 write a program to convert a string into upper case.
57 write a program to convert a string into lower case.
58 write a program to convert a string into capitalize.
59 write a program to reverse a string.
60 write a program to print a list.
61 program to change the element of a fixed index in a list.
62 write a program to insert element in the list.
63 write a program to add element into the list at any index.
64 program to delete a element from the list of any index.
65 write a program to pop a element from the list of any
index.
66 write a program to clear the list.
67 write a program to extend the list .
68 write a program to find the maximum and minimum of
the entered list.
69 write a program to print the sum odd and even digit in a
list.
70 write a program to print a list in reverse order
71 program to count the frequency of entered no in a list.
72 write a program to find the total no of odd digit and total
no of even digit.
PROGRAM 1
#Write a program of arithmetic operators +,-,*,/,%,** exponent, // floor division
a=int (input ("enter a first no. ")) b=int (input ("enter a second no. ")) print
(a+b) print (a-b) print (a/b) print (a*b) print (a/b) print (a%b) print (a**b) print
(a//b)
OUTPUT
enter a first no. 8
enter a second no. 7
15
1.1428571428571428
56
1.1428571428571428
2097152
PROGRAM 2
#Write a program of comparision /relational operators- >,<,==,>=,=<
a=int (input ("enter a first no. "))
b=int (input ("enter a second no. "))
if a>b:
print ("a is maximum. ")
else:
print ("b is maximum. ")
OUTPUT
enter a first no. 3
enter a second no. 4
b is maximum.
PROGRAM 3
Write a program of logical operators- and , or, not
a=int (input ("enter a first no. ")) b=int (input
("enter a second no. ")) c=int (input ("enter a
thrid no. "))
if (a>b)or(a>c):
Print ( "a is maximum. ")
elif (b>a) and (b>c) : Priat
("b is maximum. ")
print (" c is maximum. ")
OUTPUT
enter a first no. 4 enter
a second no. 5 enter a
thrid no. 6
c is maximum
PROGRAM 4
#Write a program of Assignment operators - =,+=,-=,*=,/=,**=,//=
a=int(input("enter a first number. ")) b=int(input("enter a second
number. "))
b+=a
print(b)
OUTPUT
enter a first number. 43
enter a second number. 56
99
PROGRAM 5
#Write a program of Identity operators - is, is not a=eval
(input("enter a number. "))
if(type(a) is int):
print(" a is integer. ")
else:
print("a is not integer. ")
OUTPUT
enter a number. 454
a is integer.
PROGRAM 6
#Write a program of Membership Operators - in , not in
a=input("enter a number.") list=["Hello"
,10,"abc",20,30,40,10.6,50]
if (a in list):
print("a are present in in the list ") else:
print("a is not present in this list")
OUTPUT
enter a number.44
a is not present in this list
PROGRAM 7
#Write a program of Bitwise Operators- & and , or ,XOR
a=int(input("enter a first number.")) b=int(input("enter a
second number.")) print(bin(a)) print(bin(b))
print(bin(a&b),a&b)
OUTPUT
enter a first number.54
enter a second number.56
0b110110
0b111000
0b110000 48
PROGRAM 8
#Write a program to find even or odd number
a=int(input("enteer a number")) if(a%2==0):
print("even number")
else: print("odd
number")
OUTPUT
enter a number67 odd
number PROGRAM
'''#Write a program to class for voting eligible
a=int(input("enter the age")) if (a>18):
print("eligible for voting") else:
print("not eligible for voting")
OUTPUT
enter the age13 not
eligible for voting
PROGRAM 10
#Write a program to find maximum number between two number
a=int(input("enter first number")) b=int(input("enter
second number"))
if(a>b):
print("a is maximum")
else:
print("b is maximum")
OUTPUT
enter first number45
enter second number56 b
is maximum
PROGRAM 11
#Write a program to find maximum number between three number
a=int(input("enter first number"))
b=int(input("enter second number"))
c=int(input("enter third number"))
if((a>b) and (a>c)): print("a is
maximum") elif((b>a) and (b>c)):
print("b is maximum")
else:
print("c is maximum")
OUTPUT
enter first number54
enter second number34
enter third number56 c
is maximum
PROGRAM 12
#Write a program to check the is +ve,-ve,0
a=int(input("enter the number")) if(a>0):
print("a is +ve")
elif(a<0):
print("a is -ve")
else: print("a is
zero")
OUTPUT
enter the number56
a is +ve
PROGRAM 13
#Write a program to find the middle of 3 number of group
a=int(input("enter the first number")) b=int(input("enter
the second number")) c=int(input("enter the third
number")) if((a>b) and(a<c) or (a<b) and (a>c)):
print("a is middle number") elif((b>a)
and (b<c) or (b<a) and(b>c)):
print("b is middle number")
else: print("c is middle
number")
OUTPUT
enter the first number56
enter the second number78
enter the third number89 b
is middle number
PROGRAM 14
#Write a program to caluclate the percentage maths=
int(input("enter the marks of maths"))
english=int(input("enter the marks of english"))
hindi=int(input("enter the marks of hindi"))
science=int(input("enter the marks of science"))
sst=int(input("enter the marks of sst")) Total=int(input("enter
the marks of Total"))
percentage=(((maths+english+hindi+science+sst)/Total)*100)
print(percentage) if (percentage>=90): print("grade A")
elif(percentage >=80): print("grade B") elif(percentage
>=70): print("grade C") elif(percentage>=60):
print("grade D") elif(percentage>=50): print("grade E")
elif(percentage >=40): print("grade F") else:
print("Fail")
OUTPUT
enter the marks of maths78
enter the marks of english89
enter the marks of hindi98
enter the marks of science87
enter the marks of sst78
enter the marks of Total500
86.0 grade B
PROGRAM 15
#write a program in python to accept total sale amount and find the profit @5%
total_sale=int(input("enter a total sale amount")) profit=total_sale*5/100
print("profit amount",profit)
OUTPUT
enter a total sale amount79
profit amount 3.95
PROGRAM 16
#WAP in python input sales amount & calculate based on the given discount rate in python
amount discount
0-5000 5%
5000-10000 12%
10,000-20,000 20% 20,000-
25,000 30%
amt=int(input("enter the sale amount"))
if(amt>0 and amt<5000):
discount=amt*5/100 print("discount
amount",discount) print("payable
amount",amt-discount) elif(amt>=5000
and amt<10000):
discount=amt*12/100 print("discount
amount",discount) print("payable
amount",amt-discount)
elif(amt>=10000 and amt<20000):
discount=amt*12/100 print("discount
amount",discount) print("payable
amount",amt-discount)
elif(amt>=20000 and amt<25000):
discount=amt*30/100 print("discount
amount",discount) print("payable
amount",amt-discount) OUTPUT
enter the sale amount7000
discount amount 840.0
payable amount 6160.0
PROGRAM 17
#Write a program to swap values of two number
a=int(input("enter a first number"))
b=int(input("enter a second number"))
print("before swapping",a) print("before
swapping",b)
temp=a a=b
b=temp
print("after swapping ",a)
print("after swapping",b)
OUTPUT
enter a first number67
enter a second number89
before swapping 67
before swapping 89 after
swapping 89 after
swapping 67
PROGRAM 18
#write a program in python find the area of rectangle
length=float(input("enter the length"))
breadth=float(input("enter the breadth")) print(length*breadth)
OUTPUT
enter the length4 enter
the breadth6
24.0
PROGRAM 19
#write a program in python find the area of circle
radius=int(input("enter the radiu")) pi=3.14
print(pi*radius*radius)
OUTPUT
enter the radiu6
113.03999999999999
PROGRAM 20
#write a program in python find the area of square
side=int(input("enter the side")) print(side*side)
OUTPUT
enter the side7
49
PROGRAM 21
#write a program in python find the perimeter of rectangle
length=float(input("enter the length")) breadth=float(input("enter
the breadth")) print(2*(length+breadth))
OUTPUT
enter the length34 enter
the breadth43
154.0
PROGRAM 22
#write a program in python find the perimeter of circle
radius=int(input("enter the radius")) pi=3.14
print(2*pi*radius)
OUTPUT
enter the radius34
213.52
PROGRAM 23
#write a program in python find the perimeter of square
side=int(input("enter the side")) print(4*side)
OUTPUT
enter the side67
268
PROGRAM 24
#write a program in python to print no from 1 to 10
i=1
while(i<=10):
print(i)
i=i+1
OUTPUT
10
PROGRAM 25
#write a program in python to print no from 10 to 1
i=10
while(i>=1):
print(i)
i=i-1
OUTPUT
10
PROGRAM 26
#write a program in python to print no from 2 to 20
i=2
while(i<=20):
print(i)
i=i+2
OUTPUT
10
12
14
16
18
20
PROGRAM 27
#write a program in python to print no from 1 to n
n=int(input("Enter the limit : "))
i=1
while(i<=n):
print(i)
i=i+1
OUTPUT
Enter the limit : 5
PROGRAM 28
#write a program in python to print no from n to 1
n=int(input("Enter the limit : "))
i=n
while(i>=1):
print(i)
i=i-1
OUTPUT
Enter the limit : 5
1
PROGRAM 29
# write a program to find the sum of no from 1 to n
sum=0
n=int(input("Enter the limit : "))
i=1
while(i<=n):
sum=sum+i
i=i+1
print("The sum from 1 to n :",sum)
OUTPUT
Enter the limit : 5
The sum from 1 to n : 15
PROGRAM 30
# write a program to find the sum of square of no from 1 to n
sum=0
n=int(input("Enter the limit : "))
i=1
while(i<=n):
sum=sum+i*i
i=i+1
print("The sum of square of no from 1 to n :",sum)
OUTPUT
Enter the limit : 5
The sum of square of no from 1 to n : 55
PROGRAM 31
# write a program to find the sum of cube of no from 1 to n
sum=0
n=int(input("Enter the no : "))
i=1
while(i<=n):
sum=sum+i*i*i
i=i+1
print("The sum of cube of no from 1 to n :",sum)
OUTPUT
Enter the limit : 5
The sum of cube of no from 1 to n : 225
PROGRAM 32
# write a program to print the sum of digit of entered no
sum=0
n=int(input("Enter the no : "))
while(n>0):
x=n%10
sum=sum+x
n=n//10
print("The sum of digit of entered no :",sum)
OUTPUT
Enter the no : 123
The sum of digit of entered no : 6
PROGRAM 33
# write a program to print the product of digit of entered no
product=1
n=int(input("Enter the no : "))
while(n>0):
x=n%10
product=product*x
n=n//10
print("The sum of digit of entered no :",product)
OUTPUT
Enter the no : 123
The product of digit of entered no : 6
PROGRAM 34
# write a program to print the sum of square of digit of entered no
sum=0
n=int(input("Enter the no : "))
while(n>0):
x=n%10
sum=sum+x**2
n=n//10
print("The sum of digit of entered no :",sum)
OUTPUT
Enter the no : 123
The sum of digit of entered no : 14
PROGRAM 35
# write a program to print the sum of cube of digit of entered no
sum=0
n=int(input("Enter the no : "))
while(n>0):
x=n%10
sum=sum+x**3
n=n//10
print("The sum of digit of entered no :",sum)
OUTPUT
Enter the no : 123
The sum of digit of entered no : 36
PROGRAM 36
# write a program to reverse the entered no
rev=0
i=int(input("enter a no : "))
while(i>0):
r=i%10
rev=rev*10+r
i=i//10
print("Reverse of the entered no is : ",rev)
OUTPUT
enter a no : 134
Reverse of the entered no is : 431
PROGRAM 37
# write a program to check whether the no is palindrome or not
i=int(input("enter a no : "))
a,rev = i,0
while(i>0):
r=i%10
rev=rev*10+r
i=i//10
if(rev==a):
print("Entered no is palindrome ")
else: print("Entered no is not palindrome ")
OUTPUT
enter a no : 121
Entered no is palindrome
PROGRAM 38
# write a program to print the factorial of entered no
a=int(input("Enter a no : "))
fact=1
i=1
while(i<=a):
fact=fact*i
i=i+1
print("Factorial of",a,"is : ",fact)
OUTPUT
Enter a no : 5
Factorial of 5 is : 120
PROGRAM 39
# write a program to print Fibonacci series
n=int(input("Enter a no : "))
a,b,c = 0,1,0
while(c<=n):
print(c)
a,b = b,c
c=a+b
OUTPUT
Enter a no : 5
PROGRAM 40
# write a program to print the pattern (1)
i=1
while(i<=3):
j=1
while(j<=3):
print(" * ",end="")
j=j+1
print(" ")
i=i+1
OUTPUT
* * *
* * *
* * *
PROGRAM 41
# write a program to print the pattern (2)
i=1
while(i<=4):
j=1
while(j<=i):
print(" * ",end="")
j=j+1
print(" ")
i=i+1
OUTPUT
* *
* * *
* * * *
PROGRAM 42
# write a program to print the pattern (3)
i=1
while(i<=4):
j=1
while(j<=4):
if j<=4-i:
print(" ",end=" ")
else:
print("*",end=" ")
j=j+1
print(" ")
i=i+1
OUTPUT
* *
* * *
* * * *
PROGRAM 43
# write a program to print the pattern (4)
i=4
while(i>=1):
j=1
while(j<=i):
print(" * ",end="")
j=j+1
print(" ")
i=i-1
OUTPUT
* * * *
* * *
* *
PROGRAM 44
# write a program to print the pattern (5)
n=4
i=n
while i > 0:
if i > 0:
print(" " * (n - i) + "*" * i)
else:
print()
i -= 1
OUTPUT
****
***
**
PROGRAM 45
# write a program to print the pattern (6)
i=1
while(i<=3):
j=1
while(j<=i):
print(" * ",end="")
j=j+1
print(" ")
i=i+1
i=2
while(i>=1):
j=1
while(j<=i):
print(" * ",end="")
j=j+1
print(" ")
i=i-1
OUTPUT
* *
* * *
* *
PROGRAM 46
# write a program to print the pattern (7)
for i in range (1,4):
for k in range (1,4-i):
print(" ",end=" ")
for j in range (1,(2*i-1)+1):
print("*",end=" ")
print(" ")
OUTPUT
***
*****
PROGRAM 47
# write a program to print the pattern (8)
for i in range (3,0,-1):
for k in range (1,4-i):
print(" ",end=" ")
for j in range (1,(2*i-1)+1):
print("*",end=" ")
print(" ")
OUTPUT
*****
***
PROGRAM 48
# write a program to print the pattern (9)
sum=0
row_no=int(input("enter a no : "))
for row in range(1,row_no+1):
for column in range(1,row+1):
sum=sum+1
print(format ( sum ),end=" ")
print()
OUTPUT
enter a no : 4
1
23
456
7 8 9 10
PROGRAM 49
# write a program to print the pattern (10)
ch=64
row_no=int(input("enter a no : "))
for row in range(1,row_no+1):
for column in range(1,row+1):
ch=ch+1
print(chr ( ch ),end=" ")
print()
OUTPUT
enter a no : 4
A
BC
DEF
GHIJ
PROGRAM 50
# write a program to print the pattern (11)
ch=64
row_no=int(input("enter a no : "))
for row in range(1,row_no+1):
for column in range(1,row+1):
ch=ch+1
print(chr ( ch ),end=" ")
print()
for row in range(row_no+1,0,-1):
for column in range(1,row-1):
ch=ch+1
print(chr ( ch ),end=" ")
print()
OUTPUT
enter a no : 5
A
B C
D E F
G H I J
K L M N O
P Q R S
T U V
W X
Y
PROGRAM 51
# write a program to perform string concatination
name1 = "AYUSH "
name2 = "GARG"
print(name1 + name2)
OUTPUT
AYUSH GARG
PROGRAM 52
#write a progam to perform string replication.
name = "PYTHON "
print (5*name)
OUTPUT
PYTHON PYTHON PYTHON PYTHON PYTHON
PROGRAM 53
#write a progam to perform string comparison
name1 = "AYUSH "
name2 = "GARG"
if(name1==name2):
print("same")
else:
print("different")
OUTPUT
different
PROGRAM 54
#write a program to print the string from selected index to selected index .
a=(input (" enter a string : "))
print(a[1:4])
OUTPUT
enter a string : hero honda
selected string is : ero
PROGRAM 55
#write a program to find the length of a string.
a=(input ("enter a string : "))
print( "length of string is : ",len(a))
OUTPUT
enter a string : hello how are you
length of string is : 17
PROGRAM 56
#write a program to convert a string into upper case.
a=(input ("enter a string : "))
print( "upper case of string is : ",a.upper())
OUTPUT
enter a string : hEllO HoW arE YOu
upper case of string is : HELLO HOW ARE YOU
PROGRAM 57
#write a program to convert a string into lower case.
a=(input ("enter a string : "))
print( "upper case of string is : ",a.lower())
OUTPUT
enter a string : hEllO HoW arE YOu
upper case of string is : hello how are you
PROGRAM 58
#write a program to convert a string into capitalize.
a=(input ("enter a string : "))
print( "upper case of string is : ",a.capitalize())
OUTPUT
enter a string : hEllO HoW arE YOu
upper case of string is : Hello how are you
PROGRAM 59
#write a program to reverse a string.
a=(input ("enter a string : "))
print( "reverse of string is : ",a[::-1])
OUTPUT
enter a string : hero honda
reverse of string is : adnoh oreh
]PROGRAM 60
#write a program to print a list.
a=[1,53,32,"hello",23]
print(a)
OUTPUT
[1, 53, 32, 'hello', 23]
PROGRAM 61
#write a program to change the element of a fixed index in a list.
a=[1,53,32,"hello",23]
a[1]=222
print(a)
OUTPUT
[1, 222, 32, 'hello', 23]
PROGRAM 62
#write a program to insert element in the list.
a=[]
i=1
x=int(input("enter the size of the list : "))
while i <= x:
value=int(input("enter the element : "))
a.append(value)
i=i+1
print(a)
OUTPUT
enter the size of the list : 3
enter the element : 1
enter the element : 22
enter the element : 3
[1, 22, 3]
PROGRAM 63
# write a program to add element into the list at any index.
a=[]
i=1
x=int(input("enter the size of the list : "))
while i <= x:
value=int(input("enter the element : "))
a.append(value)
i=i+1
print("The entered element of the list is : ",a)
y=int(input("enter the index where you want to insert the element : "))
element=input("enter the element which you want to insert : ")
a.insert(y,element)
print("The new list after insertion is : ",a)
OUTPUT
enter the size of the list : 3
enter the element : 1
enter the element : 2
enter the element : 3
The entered element of the list is : [1, 2, 3]
enter the index where you want to insert the element : 1
enter the element which you want to insert : abc
The new list after insertion is : [1, 'abc', 2, 3]
PROGRAM 64
# write a program to delete a element from the list of any index.
a=[]
i=1
x=int(input("enter the size of the list : "))
while i <= x:
value=int(input("enter the element : "))
a.append(value)
i=i+1
print("The entered element of the list is : ",a)
y=int(input("enter the index no : "))
del a[y]
print("List after the deletion of an element : ",a)
OUTPUT
enter the size of the list : 3
enter the element : 1
enter the element : 5
enter the element : 3
The entered element of the list is : [1, 5, 3]
enter the index no : 0
List after the deletion of an element : [5, 3]
PROGRAM 65
# write a program to pop a element from the list of any index.
a=[]
i=1
x=int(input("enter the size of the list : "))
while i <= x:
value=int(input("enter the element : "))
a.append(value)
i=i+1
print("The entered element of the list is : ",a)
y=int(input("enter the index no : "))
a.pop(y)
print("List after pop an element : ",a)
OUTPUT
enter the size of the list : 3
enter the element : 2
enter the element : 5
enter the element : 3
The entered element of the list is : [2, 5, 3]
enter the index no : 2
List after pop an element : [2, 5]
PROGRAM 66
#write a program to clear the list.
a=[]
i=1
x=int(input("enter the size of the list : "))
while i <= x:
value=int(input("enter the element : "))
a.append(value)
i=i+1
print("The entered element of the list is : ",a)
y=(input("YOU WANT TO CLEAR THE LIST: "))
yes="yes"
if(y=="yes"):
a.clear()
print("your list is now clear :",a)
else:
print("List is not clear ",a)
OUTPUT
enter the size of the list : 3
enter the element : 21
enter the element : 54
enter the element : 23
The entered element of the list is : [21, 54, 23]
YOU WANT TO CLEAR THE LIST: yes
your list is now clear : []
PROGRAM 67
# write a program to extend the list .
a=[]
b=[]
i=1
x=int(input("enter the size of the first list : "))
while i <= x:
value=(input("enter the element for first list: "))
a.append(value)
i=i+1
i=1
y=int(input("enter the size of the second list : "))
while i <= y:
valu=(input("enter the element for second list : "))
b.append(valu)
i=i+1
a.extend(b)
print("now your list is : ",a)
OUTPUT
enter the size of the first list : 3
enter the element for first list: 12
enter the element for first list: abc
enter the element for first list: iimt
enter the size of the second list : 4
enter the element for second list : helo
enter the element for second list : 12
enter the element for second list : 43
enter the element for second list : yo
now your list is : ['12', 'abc', 'iimt', 'helo', '12', '43', 'yo']
PROGRAM 68
#write a program to find the maximum and minimum of the entered list.
a=[]
y=int(input("enter the size of the list : "))
i=1
while i <= y:
value=(input("enter the element for list : "))
a.append(value)
i=i+1
print("maximum : ",max(a))
print("minimum : ",min(a))
OUTPUT
maximum : 32
minimum : 12
PROGRAM 69
# write a program to print the sum odd and even digit in a list.
even=0
odd=0
a=[]
y=int(input("enter the size of the list : "))
i=1
while (i <= y):
val=int(input("enter the element for list : "))
a.append(val)
if(val % 2 == 0):
even=even+val
else:
odd=odd+val
i=i+1
print("sum of odd : ",odd)
print("sum of even : ",even)
OUTPUT
enter the size of the list : 5
enter the element for list : 21
enter the element for list : 12
enter the element for list : 43
enter the element for list : 2
enter the element for list : 1
sum of odd : 65
sum of even : 14
PROGRAM 70
#write a program to print a list in reverse order
a=[]
y=int(input("enter the size of the list : "))
i=1
while (i <= y):
val=int(input("enter the element for list : "))
a.append(val)
i=i+1
print("list = ",a)
print("list in reverse order = ",a[::-1])
OUTPUT
enter the size of the list : 3
enter the element for list : 21
enter the element for list : 434
enter the element for list : 2
list = [21, 434, 2]
list in reverse order = [2, 434, 21]
PROGRAM 71
# write a program to count the frequency of entered no in a list.
f=0
a=[]
n=int(input("enter the no : "))
y=int(input("enter the size of the list : "))
i=1
while (i <= y):
val=int(input("enter the element for list : "))
a.append(val)
i=i+1
if(n==val):
f=f+1
print(f"The frequency of entered no {n} : ",f)
OUTPUT
enter the no : 23
enter the size of the list : 4
enter the element for list : 23
enter the element for list : 42
enter the element for list : 23
enter the element for list : 23
The frequency of entered no 23 : 3
PROGRAM 72
# write a program to find the total no of odd digit and total no of even digit.
o=0
e=0
a=[]
y=int(input("enter the size of the list : "))
i=1
while (i <= y):
val=int(input("enter the element for list : "))
a.append(val)
i=i+1
if(val%2==0):
e=e+1
else:
o=o+1
print(f"Total even digits : {e}\nTotal odd digits : {o}")
OUTPUT
enter the size of the list : 5
enter the element for list : 2
enter the element for list : 4
enter the element for list : 31
enter the element for list : 3
enter the element for list : 44
Total even digits : 3
Total odd digits : 2