Modified 11th CBSE CS Practical
Modified 11th CBSE CS Practical
10. Input a string and determine whether it is a palinrome or not convert the case of
characters in a string.
print("Input a string and determine whether it is a palindrome or not;\n")
print("convert the case of characters in a string.\n")
string=input(("Enter a string:"))
if (string==string[::-1]):
print("The string is a palindrome")
else:
print("Not a palindrome")
print("String after converting the case:",string.swapcase())
12. Input a list of numbers and swap elements at the even location with the elements at
the odd location.
lst=[]
num=int(input('How many numbers:'))
for n in range(num):
numbers=int(input('Enternumber'))
lst.append(numbers)
print("List before swaping:",lst)
for i in range(0,num,2):
temp1=lst[i]
temp2=lst[i+1]
lst[i]=temp2
lst[i+1]=temp1
print("List after swaping:",lst)
13. Input a list/tuple of elements, search for a given element in the list/tuple.
print("Program to input a list/tuple of elements, search for a given element in the list/tuple")
list=[]
num=int(input("How many numbers in the list:"))
for n in range(num):
numbers=int(input("Enter number"))
list.append(numbers)
print("the entered list is",list)
length = len(list)
element=int(input("Enter the element to be searched for:"))
for i in range(0,length):
if element==list[i]:
print(element,"found at index",i,"and position:",i+1)
break
else:
print(element," is not found!!!")
14. Input a list/tuple of numbers and find the smallest and largest number from the list.
mylist=[20,100,20,1,10]
mylist.sort()
print(mylist)
print("smallest element is :",mylist[0])
print("largest element is :",mylist[-1])
15. Create a dictionary with the roll number, name and marks of n students in a class
and display the names of students who have scored marks above 75.
print("create a dictionary with the roll number, name and marks of n students in a class and \n")
print("display the names of students who have scored marks above 75")
result={}
n= int(input("enter number of students:"))
for i in range(n):
print("enter details of students no.",i+1)
rno=int(input("roll no:"))
name=input("name:")
marks=int(input("marks:"))
result[rno]=[name,marks]
print(result)