Computer Report File
Computer Report File
SESSION 2024-25
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))
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)
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])
MY SQL
17. CARS
Out Come
18.Employees
Out Come
19. STUDENTS
Out Come
20. TEACHERS