0% found this document useful (0 votes)
17 views

11 Cs Practical Record

The document outlines a computer science practical record book for a student, including their name, class, roll number, teacher, and a table of contents listing programming experiments completed with their date, name, page number, and signature. The experiments include programs to compute powers, interest, check even/odd numbers, find the largest of 3 numbers, check character types, grade percentages, and solve quadratic equations.

Uploaded by

deepa mohanraj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

11 Cs Practical Record

The document outlines a computer science practical record book for a student, including their name, class, roll number, teacher, and a table of contents listing programming experiments completed with their date, name, page number, and signature. The experiments include programs to compute powers, interest, check even/odd numbers, find the largest of 3 numbers, check character types, grade percentages, and solve quadratic equations.

Uploaded by

deepa mohanraj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 42

SAINIK SCHOOL AMARAVATHINAGAR

COMPUTER SCIENCE - PRACTICAL RECORD BOOK


ACADEMIC YEAR : 2023-24

ROLL NO :

NAME :

CLASS : XI SECTION :

HOUSE :

SUBJECT : HANDS ON EXPERIENCE IN


COMPUTER SCIENCE WITH PYTHON

SUB CODE : 083

TEACHER IN-CHARGE : PM JIGAJINNI

1
SAINIK SCHOOL AMARAVATHINAGAR

CERTIFICATE

This is to certify that Cadet…..………………………………………………with

School Roll No…………....has satisfactorily completed the laboratory work (Hands on


Experience) in Computer Science with Python (083) laid down in the regulations of
CBSE for the purpose of AISSCE Practical Examination 2022-23 in Class XI to
be held in Sainik School Amaravathinagar.

(PM Jigajinni)
PGT in Computer Science
Teacher In-charge

Examiners:

1 Name : PM Jigajinni Signature:


(Internal)

2
TABLE OF CONTENTS

S.NO DATE PROGRAM NAME PAGE NO SIGNATURE

1 To Study Computer System & Organization

n
2 WAP to compute x for given two integers
x(base) and n (power).

3 WAP for compute simple and compound


interest.
4 WAP to accept a number from the user and
display whether number is even or odd

5 WAP to input 3 numbers and find the


largest.
6 WAP to check whether a given character is
an alphabet, digit, or special character.
7 WAP to accept percentage marks of a
student and display grade accordingly.
8 WAP to find the roots of a quadratic
2
equation ax + bx + c
9 WAP to find the factorial of a given number

10 WAP to find a given number is prime or


composite.

11 WAP to print Fibonacci series up to certain


limit N.

12 WAP to accept a number and display


whether it is a perfect number or not.

13 WAP to accept a number and display


whether it is a palindrome number or not.

14 WAP to accept a multi-digit number from


user and reverse and print the number.

15 WAP to accept a number, find and display


whether it is a Armstrong number or not.

3
SNO DATE PROGRAM NAME PAGE NO SIGNATURE

16 WAP to display prime numbers up to a


certain limit.
WAP to print the following pattern:
1
17 12
123
1234
12345
WAP to print the sum of the series
18 x0/0!+x1/1!+x2/2!+…….xn/(n)!- exponential
series.
WAP to compute the greatest Common
19 Divisor and Least Common Multiple of two
integers

20 WAP to accept a string and display whether


it is a string palindrome or not.

WAP that counts the number of alphabets,


21 digits, uppercase letters, lowercase letters,
spaces, vowels, consonants and other
characters in the string entered.

22 WAP to display maximum and minimum of


an element in a given list.
WAP to accept a string(a sentence) and
23 returns a string having first letter of each
word in capital letter.

24 WAP in to display those strings which are


starting with ‘A’ in a given list.
WAP to input list of elements and swap the
25 elements in even location with odd
location.

26 WAP to find and display cumulative sum of


elements in a given list.

27 WAP to display frequencies of all the


elements of a list.

4
SNO DATE PROGRAM NAME PAGE NO SIGNATURE

28 WAP to count the frequency of words in a


sentence using a dictionary.

29 WAP to find and display the sum of all the


elements ending with digit 3 in a given list.
WAP to shift the negative number to left
30 and the positive numbers to right in a given
list of numbers

31 WAP to accept values from user and


create a tuple.
WAP to input tuple of elements and search
32
for a given element in the tuple.

33 WAP to find standard deviation and


variance of a tuple of numeric values

34 WAP to generate Random Number within


a given range and store in a list
WAP to create a dictionary containing
35 months as keys and number of days as
values. Display number of days when
user enters name of the month.
WAP to create a dictionary with the roll
number, name and marks of N students
36 in a class and display the names of
students who have scored above 75
marks

5
Experiment - 02
n
WAP to compute x for given two integers x (base) and n (power).
x=int(input("Enter value of base x"))
n=int(input("Enter value of power n"))
result=(x**n)
print(“Result is…”,result)

Output :-
Enter value of base x25
Enter value of power n 2
Result is …625

6
Experiment – 03
WAP to compute simple and compound interest.
p=float(input("Enter the principle amount : "))
t=float(input("Enter time period in years :"))
r=float(input("Enter rate of interest : "))
si=(p*t*r)/100
amt=p * ((1+r/100) ** t)
ci=amt-p
print("Simple interest is…”,si)
print(“Compound interest is…",ci)
Output :-
Enter the principle amount : 5000
Enter time period in years : 2
Enter rate of interest : 5
Simple interest is… 500.0
Compound interest is.. 512.50

7
Experiment – 04
WAP to accept a number from the user and display whether number is
even or odd
x=int(input("Enter number:"))
if (x % 2 == 0) :
print("Given number”, x,”is even")
else:
print("Given number”, x,”is odd")
Output:
Enter number :25
Given number 25 is odd
Enter number: 100
Given number 100 is even

8
Experiment – 05
WAP to input 3 numbers and find the largest.
n1=int(input("Enter number 1 : "))
n2=int(input("Enter number 2 :"))
n3=int(input("Enter number 3 :"))
print(“Given numbers are…”,n1,n2,n3)
if n1 > n2 :
if n1 > n3 :
print("Largest is .....",n1)
else :
print("Largest is .....",n3)
else :
if n2 > n3 :
print("Largest is .....",n2)
else:
print("Largest is .....",n3)
Output:
Enter number 1 : 45
Enter number 2 : 89
Enter number 3 : 59
Given numbers are…45,89,59
Largest is ....89

Enter number 1 :- 89
Enter number 2 :-100
Enter number 3 :-108
Given numbers are… 89,100,108
Largest is ..... 108

9
Experiment – 6
WAP to check whether a given character is an alphabet, digit ,or special
character.
ch=input("Enter a single character : " )
if ch >= "A" and ch <= "Z" :
print("You have entered”,ch,”It is an upper casealphabet")
elif ch >= "a" and ch <= "z" :
print("You have entered”,ch,”It is a lower casealphabet")
elif ch >= "0" and ch <= "9" :
print("You have entered”,ch,”It is a digit")
else:
print("You have entered”,ch,”It is a special character ")

Output :
Enter a single character : M
You have entered M It is an upper case alphabet

Enter a single character : f


You have entered f It is a lower case alphabet

Enter a single character : 6


You have entered 6 It is a digit

Enter a single character : @


You have entered @ It is a Special character

10
Experiment – 7
WAP to accept percentage marks of a student and display grade
accordingly.
perc=float(input("Enter percentage of marks of a student"))
if perc >85 :
print("A Grade ")
elif perc > 70 :
print("B Grade ")
elif perc > 60 :
print("C Grade ")
elif perc > 45 :
print("D Grade ")
else :
print("E Grade ")

Output:
Enter percentage of the student89
A Grade

Enter percentage of the student78


B Grade

Enter percentage of the student65


C Grade

Enter percentage of the student59.5


D Grade

11
Experiment –8
WAP to find the roots of a quadratic equation ax2 + bx + c
import math

print("Equation is ax2 + bx + c = 0")


a=int(input("Enter a : " ))
b=int(input("Enter b :" ))
c=int(input("Enterc :" ))

d=b*b-4*a*c
if a == 0 :
print("Equation is Linear with only one root ")
root = -c/b
print("Root is ",root)

elif d == 0 :
print("Two roots are real and equal ")
root1=root2=-b/(2*a)
print("Root1=",root1,”andRoot2=",root2)

elif d >0 :
print("Two root are real and unequal")
root1=(-b+math.sqrt(d))/(2 * a)
root2=(-b-math.sqrt(d))/(2 * a)
print("Root1=",root1)
print("Root2=",root2)

else:
print("Two roots are imaginary")
d=-d
real1=real2=-b/(2*a)
imag1=imag2==math.sqrt(d)/(2 * a)
print("Root1=",real1,"+i",imag1)
print("Root2=",real2,"-i",imag2)

12
Output:
Equation is ax2 + bx + c = 0
Enter a:0
Enter b: 2
Enter c: 1

Equation is Linear with only one Root


Root is -0.5

Equation is ax2 + bx + c = 0
Enter a: 1
Enter b: 2
Enter c: 1

Two Roots are real and equal


Root1=1.0 and Root2=1.0

Equation is ax2 + bx + c = 0
Enter a : 1
Enter b :9
Enter c :2

Two roots are real and unequal


Root1= -0.2279981273412348
Root2= -8.772001872658766

Equation is ax2 + bx + c = 0
Enter a : 2
Enter b :4
Enter c :16

Two roots are imaginary


Root1= -1.0 +i 2.6457513110645907
Root2= -1.0 -i 2.6457513110645907

13
Experiment –09
WAP to find the factorial of a given number
n=int(input("Enter the Number"))
fact=1
for i in range (1,n+1):
fact=fact * i
print("Factorial of ", n , " is .....",fact)

Output :
Enter the Number5
Factorial of 5 is ..... 120

Enter the Number6


Factorial of 6 is ..... 720

14
Experiment – 10
WAP to find a given number is prime or composite.
n=int(input("Enter value of n:"))
flag=0
if n==0 or n == 1:
print("Neither prime nor composite number")
else:
for i in range (2,n) :
if n % i == 0 :
flag+= 1
break
if flag == 0 :
print("Given number is prime number")
else:
print("Given number is composite number")

Output :

Enter a value of n:1


Neither prime nor composite number

Enter a value of n:0


Neither prime nor composite number

Enter a value of n:2


Given number is prime number

Enter a value of n:6


Given number is composite number

15
Experiment – 11
WAP to print Fibonacci series up to certain limit N.
n=int(input("Enter Value of n : "))
f1=0
f2=1
if n <=1 :
print("Invaild Series")
else:
print(“Fibonacci Series is……”)
print(f1,f2,end=" ")
for i in range(2,n):
f3=f1 + f2
print(f3,end=" " )
f1=f2
f2=f3

Output :
Enter Value of n : 0
Invalid series

Enter Value of n :1
Invalid series

Enter Value of n :10

Fibonacci series is……


0 1 1 2 3 5 8 13 21 34

16
Experiment – 12
WAP to accept a number and display whether it is a perfect number or
not.
n=int(input("Enter value of n:"))
sum=0
for i in range (1,n):
if n % i == 0 :
sum = sum + i
if sum == n :
print("Given number",n,"is perfect number")
else:
print ("Given number",n,"is not perfect number")

Output:

Enter value of n: 5
Given number 5 is not perfect number

Enter value of n : 6
Given number 6 is perfect number

17
Experiment – 13
WAP to accept a number and display whether it is a palindrome
number or not.
num=int(input("Enter any multidigit number"))
rev=0
num1 =num
while num >0 :
rem = num % 10
rev = rev * 10 + rem
num= num // 10
if num1 == rev :
print("Given multidigit number", num1 ," is palindrome")
else:
print("Given multidigit number",num1 , " is not apalindrome ")

Output:
Enter any multidigit number56
Given multidigit number 56 is not a palindrome

Enter any multidigit number121


Given multidigit number 121 is palindrome

18
Experiment – 14
# program to compute the reserve of given number.
n=int(input("Enter tha multidigit number :- "))
m=n
rev=0
while n >0 :
rem = n % 10
rev = rev * 10 + rem
n = n // 10
print(" /n Reverse of " ,m , " is " , rev)

Output :
Enter tha multidigit number :- 25
/n Reverse of 25 is 52

19
Experiment – 15
# program to find the given number is Armstrong number or not.
num=int(input("Enter 3 digit number"))
sum = 0
f = sum
while f >0 :
a = f % 10
sum += sum ** 3
if sum == num :
print(" It is a Armstrong number",num)
else:
print(" It is a Not Armstrong number ",num)

Output :

Enter 3 digit number 153


It is a Armstrong number

Enter 3 digit number 154


It is a Not Armstrong number

20
Experiment – 16
# program to display prime number up to a certain limit.
lower=int(input("Enter lower range " ))
upper=int(input("Enter upper range " ))
if lower > upper :
print("Invail number ")
else :
for num in range (lower ,upper + 1 ) :
if num >1 :
for i in range (2 , num):
if num % i == 0 :
break
else :
print(num ,"is prime number")
Output :-
Enter lower range 10
Enter upper range 50
11 is prime number
13 is prime number
17 is prime number
19 is prime number
23 is prime number
29 is prime number
31 is prime number
37 is prime number
41 is prime number
43 is prime number
47 is prime number

21
Experiment – 17
# program to print the pattern.
n=int(input("Enter the value of n "))
for i in range (1, n + 1 ) :
for j in range(1,i +1 ) :
print(j, end= " " )
print()

output :-
Enter the value of n 5
1
12
123
1234
12345

22
Experiment – 18

WAP to print the sum of the series 1+x1/1!+x2/2!+


…….xn/(n)!exponential series.
x=int(input("Enter value of x : "))
n=int(input("Enter limit:"))
s=0
for i in range (0, n+1) :
fact=1
for k in range (1,i+1) :
fact=fact*k
s+=(x ** i)/fact
print("After term ",i+1,"is",s)
print ("sum of given series is ...",s)

Output :-

Enter value of x : 1
Enter limit:2
After term 1 is 0
After term 2 is 1.0
After term 3 is 2.5
sum of given series is ... 2.5

23
Experiment – 19
WAP to compute the greatest Common Divisor and Least Common
Multiple of two integers
m=int(input("Enter integer value:-"))
n=int(input("Enter integer value:-"))
a,b=m,n
if m <n :
m,n=n,m
rem=m%n
while rem!=0 :
m,n=n,rem
rem=m%n
print("GCD of",a,"and",b,"is=",n)
LCM=(a*b)/n
print("LCM of",a,"and",b,"is=",LCM)

Output :-
Enter integer value2
Enter integer value5
GCD of 2 and 5 is= 1
LCM of 2 and 5 is= 10.0
>>>

Enter integer value:-3


Enter integer value:-9
GCD of 3 and 9 is= 3
LCM of 3 and 9 is= 9.0
>>>

24
Experiment – 20
# program to check the whether string is a palindrome or not.
string=input("Enter stirng")
rev_string = string[: : -1]
if string==rev_string :
print("string is palindrome")
else :
print("string is not palindrome")

Output:-
Enter stirng1221
string is palindrome

Enter stirnggadag
string is palindrome

25
Experiment – 21
# WAP that counts the number of alphabet, digits, uppercase letters,
# lower case letter, spaces Vowels, Consonants and other characters in
# the string entered

str1=input("Enter a string")
NA=ND=NU=NL=NS=NV=NC=NO=0
for ch in str1:
if ch.isalpha () :
NA+=1
if ch.isupper () :
NU+=1
if ch=="A" or ch=="E" or ch=="I" or ch=="o" or ch=="u" :
NV+=1
else:
NC+=1
if ch.islower () :
NL+=1
if ch=="a" or ch=="e" or ch=="i" or ch=="o" or
ch=="u" :
NV+=1
else:
NC+=1
elif ch.isdigit () :
ND+=1
elif ch.isspace () :
NS+=1
else:
NO+=1
print("NO of Alphabet=",NA)
26
print("NO of Upper case letters=",NU,"and Lower Case Letters=",NL)
print("NO of Digits=",ND)
print("NO of Spaces=",NS)
print("NO of Vowels=",NV,"and NO of Consonants=",NC)
print("NO of other Characters=",NO)

Output :-
Enter a string :My name is name and my roll number is 1111 and my
house is house and email is email@!@$%^.com
NO of Alphabet= 64
NO of Upper case letters= 1 and Lower Case Letters= 63
NO of Digits= 4
NO of Spaces= 18
NO of Vowels= 27 and NO of Consonants= 37
NO of other Characters= 7

27
Experiment – 22
# program to display maximum and minimum elements of a given list.
L=eval(input("Enter a list"))
max=L[0]
for i in range(0,len(L)) :
if L[i] >max :
max=L[i]
print("Maximum of the given list is :",max)
min=L[0]
for i in range(0,len(L)):
if L[i] <min :
min=L[i]
print("Minimum of the given listis ",min)

Output :-
Enter a list :12,56,25,45,1,89,78,5
Maximum of the given list is : 89
Minimum of the given listis 1

Enter a list2,56,25,45,1,98,78,5,0
Maximum of the given list is : 98
Minimum of the given listis 0

28
Experiment – 23
# WAP to accept a string(a sentence) and returns a string having first
# letter of each word in capital letter.

str1=input("Enter a string :")


print("original string", str1)
str2=" "
x=str1.split()
for a in x :
str2 += a.capitalize()+" "
print(str2)

Output :-
Enter a string :my name is raj
original string my name is raj
My Name Is Raj

29
Experiment – 24
# WAP in Python to display those strings which are string with ‘A’ of
# given list.

L=["AUSHIM","LEENA","AKHTAR","HIBA","NISHANT","AMAR"]
count=0
for i in L :
if i[0] in ("aA") :
count+=1
print (i)
print("Appearing ",count,"times")
OUTPUT :-
AUSHIM
AKHTAR
AMAR
Appearing 3 times

30
Experiment – 25
WAP to input list of elements and swap the elements in even location
with odd location.

L=[8,23,54,11,99,71,21,55,60,2]
print("The Given list is ",L)
L1=L
print("List before shifting",L1)
for i in range(len(L1)-1):
L1[i],L[i+1]=L1[i+1],L1[i]
print("List after shifting",L1)

OUTPUT :-
The Given list is [8, 23, 54, 11, 99, 71, 21, 55, 60, 2]
List before shifting [8, 23, 54, 11, 99, 71, 21, 55, 60, 2]
List after shifting [23, 54, 11, 99, 71, 21, 55, 60, 2, 8]

31
Experiment – 26
WAP to find and display cumulative sum of elements in a given list.
list=[1,3,5,7,8]
finallist=[list[0]]
for i in range(1,len(list)):
finallist+=[finallist[i-1]+list[i]]
print(finallist)

OUTPUT :-
[1]
[1, 4]
[1, 4, 9]
[1, 4, 9, 16]
[1, 4, 9, 16, 24]

32
Experiment – 27

WAP to display frequencies of all the elements of a list.

L=[3,21,5,6,3,8,21,6]
L1=[ ]
L2=[ ]
for i in L :
if i not in L2 :
x=L.count (i)
L1.append (x)
L2.append (i)
print("Element "," \t\t\t ", " frequency")
for i in range(len(L1)) :
print(L2[ i ] , " \t\t\t " , L1[ i ])

OUTPUT :-

Element frequency
3 2
21 2
5 1
6 2
8 1

33
Experiment – 28
#program to find & display the sum of all the elements ending with 3 in a given list.
L=[33,13,92,99,3,12]
sum=0
x=len(L)
for i in range (0,x) :
if type (L[i])== int :
if L [i] %10==3 :
sum+= L [ i ]
print ("sum of the elements ending with 3 is ...",sum)
OUTPUT :-
33
13
3
sum of the elements ending with 3 is ... 49

34
Experiment – 29
WAP to shift the negative number to left and the positive numbers to
right in a given list
L=[-12,11,-13,-5,6,-3,-6]
n=len(L)
print("original list:",L)
for i in range(n-1):
for j in range(n-i-1):
if L[ j ]<0 :
L[ j ] , L[ j+1] = L[ j + 1] , L[ j ]
print("After shifting list is : " , L )

OUTPUT :-
original list: [-12, 11, -13, -5, 6, -3, -6]
After shifting list is : [11, 6, -6, -3, -5, -13, -12]

35
Experiment – 30
WAP to accept values from user and create a tuple.
t=tuple()
n=int(input("Enter any number : "))
for i in range(n):
a=input("Enter number :" )
t=t+(a,)
print("output is ")
print(t)

OUTPUT:-
Enter any number : 5
Enter number :56
Enter number :58
Enter number :45
Enter number :52
Enter number :12
output is
('56', '58', '45', '52', '12')

36
Experiment – 31
# program to input tuple of elements and search for a given elements in the
tuple.
t=tuple()
n=int(input("Enter number of elements in a tuple"))
for i in range(n) :
ele=int(input("Enter the elements in a tuple"))
t=t+(ele,)
print("Given tuple is ......",t)
x=int(input("Enter the elements to be searched "))
for i in range (n):
if t[i] == x :
print("Elements ", x ,"is found at ",i+1 ,"position ")
break
else:
print("Sorry !The given elements ",x, "is not found in the
tuple ")

OUTPUT :

Enter number of elements in a tuple:4


Enter the elements in a tuple:12
Enter the elements in a tuple:43
Enter the elements in a tuple:56
Enter the elements in a tuple;89
Given tuple is ...... (12, 43, 56, 89)
Enter the elements to be searched: 56
Elements 56 is found at 3 position
37
Experiment – 32
WAP to create a dictionary containing months as keys and number of
days as values. Display number of days when user enters name of the
month.
dict_months={"Jan":31,"Feb":29,"Mar":31,"Apr":30,
"May":31,"Jun":30,"Jul":31,"Aug":31,"Sep":30,
"Oct":31,"Nov":30,"Dec":31}
flag=0
month_name=input("Enter the name of the month ?")
for i in dict_months:
if i == month_name:
print(dict_months[i])
flag=1
if flag == 0 :
print("Invalid Month Name ")

OUTPUT :-

Enter the name of the month ? Jan


31

Enter the name of the month ?adf


Invalid Month Name

38
Experiment – 33
n=int(input("How many students ?" ))
stud={ }
for i in range(1,n+1) :
print("Enter details of students",i)
rollno=int(input("Roll no:"))
name=input("Name:")
marks=float(input("Marks:"))
d={"Roll_no":rollno,"Name":name,"Marks":mark}
key="stud"+str(i)
stud[key]=d
print("Students with marks >75 are:")
for i in range(1,n+1):
key="stud"+str(i)
if stud[key] ["Marks"] >=75 :
print(stud[key])
OUTPUT :-
How many students ? 2
Enter details of students 1
Roll no:1234
Name:sdsf
Marks:100
Enter details of students 2
Roll no:5678
Name:dfgh
Marks:74
Students with marks >75 are:
{'Roll_no': 1234, 'Name': 'sdsf', 'Marks': 100.0}

39
Experiment – 34
WAP to find standard deviation and Variance of a tuple of numeric values
import math
import statistics
t=(10,25,45,42,39)
n=len(t)
total=0
for i in range(n):
total=total+(t[i]-statistics.mean(t))**2
SD=math.sqrt(total)/(n-1)
print("standard deviation",SD)
var=SD**2
print("variation",var)

OUTPUT:-
standard deviation 7.292119033586877
variation 53.175000000000004

40
Experiment – 35
WAP to generate Random Number within a given range & store in a list.
import random
start=int(input("Enter starting Range Value:"))
end=int(input("Enter ending Rangevalue:"))
num=int(input("Enter number of random numbers to be generated:"))
L=[ ]
for i in range (num) :
L.append(random.randint(start,end))
print("The list of random numbers generated
within a given range:")
print(L)

OUTPUT :-
Enter starting Range Value:10
Enter ending Rangevalue:100
Enter number of random numbers to be generated:20
The list of random numbers generated within a given range:
[45, 41, 75, 82, 66, 92, 48, 47, 73, 75, 65, 99, 86, 63, 12, 92, 94, 88, 88, 67]

41
Experiment – 36
WAP to count the frequency of words in a sentence using a dictionary.

sentence=input("Enter Sentence: ")


print(sentence)
words=sentence.split()
d={ }
for one in words:
key=one
if key not in d :
count=words.count(key)
d[key]=count
print("Count frequencies of words in given sentence
\n",d)

OUTPUT :-

Enter Sentence: my name is name and my class is class and house is house
house my name is name and my class is class and house is house house
Count frequencies of words in given sentence
{'my': 2, 'name': 2, 'is': 3, 'and': 2, 'class': 2, 'house':3}

42

You might also like