CS Practical File Class 11 Cbse
CS Practical File Class 11 Cbse
CS Practical File Class 11 Cbse
PRACTICAL FILE
Class: XI
Class/Sec : XI-A
#question 1
j= 0
for i in inp_1:
if i == inp_2:
j += 1
print(inp_1[::-1])S
#question 3
x = inp_1[::-1]
if x == inp_1:
else:
x = inp_1.split()
y = len(x)
x = inp_1.split()
y=0
#taking a counter and checking for each word as per the conditon
for i in x:
if i[0] == 'a':
a += 1
a += 1
else:
continue
print(y)
#question 6
x = inp_1.split()
for i in x:
x = inp_1.split()
#splitting the words and checking for 'the' to replace with 'that'
for i in x:
if i.lower() == "the":
i = "that"
else:
continue
#question 8
cl =
['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','Z']
sl = ['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','z']
num = ['0','1','2','3','4','5','6','7','8','9']
#making lists for different sets for each case and counters
a, b, c = 0, 0, 0
for i in range(len(inp_1)):
if inp_1[i] in cl:
a += 1
b += 1
c += 1
print("Capital Letters",a)
print("Small Letters",b) #displaying the results
print("Numbers",c)
#question 9
cl =
['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','Z']
sl = ['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','z']
#making counters
a=0
b=0
_len = len(inp_1)
for i in range(_len):
if inp_1[i] in cl:
a += 1
b += 1
print("Lowercase",b)
#question 10
cl = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
sl = 'abcdefghijklmnopqrstuvwxyz'
for i in inp_1:
if i in cl:
i = '*'
print(i,end='')
elif i in sl:
i = '@'
print(i,end='')
else:
print(i,end='')
continue
Programs on Python Lists
#question 1
list1 = []
inp_2 = int(input("Enter the values: ")) #taking the values for the list
list1.append(inp_2)
list1.sort()
list1 = []
list1.append(inp_2)
list1.sort()
list1 = []
for i in range(10):
list1.append(inp_1)
a=0
for i in range(10):
a += inp_1
b = a/10
print("Sum is ", a)
print("Mean is ", b)
#question 5
import random
list1 = []
for i in range(10):
list1.append(x)
list2 = []
for j in list1:
if j % 2 != 0:
list2.append(j)
list1 = []
for i in range(inp_1):
list1.append(inp_2)
list2 = []
for j in list1:
print("Corrected List")
print(list2)
#question 7
list1 = []
for i in range(inp_1):
list1.append(inp_2)
list2 = ['']
for j in list1:
if j in list2:
if a == inp_1:
print("Empty List") #if all slots empty then empty list proved otherwise isn't
else:
print("Not Empty")
#question 8
x = []
for i in range(inp_1):
x.append(inp_2)
print(x)
#question9
list1 = []
for i in range(inp_1):
list1.append(inp_2)
list2 = []
for i in list1:
if i > inp_3: #appending new list for items from than the given value
list2.append(i)
print(list2)
#question10
list1 = []
list2 = []
while True:
if x == '1':
else:
while True:
if y == '1':
else:
list3.sort() #sorting it
#question 11
list1 = []
while True:
if x== '1':
print()
print()
'Press 5 to sort',
'Press 6 to reverse',
'Press 7 to display']
for i in options:
print(i)
print()
print()
a = input("")
if a == '1':
if inp_1 in num:
list1.append(f)
else:
list1.remove(inp_2)
elif a == '3':
for i in list1:
list1.remove(i)
list1.remove(list1[0])
elif a == '4':
a=0
for k in list1:
if inp_3 in list1:
a += 1
elif a == '5':
inp_4 = input("Sort in ascending or descending?: ")
if inp_4 == 'ascending':
list1.sort()
else:
list1.sort(reverse = True)
elif a == '6':
list1.reverse()
inp_5 = input("Should the list be displayed?: ") #asking user for display of
data
if inp_5 == 'yes':
print(list1)
else:
continue
elif x == '2':