ANKIT CHAUHAN PRACTICAL FILE -6
ANKIT CHAUHAN PRACTICAL FILE -6
Sec-7,Rohini(1413074)
Computer Science
Practical File
Class-XI
(2024-25)
INDEX
S Practical Title Teacher's
No Signature
3 Write a python program to check if the minimum element of a tuple lies at the
middle position of the tuple.
9 Write a program to find the frequency of all elements of a list. Also print the list
of unique elements in the list and duplicate elements in the given list.
10 Write a program to create a dictionary with the roll number,name and marks of
a student in a class and display the name of students who have marks above
75 .
14 Write a python program to display the terms of a Fibonacci series till 100.
15 Write a python program to compute the greatest common divisor and least
common multiple of two Integers.
18 Input a list of numbers and swap elements at the even location with the
elements at the odd location.
PROGRAM 6
Write a python program to input a string and determine whether it is a
palindrome or not; convert the case of characters in a string.
string=input("Enter string:")
if(string==string[::-1]):
print("The string is a palindrome")
else:
print("The string isn't a palindrome")
case= string.swapcase()
print("change case of string", case)
PROGRAM 7
Input a list/tuple of elements, search for a given element in the list/tuple.
a=eval(input("enter the input="))
length =len(a)
element= int(input(" enter the element to be searched for ="))
for i in range(0, length):
if element== a[i]:
print("element is found at index", i)
break
else:
(" element is not found at index", i )
PROGRAM 8
write a program to find the largest/smallest number.
list=eval(input("Enter a list"))
print("the list is:",list)
mx=max(list)
mn=min(list)
print("maximum number in the list:",mx)
print("minimum number in the list:",mn)
PROGRAM 9
Write a program to find the frequency of all elements of a list. Also
print the list of unique elements in the list and duplicate elements in
the given list.
list=eval(input("Enter list:"))
length=len(list)
unique=[]
dup1=[]
count=i=0
while i<length:
element=list[i]
count=1 #count as 1 for the elements at list[i]
if element not in unique and element not in dup1:
i+=1
for j in range(i,length):
if element==list[j]:
count+=1
else:
print("element",element,"frequency",count)
if count==1:
unique.append(element) #when element is found in unique or dup1
list
else:
dup1.append(element)
else:
i+=1
print("Original list",list)
print("unique element",unique)
print("Duplicates elements list",dup1)
PROGRAM 10
Write a program to create a dictionary with the roll number,name and
marks of a student in a class and display the name of students who
have marks above 75 .
PROGRAM 12
Write a program to input the value of x and n and print the sum of the following
series:
(a)1+x+x^2+x^3+x^4+ ..................x^n
(b)1-x+x^2-x^3+x^4 -.....................x^n
PROGRAM 13
Input a number and check if the number is a prime or composite number.
PROGRAM 14
Write a python program to display the terms of a Fibonacci series till 100.
next=first+second
print(next,end=",")
first= second
second= next
PROGRAM 15
Write a python program to compute the greatest common divisor and least
common multiple of two
Integers.
PROGRAM 16
Write a python program to implement a simple calculator for two input numbers.
Offer choices through a Menu.
print("calculator")
print("enter two numbers below")
n1=float(input("enter first no:"))
n2=float(input("enter second no:"))
cm=0
while cm<5:
print("calculator menu:")
print("1.add")
print("2.subtract")
print("3.multiply")
print("4.divide")
print("5.exit")
cm=int(input("Enter choices(1-5):"))
if cm==1:
print("sum:",n1+n2)
elif cm==2:
print("difference:",n1-n2)
elif cm==3:
print("product:",n1*n2)
elif cm==4:
print("quotient",n1/n2)
elif cm==5:
break
else:
print("invalid choice")
PROGRAM 17
Write a python program that removes all capitalization and common punctuation
from a string.
punctuation= ".!@#$%^&*_-+={}[]\|:;'?/>,<"
s= input("enter the string:")
no_punct =""
for i in s:
if i not in punctuation:
no_punct = no_punct+i
print(no_punct.lower())
PROGRAM 18
Input a list of numbers and swap elements at the even location with the elements
at the odd location.
val=eval(input("Enter a list:"))
print("original list:",val)
ln=len(val)
if ln%2 !=0:
ln=ln-1
for i in range(0,ln,2):
print(i,i+2)
val[i],val[i+1]=val[i+1],val[i]
print("list after swapping:",val)
PROGRAM 19
Write a python program to create a third dictionary from two dictionaries having
some common keys, in such a way so that the values of common keys are added
in the third dictionary.
d1={'s':205,'a':108,'k':117}
d2={'a':234,'h':20,'k':450}
dict3=dict(d1)
dict3.update(d2)
for i,j in d1.items():
for x,y in d2.items():
if i==x:
dict3[i]=(j+y)
print("Two given dictionaries are: ")
print(d1)
print(d2)
print("The resultant dictionary :")
print(dict3)
PROGRAM 20
Program to obtain three numbers and print their sum.