PROGRAM
PROGRAM
count=0
l=[]
for i in range(n):
l.append(ele)
for i in l:
if i==item:
count=count+1
OUTPUT:
The Frequency of 90 is 2
PROGRAM-2
sum=0
l=[]
for i in range(n):
l.append(ele)
for i in l:
sum=sum+i
mean=sum/n
OUTPUT:
Q.Write a program to accept a character from the user and display whether it is a vowel or
consonant.
if (ch=='a' or ch=='A'):
print(ch,"is a vowel")
print(ch,"is a vowel")
print(ch,"is a vowel")
print(ch,"is a vowel")
print(ch,"is a vowel")
else:
print(ch,"is a consonant")
OUTPUT:
=======================
c is a consonant
a is a vowel
PROGRAM-4
Q.WAP to accept percentage from the user and display the grade .
if perc>90:
print("A")
print("B")
print("C")
elif perc<60:
print("D")
else:
print("Fail")
OUTPUT:
C
PROGRAM-5
l=[1,2,1,2,3,4,5,1,1,2,5,6,7,8,9,9]
uniqueList=[]
duplicateList=[]
for i in l:
if i not in uniqueList:
uniqueList.append(i)
duplicateList.append(i)
print(duplicateList)
OUTPUT:
=======================
[1, 2, 5, 9]
PROGRAM-6
Q.Write a code to calculate and display total marks and percentage of a student from the given list
storing marks of a student.
total=0
l=[]
for i in range(n):
l.append(ele)
for i in l:
total=total+i
perc=(i/total)*100
OUTPUT:
=======================
l=[]
for i in range(n):
l.append(ele)
m=int(n/2)
OUTPUT:
=======================
Q.WAP that reads two numbers and an arithmetic operator and displays the result.
if Op=='+':
print(a+b)
elif Op=='-':
print(a-b)
elif Op=='*':
print(a*b)
elif Op=='/':
print(a/b)
elif Op=='%':
print(a%b)
elif Op=='**':
print(a**b)
else:
print("Invalid Option")
OUTPUT:
=======================
1296.0
PROGRAM-9
Q.WAP to accept the number from the user and print the reverse of that number.
num=int(input("Enter a number:"))
rev_dig=0
while num!=0:
digit=num%10
rev_deg=rev_dig*10+digit
num//=10
OUTPUT:
Enter a number:80
Q. WAP to read alist of elements. Modify this list so that is does not contain any duplicate
elements,i.e.,all elements occuring multiple times in the list should only appear once.
l1=[]
for i in range(n):
l1.append(ele)
l2=[]
for j in l1:
if j not in l2:
l2.append(j)
print(l2)
OUTPUT:
=========================
[2, 3]
=========================
PROGRAM-11
Q.Write a function to display prime numbers below 30.
is_prime=True
for i in range(2,num):
if num%i==0:
is_prime=False
break
if is_prime:
print(num)
OUTPUT:
11
13
17
19
23
29
PROGRAM-12
Q.WAP to multiply an element by 2 if it is odd index for a given list containing both numbers and
strings.
l=[]
for i in range(n):
l.append(ele)
for i in range(len(l)):
if i%2!=0:
l[i]=l[i]*2
OUTPUT:
=======================
The updated list is: [12, 42, 45, 66, 44, 42, 23, 180]