Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 16

Certificate

This is to certify that the original and genuine investigation content of


this project entitled “Computer Science” has been satisfactorily
executed and prepared by Dhruv Payal a student of class XII A, under
the direct supervision of Mrs. Pooja Vashisht for the academic session
2023- 2024. This Bonafide work of his has been submitted to DELHI
PUBLIC SCHOOL, DEHRADUN, for consideration in partial
fulfilment of Practical Examination conducted by AISSCE, New
Delhi. The project report is up to the expectation and a result of his
efforts and endeavour.
ACKNOWLEDGEMENT
Project is like a bridge between theoretical and practical learning and
now on the accomplishment of this project successfully, I would like
to thank all the people who have been concerned with it and bestowed
upon me their blessings and the heart pledged support. Primarily, I
would like to thank God, who always guided me to work on the right
path of life. Without his grace this project could not become a reality.
Next to him are my parents, to whom I am greatly indebted for their
love and encouragement to this stage. I am feeling highly obliged in
taking the opportunity to express my special thanks and gratitude to
our Respected Principal Sir, Mr. B. K. Singh and Vice-Principal
Ma’am, Mrs. Sujata Singh, for their valuable guidance, keen interest
and encouragement. I express my deep and sincere gratitude to my
subject teacher Mrs. Pooja Vashisht, whose guidance, encouragement,
suggestions and constructive criticism have contributed immensely to
the evolution of my ideas on the project. At last, but not the least, I
am thankful to all my teachers and friends who have been always
helped me and encouraged me throughout the year. No more I have
the words to express my thanks, but my heart is still full of favours
received from every person.
1. Program to check of a number is odd or even.

number = float(input("Enter a number: "))


if number > 0:
print("The number is positive.")
elif number < 0:
print("The number is negative.")
else:
print("The number is zero.")

Output:-
2. Program to get factorial of a given number.

def factorial(n):
result = 1
for i in range(1, n + 1):
result *= i
return result
num = int(input("Enter a number: "))
if num < 0:
print("Factorial is not defined for negative numbers.")
elif num == 0:
print("The factorial of 0 is 1.")
else:
print("The factorial of", num, "is", factorial(num))

Output:-
3. Program to print the table of a given number.

n=int(input("Enter number: "))


i=1
while i<=10:
print(n,"x",i,"=", n*i)
i+=1

Output:-
4. Program to check for a common element in a list.

L1=[]
L2=[]
result=False
n = int(input("Enter the list size: "))
i=0
while i<n:
a=input("Enter elements: ")
L1.append(a)
i+=1
m=int(input("Enter the list size: "))
c=0
while c<m:
a=input("Enter elements: ")
L2.append(a)
c+=1
for x in L1:
for y in L2:
if x==y:
result=True
print(result)
if result:
print("A common element exist")
else:
print("No common elements exist")

Output:-
5. Program to print the grades of a student.

grades = {'Alice': 90, 'Bob': 85, 'Charlie': 92, 'Diana': 88,


'Eva': 95}
print("Alice's grade:", grades['Alice'])
print("Bob's grade:", grades['Bob'])

Output:-
6. Program for Default argument

def change(P,Q=30):
P=P+Q
Q=P-Q
print(P,"#",Q)
return P

X=150
Y=100
X=change(X,Y)
print(X,"#",Y)
Y=change(X)

Output:-
7. Program for Positional Argument

def grade(name, score):

if score > 80:


grade = 'A'
elif 80 >= score > 70:
grade = 'B'
elif 70 >= score > 60:
grade = 'C'
else:
grade = 'D'

print(name, "had grade" ,grade)

grade('max',80)

Output:-
8. Program to find the sum of numbers from 1-9 using
variable length argument.

def sum(*numbers):
total = 0
for num in numbers:
total += num
return total

r=sum(1,2,3,4,5,6,7,8,9)
print(r)

Output:-
9. Program for Keyword argument

def greet(name, greeting="Hello"):


print(f"{greeting}, {name}!")
greet(name="max",greeting="Howdy")

Output:-
10. Program to find circumference and area of a
circle .

def circle(radius):
circumference = 2 * 3.14159 * radius
area = 3.14159 * radius ** 2
return circumference, area
circumference,area=circle(3)
print(circumference)
print(area)

Output:-
11. Program to find total number of characters in a
file.

def countch(count):
with open(count, 'r') as file:
text = file.read()
return len(text)
filepath = 'textfile.txt'
charactercount = countch(filepath)
print(f"Character Count: {charactercount}")

Output:-
12. Program to find total number of words in a file.

def countw(textfile):
with open(textfile, 'r') as file:
text = file.read()
words = text.split()
return len(words)
filepath = 'textfile.txt'
wordc = countw(filepath)
print(f"Word Count: {wordc}")

Output:-
13. Program to check number of lines in a file.

def countl(textfile):
with open(textfile, 'r') as file:
lines = file.readlines()
return len(lines)

filepath = 'textfile.txt'
linecount = countl(filepath)
print(f"Line Count: {linecount}")

Output:-

You might also like