CS Practical File
CS Practical File
EDUCATION
UNIVERSAL CONVENT SEN. SECONDARY SCHOOL
HALDWANI(NAINITAL)
SESSION – 2023-2024
CLASS: XI ‘A’
ROLL NO. : 3
ACKNOWLEDGEMENT
Anubhav Kiroula.
CERTIFICATE
This is to certify that Anubhav kiroula , student of Class
XI, Universal Convent Senior Secondary School
Haldwani(Nainital) has completed the PRACTICAL FILE
during the academic year 2023-2024 towards partial
fulfillment of credit for the Computer Science practical
evaluation of CBSE and submitted satisfactory report,
as compiled in the following pages, under my
supervision.
Total number of practical certified are: 25
Examiner Signature:-
CONTENT
#Printing Message
print(wl_msg)
2.Write a python program to input two numbers and display the larger / smaller number.
#Taking input
#Checking Larger
if n1>n2:
print(n1," is larger.")
elif n2>n1:
print(n2," is larger")
else:
#Checking Smaller
if n1<n2:
print(n1," is smaller.")
elif n2<n1:
print(n2," is smaller")
else:
#Checking Largest
print(n1," is largest.")
print(n2," is largest")
print(n3," is largest")
else:
#Checking Smallest
print(n1," is smallest.")
print(n2," is smallest")
print(n3," is smallest")
else:
for i in range(1,6):
for j in range(1,i+1):
print("*",end=" ")
print()
for i in range(6,1,-1):
for j in range(1,i):
print(j,end=" ")
print()
for j in range(65,i+1):
print(chr(j),end="")
print()
5. Write a program to input the value of x and n and print the sum of the following series:
a. 1 + x² + x³ + ... + xⁿ
s=0
#Series 1
s += x**i
if i<n:
print(x**i,"+",end=" ")
else:
print(x**i,end=" ")
print ("=", s)
#Series 2
sum = 0
m=1
for i in range(1, 7) :
f=1
f *= j
t = x ** i / f
if i==1:
print(int(t),end=" ")
elif i%2==0:
print("-",int(t),end=" ")
else:
print("+",int(t),end=" ")
sum += t * m
m = m * -1
Series 1:
Series 2:
temp = n
cnt=0
rev=0
for i in range(1,n):
if n%i==0:
cnt+=i
if cnt==n:
else:
digit = temp % 10
cnt += digit ** 3
temp //= 10 # Armstrong number is a number that is equal to the sum of cubes of
its digits
if n == cnt:
else:
dig = n % 10
rev = rev * 10 + dig #This loop calculates the reverse and matches it with input
n = n // 10
if temp == rev:
else:
if n>1:
for i in range(2,n):
if n%i==0:
f=1
break
else:
f=0
else:
if f==1:
else:
n1, n2 = 0, 1
count = 0
if nterms <= 0:
elif nterms == 1:
print(n1, end=” ”)
else:
print("Fibonacci sequence:")
print(n1)
nth = n1 + n2
# update values
n1 = n2
n2 = nth
count += 1
9. Write a python program to compute the greatest common divisor and
least common multiple of two integers.
gcd = 1
gcd = i
# Displaying GCD
# Calculating LCM
10. Write a program to count and display the number of vowels, consonants,
uppercase, lowercase characters in string.
v = c = uc = lc = 0
v_list = ['a','e','i','o','u']
for i in txt:
if i in v_list:
v += 1
if i not in v_list:
c += 1
if i.isupper():
uc += 1
if i.islower():
lc += 1
11. Write a menu driven program for list manipulation. Display menu as:
1. Add a record
2. View record
3. Delete Record
4. Modify record
5. Exit
l=[]
while True:
2. View record
3. Delete Record
4. Modify record
5. Exit''')
if ch==1:
l.append(v)
print("Record Added...")
elif ch==2:
print(l)
elif ch==3:
l.remove(n)
print("Record Deleted...")
elif ch==4:
l[i]=nv
print("Record Modified...")
break
1. Add record:
2. View Record:
3. Delete Record:
4. Modify Record:
5. Exit:
12. Write a menu drive program to the following from the list:
1. Maximum
2. Minimum
3. Sum
4. Sort in Ascending
5. Sort in Descending
6. Exit
l=[11,32,5,43,22,98,67,44]
while True:
print('''
1. Maximum
2. Minimum
3. Sum
4. Sorting (Ascending)
5. Sorting (Descending)
6. Exit
''')
if ch==1:
print("Maximum:",max(l))
elif ch==2:
print("Minimum:",min(l))
elif ch==3:
print("Sum:",sum(l))
elif ch==4:
l.sort()
print("Sorted list(Ascending):",l)
elif ch==5:
l.sort(reverse=True)
print("Sorted List(Descending:)",l)
elif ch==6:
break
Maximum:
Minimum:
Sum:
Sort (Ascending):
Sort(Descending):
Exit:
13. Write a program to input a list of numbers and swap elements at the
even location with the elements at the odd location.
s=len(l)
if s%2!=0:
s=s-1
for i in range(0,s,2):
l[i],l[i+1]=l[i+1],l[i]
14. Write a program to input a list of number and interchange first element
to last element.
t=l[0]
l[0]=l[-1]
l[-1]=t
print(l)
15. Write a program to create a tuple with user input and search for given
element.
if n in t:
print("Found:",n)
else:
16. Write a program to create tuple with user input and display the square of
numbers divisible by 3 and display cube of numbers divisible by 5.
for i in t:
if i%3==0:
print(i**2,end=' ')
if i%5==0:
print(i**3,end=' ')
17. Write a menu driven program to do the following using a
dictionary.
1. Display Contacts
2. Add Contact
3. Delete a Contact
5. Search Contact
6. Exit
d={}
while True:
print('''
1. Display Contacts
2. Add Contact
3. Delete a Contact
5. Search Contact
6. Exit
''')
if ch==1:
print("Saved Contacts.......")
for i in d:
print('----------------')
print("Name:",i)
print("Phone.No:",d[i])
print('----------------')
elif ch==2:
name=input("Enter Name:")
#d[name]=ph
d.setdefault(name,ph)
print("Contact Saved...")
elif ch==3:
#d.pop(n)
#d.popitem()
#del d[n]
d.clear()
print("Contact Deleted...")
elif ch==4:
d[n]=new_ph
print("Contact Saved...")
elif ch==5:
print("Search Contact")
if n in d:
print("Record Found...",d[n])
else:
elif ch==6:
break
Main Menu:
1. Display Contacts:
2. Add Contact:
3. Delete a contact:
4. Change a phone number:
5. Search a contact:
6. Exit:
18. Write a program to 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.
d={1:['Rudra',99],2:['Rushi',98],
3:['Prakash',65],4:['Jay',84]}
for i in d:
if d[i][1]>75:
• Total Sales 1K to 2K – 5%
'Preet':[650,987,123],'Jay':[284,456,321]}
bonus=0
for i in d:
d[i]=sum(d[i])
for i in d:
if d[i]<1000:
d[i]=0
d[i]=d[i]*0.05
d[i]=d[i]*0.08
d[i]=d[i]*0.1
elif d[i]>=4001:
d[i]=d[i]*0.12
for i in d:
print(i,"\t: %.2f"%d[i])
20. Write a program to enter a team name, wins and losses of a team.
Store them into a dictionary where teams names are key, wins and
losses are values stored as a list. Do the following based on the
dictionary created above:
l_win = []
l_rec = []
while True :
if t_name in 'Qq' :
print()
break
else :
l_win += [ win ]
if win > 0 :
l_rec += [ t_name ]
Ans:
Ans:
2. Write SQL queries for (i) to (iv) and find outputs for SQL queries (v)
to (viii) which are based on tables.
Ans:
3. Consider the following tables EMP and SALGRADE, write the query
for (i) to (vi) and output for (vii) to (x).
Ans:
4. In a database there are two tables : Write MYSQL queries for (i) to
(iii).
Ans:-
5. Considering the VISITOR table data, write the query for (i) to (iv)
and outputs for (v) to (viii).
Ans:-
********