0% found this document useful (0 votes)
99 views22 pages

Practical File - Xi 2024-25

This document is a practical file for Class XI Computer Science at PM SHRI KENDRIYA VIDYALAYA, detailing various programming exercises completed by a student named Souvik Gope. It includes a certificate of completion, acknowledgments, and multiple Python programs demonstrating basic programming concepts such as input/output, conditionals, loops, and data structures. The programs cover tasks like finding the largest number, checking for palindromes, and creating and manipulating lists and dictionaries.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
99 views22 pages

Practical File - Xi 2024-25

This document is a practical file for Class XI Computer Science at PM SHRI KENDRIYA VIDYALAYA, detailing various programming exercises completed by a student named Souvik Gope. It includes a certificate of completion, acknowledgments, and multiple Python programs demonstrating basic programming concepts such as input/output, conditionals, loops, and data structures. The programs cover tasks like finding the largest number, checking for palindromes, and creating and manipulating lists and dictionaries.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 22

CLASS-XI

COMPUTER SCIENCE (083)


PRACTICAL FILE-2024-25

PM SHRI KENDRIYA VIDYALAYA


NEW ALIPURDUAR JN

SUBMITTED BY:
Roll No:……………….
Name:
Date:………………….

 Signature of Internal Examiner:

 Signature of Principal:

1
CERTIFICATE
This is to certify that SOUVIK GOPE of class: XI B of
PM SHRI KENDRIYA VIDYALAYA ALIPURDUAR
has done his project & PracticalUnder my supervision. He
has taken interest and has shown at most sincerity in
completion of this project & Practical. I certify this project
up to my expectation & as per guidelines issued by CBSE,
NEW DELHI.

INTERNAL EXAMINER PRINCIPAL

2
ACKNOWLEDGMENT
It is with pleasure that I acknowledge my sincere gratitude to
our teacher, MR. ACHYUT who taught and undertook the
responsibility of teaching the subject computer science. I have
been greatly benefited from his classes. I am especially
indebted to our Principal MR. SATISH Kr. JHA who has
always been a source of encouragement and support and
without whose inspiration this project would not have been a
successful I would like to place on record heartfelt thanks to
him. Finally, I would like to express my sincere appreciation
for all the other students in my batch their friend & the fine
time that we all shared together.

STUDENT’S SIGN
PRINCIPAL SIGN

3
Program.1: Input a welcome message and display it.
Sol:
str=input("Enter a Welcome message")
print(str)

Program 2: Input two numbers and display the


larger / smaller number.
Sol:

n1=int(input("Enter first Number"))


n2=int(input("Enter Second Number"))
if n1>n2:
print("Larger is:",n1)
else:
print("Larger is:",n2)

4
Program 3: Input three numbers and display the
largest number.
Sol:
n1=int(input("Enter first Number"))
n2=int(input("Enter Second Number"))
n3=int(input("Enter Third Number"))

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)

Program 4: Given two integers x and n, compute 𝑥n.


5
Sol:
x=int(input("Enter value for x"))
n=int(input("Enter value for n"))
val=1
i=1
while i<=n:
val=val*x
i=i+1

print("n raise to the power of x=", val)

Program 5: Write a program to input the value of x


and n and print the sum of the following series:

6
S=1+x+x2+x3+x4+x5+……..xn

Sol: x=int(input("Enter value for x"))


n=int(input("Enter value for n"))
s=1
i=1
while i<=n:
s=s+x**i
i=i+1
print("The sum of the series is:",s)

Program 6: Write a program to input the value of x


and n and print the sum of the following series:
S=1-x+x2-x3+x4-x5+……..xn

7
sol:

x=int(input("Enter value for x"))


n=int(input("Enter value for n"))
s=1
i=1
while i<=n:
if i%2==0:
s=s+x**i
else:
s=s-x**i

i=i+1
print("The sum of the series is:",s)

Program 7:Write a program to enter a number and


print whether it is Palindrome Number or not?

8
Sol:

n=int(input("Enter a Number"))
m=n
s=0
while n>0:
r=n%10
s=s*10+r
n=n//10

if s==m:
print("Palindrome")
else:
print("Not Palindrome")

Program 8: Write a program to enter a number and


print whether it is Armstrong Number or not?

Sol:

9
n=int(input("Enter a Number"))
m=n
s=0
while n>0:
r=n%10
s=s+r*r*r
n=n//10

if s==m:
print("Armstrong")
else:
print("Not Armstrong")

Program 9: Write a program to enter a number and


print whether it is Prime Number or not?

Sol:
n=int(input("Enter a Number"))

10
i=2
while i<n:
if n%i==0:
break
i=i+1
if i==n:
print("Prime")
else:
print("Not Prime")

Program 10: Write a program to enter a number and


print whether it is Perfect Number or not?
Sol:

n=int(input("Enter a Number"))
sum=0

11
for i in range(1,n):
if n%i==0:
sum=sum+i

if sum==n:
print("Perfect")
else:
print("Not Perfect")

Program 11: Write a program to print Fibonacci


sequence.
Sol:

nterms=int(input("How many terms?"))


n1,n2=0,1

12
count=0
while count<nterms:
print(n1)
nth=n1+n2
n1=n2
n2=nth
count+=1

Program 12: Write a program to enter a string and


count total vowels and consonants in it.
Sol:

str=input("Enter the string")


vowel=0
con=0
13
for i in str:
if i=='a' or i=='e' or i=='i' or i=='o' or
i=='u':
vowel=vowel+1
else:
con=con+1

print("Total Vowels are:", vowel)


print("Total Consonents are:", con)

Program 13: Write a program to enter a string and


count total lower case, upper case and others in
it.
Sol:

str=input("Enter the string")


lower=0
upper=0
14
other=0
for i in str:
if i.islower():
lower=lower+1
else:
if i.isupper():
upper=upper+1
else:
other=other+1
print("Total lower are:", lower)
print("Total upper are:", upper)
print("Total others are:", other)

Program 14: Write a program to enter a string and


print whether it is Palindrome or not? convert the
case of characters in a string.
Sol:

my_str = input("Enter a string")


my_str = my_str.casefold()#it will consider upper
and lower string same
rev_str=my_str[::-1]

if my_str==rev_str:

15
print("The string is a palindrome.")
else:
print("The string is not a palindrome.")

Program 15: Write a program to create a list and


print the smallest element of the list.
Sol:

List=[]
ch='y'
while ch=='y':
n=int(input("Enter a number"))
List.append(n)
ch=input("Wnat to add more element to the List?
(y/n) ")

16
small=List[0]
for i in List:
if i<small:
small=i

print("Smallest element of the list is:", small)

Program 16: Write a program to create a tuple and


print the smallest element of the tuple.
Sol:

Tuple=()
ch='y'
while ch=='y':
n=int(input("Enter a number"))
Tuple=Tuple+(n,)
ch=input("Wnat to add more element to the List?
(y/n) ")

17
small=Tuple[0]
for i in Tuple:
if i<small:
small=i

print("Smallest element of the Tuple is:", small)

Program 17: Write a program to search a number


from a list.
Sol:
List=[12,13,14,15,16,17]
n=int(input("Enter the number to search from the
list"))

found=False
for i in range(0,len(List)-1,1):
if List[i]==n:
print("Element found at:",i+1)
found=True

18
if found==False:
print("Element not found")

Program 18: Write a program to reverse the content


of the list.
Sol:

nums = [1,2,3,4,5,6,7,8,9]
print(nums)
length = len(nums)

for i in range(0,length//2,1):
t=nums[i]
nums[i]= nums[length-1-i]
nums[length-1-i]=t

print(nums)
19
Program 19: Input a list of numbers and swap
elements at the even location with the elements at
the odd location
Sol:
nums = [1,2,3,4,5,6,7,8,9]
print(nums)
length = len(nums)
for i in range(0,length,4):
if(i+2<length):
nums[i], nums[i+2] = nums[i+2], nums[i]
if(i+3<length):
nums[i+1], nums[i+3] = nums[i+3], nums[i+1]

print(nums)

20
Program 20: Create a dictionary with the roll
number, name and marks of n students in a class
and display the names of students who have marks
above 75.
Sol:
n = int(input("Enter number of students: "))
result = {}

for i in range(0,n,1):
print("Enter Details of student No.", i+1)

rno = int(input("Roll No: "))


name = input("Name: ")
marks = int(input("Marks: "))
result[rno] = [name,marks]

21
print(result)

for student in result:


if result[student][1] > 75:
print(result[student][0])

22

You might also like