CLASS -12 TH
PRACTICAL QUESTIONS WITH ANSWERS
********************************************
********************************************
..........................................................
...........................................................
PRACTICE SETS
-------------------------------------------------------------------------
---------------------------------------------------------------------------
---------------------------------------------------------------------------
Sample question papers with marking scheme (PYQ)
-------------------------------------------------------------------------
***********************************************
Computer Networks
.......................................
New
---------------------------------------------------------------------
...................................................................................
Practicals(NEW)
.................................................................................
Dear Students,
Practical Experiments 17 to 20
Experiment -17
---------------------------------------------
Two files "part1.txt" and "part2.txt" together contain a full essay.
Write a program to:
1. Merge both files into "fullessay.txt"
2. Count the number of sentences
3. Display the longest sentence
4. Count the frequency of each word (case-insensitive)
---
Sample Input Files
part1.txt
Artificial Intelligence is transforming the world. It helps in automation.
part2.txt
AI also improves decision making. Many industries depend on it.
---
Program
# Step 1: Merge the files
f1 = open("part1.txt", "r")
f2 = open("part2.txt", "r")
f3 = open("fullessay.txt", "w")
content = f1.read() + " " + f2.read()
f3.write(content)
f1.close()
f2.close()
f3.close()
# Step 2: Sentence count
sentences = content.split(".")
sentences = [s.strip() for s in sentences if s.strip() != ""]
print("Total Sentences:", len(sentences))
# Step 3: Longest sentence
longest = max(sentences, key=len)
print("Longest Sentence:", longest)
# Step 4: Word frequency
words = content.lower().replace(".", "").split()
freq = {}
for w in words:
freq[w] = freq.get(w, 0) + 1
print("Word Frequency:")
for k, v in freq.items():
print(k, ":", v)
---
Output
Total Sentences: 4
Longest Sentence: Artificial Intelligence is transforming the world
Word Frequency:
artificial : 1
intelligence : 1
is : 1
transforming : 1
the : 1
world : 1
it : 2
helps : 1
in : 2
automation : 1
ai : 1
also : 1
improves : 1
decision : 1
making : 1
many : 1
industries : 1
depend : 1
on : 1
Experiment -18
-----------------------------------------------------------------
.
A CSV file "attendance.csv" contains:
Name,Days_Present,Days_Total
Write a Python program to:
1. Display all records
2. Calculate attendance percentage for each student
3. Count students with attendance below 75
4. Display the student with highest attendance
---
attendance.csv
Amit,180,200
Riya,150,200
John,198,200
Meena,120,200
Tara,175,200
---
Program
import csv
f = open("attendance.csv", "r")
reader = csv.reader(f)
low_count = 0
best_name = ""
best_percent = 0
print("Attendance Report:")
for row in reader:
name, present, total = row
present = int(present)
total = int(total)
percent = (present / total) * 100
print(name, ":", percent, "%")
if percent < 75:
low_count += 1
if percent > best_percent:
best_percent = percent
best_name = name
f.close()
print("Students below 75%:", low_count)
print("Highest Attendance:", best_name, "-", round(best_percent, 2), "%")
---
Output
Attendance Report:
Amit : 90.0 %
Riya : 75.0 %
John : 99.0 %
Meena : 60.0 %
Tara : 87.5 %
Students below 75%: 1
Highest Attendance: John - 99.0 %
Experiment -19
------------------------------------------------
A binary file "library.dat" stores:
[BookID, Title, Author, Copies]
Write a program to:
1. Create the file
2. Count how many books have less than 5 copies
3. Increase copies of a book given by BookID
---
Program
import pickle
# Step 1: Create file
books = [
[101, "Python", "Guido", 3],
[102, "AI Basics", "Russell", 10],
[103, "Data Science", "James", 2]
]
f = open("library.dat", "wb")
pickle.dump(books, f)
f.close()
# Step 2: Count books with <5 copies
f = open("library.dat", "rb")
data = pickle.load(f)
f.close()
count = 0
for b in data:
if b[3] < 5:
count += 1
print("Books with less than 5 copies:", count)
# Step 3: Update copies
bid = int(input("Enter Book ID to add copies: "))
new_list = []
for b in data:
if b[0] == bid:
b[3] += 1 # increase copy by 1
new_list.append(b)
# Write back
f = open("library.dat", "wb")
pickle.dump(new_list, f)
f.close()
print("Updated Successfully")
---
Output Example
Books with less than 5 copies: 2
Enter Book ID to add copies: 101
Updated Successfully

Sir you said that you will upload the details of boards CSpractical.
ReplyDeleteThis comment has been removed by a blog administrator.
ReplyDeleteThank you sir
ReplyDeleteThis comment has been removed by a blog administrator.
ReplyDeletesuper se opar blog quality amazing information about education must need to every one educational skills who want made own life thanks for unique content I have read many blogs article but now I got miracle magic article who change my life I thought not need education must for every one but now change my thought thanks to you again help for student who want submit own project and exma. Graphic Designing course in Delhi NCR,
ReplyDeleteBest computer course in Delhi NCR
Best Fine art Institute in Delhi NCR