Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
20 views

Computer Report File

The document is a computer report file for a student named Daksh Raj from Agarsen Dav Public School, detailing their completion of the Computer Science practical file for the session 2024-25. It includes an index of various programming tasks and implementations using Python, such as recursion, file handling, and CSV operations. The report also features code snippets demonstrating the student's understanding of different programming concepts and libraries.

Uploaded by

babykumari1438
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)
20 views

Computer Report File

The document is a computer report file for a student named Daksh Raj from Agarsen Dav Public School, detailing their completion of the Computer Science practical file for the session 2024-25. It includes an index of various programming tasks and implementations using Python, such as recursion, file handling, and CSV operations. The report also features code snippets demonstrating the student's understanding of different programming concepts and libraries.

Uploaded by

babykumari1438
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/ 16

AGARSEN DAV PUBLIC SCHOOL

BHARECH NAGAR RAMGARH 829117

SESSION 2024-25

COMPUTER REPORT FILE


NAME:- DAKSH RAJ
CLASS:- XII SCIENCE
ROLL NO:-
SUBMITTED TO:- M.R AJAY SIR
CERTIFICATE
THIS IS TO CERTIFY THAT DAKSH
RAJ.STUDENT OF CLASS XII
SCIENCE HAS COMPLETED THEIR
COMPUTER SCIENCE (NEW-083)
PRACTICAL FILE.

INTERNAL EXAMINER
EXTERNAL EXAMINER
INDEX
S Program Date Teacher
N Factorial Using sign
o Recursion
1 Fibonacci
2 Sequence

3 Prime Number
Check
4
Calculating
5
Power
6
Maths Library
7
Date And Time
8
Die Sumilation
9
Mean Median
10 Mode
11 Text File:W &
12 R
13 Count Lines
Words
14 Append Data
15 Count Specific
16 Word
17 Stack Using
List
18
Reverse A
19 String
20 Csv File

Csv: Avgrage
Cars ‘
Employees
Student
Teacher
 WORKING WITH
FUNCTION
1. FACTIORIAL USING RECURSION
def factorial(n):
return 1 if n==0 else n*factorial(n-
1)

num=int(input("enter no"))
print("Factorial
of",num,"is",factorial(num))
2. FIBONACCI SEQUENCE USING
RECURSION
def Fibonacci(n):
if n<=1:
return n
else:
return Fibonacci(n-
1)+Fibonacci(n-2)
terms=10
print(“Fibonacci sequence:”)
for i in range(terms):
print(Fibonacci(i),end+” “)
3. PRIME NUMBER CHECK
Def is_prime(n):
If n<2:
return False
for i in range(2,int(n**0.5)+1):
if n%i == 0:
return False
return True
num=29
print(num,”is prime:”, is_prime())
4. CALCULATE THE POWER OF A
NUMBER
def power(base,exp):
return base**exp
print(f”3^4= {power(3,4)}”)

 USING
PYTHON
LIBRARIES
5. MATHS LIBRARY CALCULATION
import math
print(“GCD of 48 and 18 is:”,
maths.gcd(48,18))
6. DATETIME LIBRARY CURRENT DATE
AND TIME
from datetime import datetime

now =datetime>now()
print(“current date and
time:”,now.strftime(“%Y-%m-%d %H:
%M:%S))
7. RANDOM LIBRARY: DICE
SIMULATION
import random
print(“Rolling a
dice:”,random.randint(1,6))

8. STATISTICS LIBRARY MEAN MEDIAN


MODE
import statistics
data = [10,20,30,20,40,50]
print(“Mean:”<statistics.mean(data))
print(“Median:”,statistics.median(data)
)
print(“Mode:”,statistics.mode(data))
FILE HANDLING
9. WRITE AND READ FROM A TEXT
FILE
with open(“example.txt”,”w”) as f:
f.write(“hello, file handling in
python!”)
with open(“example.txt”,”r”) as f:
content= f.read()
print(“content of the file:”,content)

10. COUNT LINES WORDS, AND


CHARACTERS IN A FILE
With open(“example.txt”,”r”) as f:
lines= f.readlines()

line_count=len(length)
word_count=sum(len(line.spilt())for
line in lines)
char_count=sum(len(line) for line in
lines)
print(“lines:”,line_count,”words:”,wor
d_count,”characters:”,char_count)
11. APPEND DATA TO A FILE
with open(“example.txt”,”a”) as file:
File.write(“\nappending a new line
to the existing file.”)
with open(example.txt”, ”r”) as file:
content=file.read()
print(“update file content:\
n”,content)
12. COUNT SPECIFIC WORD
OCCURRENCES IN A FILE
with open(word.txt”,”w”) as file:
file.write(“python is fun.pythonnis
powerful. Python is popular.”)

word_to_count = “PYTHON”
with open(“word.txt”, ”r”) as file:
content= file.read()
count=content.count(word_to_count)
print(f”the
word”{word_to_count}”occurs{count
}times in the file”)
 STACK
IMPLEMENTATION
13. STACK USING LIST
stack=[]
def push(element):
stack.append(element)
def pop():
return stack.pop() if stack else
“sack is empty”
push(10)
push(20)
print(“stack after push:”,stack)
print(“popped element:”,pop())
print(“stack after pop:”,stack)

14. REVERSE A STRING USING STACK


def reverse_string(s):
stack=list(s)
reversed_str=” “
while stack:
reversed_str+= stack.pop()
return reversed_str
string= “python”
print(“reversed string:”,
reverse_string(string))

 CSV HANDLING
15. WRITE AND READ FROM A CSV FILE
import csv
#writing to csv
with open(“data.csv”, ”w”, newline=”
“) as file:
writer = csv.writer(file)
writer.writerow([“Name”, “Age”,
“City”])
writer.writerow([“Alicce”, 25, “New
York”,])
writer.writerow([“Bob”, 30, “Los
Angeles”])
#reading from csv
with open(“data.csv”, “r”) as file:
reader= csv.reader(file)
for row in reader:
print(row)
16. FIND AVERARAGE FROM CSV FILE
import csv
with open(“marks.csv”, ”w”,
newline=” “) as file:
writer = csv.writer(file)
writer.writerow([“Student”,
“Marks”])
writer.writerow([“John”, 85])
writer.writerow([“Jane”, 90])
writer.writerow([“Mike”, 78])

with open(“marks.csv”, “r”) as file:


reader = csv.reader(file)
next(reader) #skip header
total, count = 0, 0
for row in reader:
total += int(row[1])
count += 1
print(“Average marks:”, total/ count)

MY SQL
17. CARS
Out Come

18.Employees
Out Come

19. STUDENTS
Out Come

20. TEACHERS

You might also like