You are on page 1of 18

Computer Science

Practical File
Term 1

Archit Singh

XII-A
No. Name of Practical Date
1. WAP to accept a string from the
user and write it in text file
“story.txt” as long as the user
wants.
2. WAP to accept roll no., names and
marks of students and store these
details in “student.txt
3. WAP to input strings(sentences)
and then write in a file “story.txt”
together in list forms.
4. WAP to read a text file “demo.txt”.
Count and print number of lines,
words and consonants in it.
5. WAP to count and print
occurrences of words like “he” and
“she” from a file “story.txt”.
6. WAP to count vowels, consonants,
upper case, lower case consonants
in a file “story.txt”.
7. WAP to display all the lines ending
with “e” in a text file “demo.txt”
8. WAP to find a display words with
the maximum length in a text file
“story.txt”.
9. WAP to remove those lines which
are starting with “#” from
“story.txt”.
10. WAP to copy contents of “file1” to
“file2” after capitalizing the first
letter of each line.
11. WAP to delete a line having a
particular word from a text file
passed as an argument.
12. Demonstrate seek and tell method.
13. WAP to accept a string from a user
and write it in a binary file
“sample.dat”. Also, after writing
display each line.
14. WAP to accept item no., item price
as long as the user wants and write
it in a binary file “item.dat” in the
form of list.
15. Create a binary file “student.dat”
with admission no., name, class,
bus number. Search for a given
admission no and display its
details. If not found, display an
appropriate message.
16. WAP to create a dictionary having
name and phone no. Write it in a
binary file “phone.dat”. Also search
and display.
17. WAP to create a binary file
“hospital.dat” with patient id,
name and bill. Input a patient id,
search for it and display the info.
18. WAP to accept name and phone no
from a user and add it to a
dictionary “phone.dat”. Accept
new name and new phone no from
the user and update it.
19. Write a function to write and
search for a book number from a
binary file “book.dat”, assuming
the binary file is containing the
records of the following type:
{“book_no : value, “book name” :
string}. Assume that book_no is an
integer.
20. Assume the list of vehicles as
follows: [vehicle, no of wheels]
where vehicle is a string and no of
wheels is an integer. Write a
function wfile() to write and
showfile() to read all the records
present in an already existing
binary file “speed.dat” and display
them on the screen. Also count the
no of records present in the file.
Program 1:

Output:

Program 2:

Output:
Program 3:

Output:

Program 4:

Output:
Program 5:

Output:

Program 6:

Output:
Program 7:

Output:

Program 8:

Output:
Program 9:

Program 10:
Program 11:

Output:

Program 12:

Output:
Program 13:

Output:
Program 14:

Output:
Program 15:

Output:
Program 16:

Output:
Program 17:

Output:
Program 18:

Output:
Program 19:

Output:
Program 20:

Output:

You might also like