0% found this document useful (0 votes)
15 views15 pages

Python File Handling Examples

The document outlines various Python programming tasks including reading a text file and displaying words, counting characters, filtering lines, creating binary files, generating random numbers, implementing a stack, and managing student details in a dictionary. Each task includes input and output views for clarity. The tasks focus on file handling, data manipulation, and basic programming concepts.

Uploaded by

xyz3264128
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views15 pages

Python File Handling Examples

The document outlines various Python programming tasks including reading a text file and displaying words, counting characters, filtering lines, creating binary files, generating random numbers, implementing a stack, and managing student details in a dictionary. Each task includes input and output views for clarity. The tasks focus on file handling, data manipulation, and basic programming concepts.

Uploaded by

xyz3264128
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

• Read a text file line by line and display each word separated

by a #.
Text File View:-

Python Input:-

Python Output:-
Read a text file and display the number of
vowels/consonants/uppercase/lowercase characters in the file.
Text File View:-

Python Input View:-


Output View:-
Remove all the lines that contain the character 'a' in a file
and write it to another file.

Text File View:-

Python Input View:-

Output:-
Create a binary file with name and roll number. Search for a
given roll number and display the name, if not found display appropriate
message.

Python Input view:-


Output View :-
Create a binary file with name and roll number. Search for a
given roll number and display the name, if not found display app

Input View:-
Output view :-
Write a random number generator that generates random
numbers between 1 and 6 (simulates a dice).

Input View:-

Output View:-
Write a Python program to implement a stack using list

Input View:-
Output View:-
Create a CSV file by entering user-id and password, read
and search the password for given userid.

Input View:-
Output View :-
Write a Python program to store students’ details such as
admission number, roll number, name and percentage in a dictionary and
display the information of a student on the basis of the admission number
entered by the user.
Input view:-

Output View:-

You might also like