0% found this document useful (0 votes)
6 views6 pages

Python Lab IYr Week-7

The document outlines four Python programming tasks aimed at file manipulation, including merging file contents, checking for specific words, finding the most frequent word, and analyzing word statistics in a file. Each program includes a brief aim, required tools, and a step-by-step procedure for implementation using Python IDLE. The document emphasizes the necessity of having specific text files in the same folder for the programs to run successfully.

Uploaded by

mdafzal.aiml
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)
6 views6 pages

Python Lab IYr Week-7

The document outlines four Python programming tasks aimed at file manipulation, including merging file contents, checking for specific words, finding the most frequent word, and analyzing word statistics in a file. Each program includes a brief aim, required tools, and a step-by-step procedure for implementation using Python IDLE. The document emphasizes the necessity of having specific text files in the same folder for the programs to run successfully.

Uploaded by

mdafzal.aiml
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
You are on page 1/ 6

Week - 7:

1. Write a Python code to merge two given file contents into a third file.
2. Write a Python code to open a given file and construct a function to check for given words
present in it and display on found.
3. Write a Python code to Read text from a text file, find the word with most number of
occurrences.
4. Write a function that reads a file file1 and displays the number of words, number of vowels,
blank spaces, lower case letters and uppercase letters.

PROGRAM – 1:
Aim: Write a Python code to merge two given file contents into a third file.
Tools required:
1. Python distribution.
2. Python IDLE.
Procedure:
1. Open the Python IDLE  open the new file editor, and type the following code.
Note: To successfully run the below program file1.txt and file2.txt must exist
in the same folder. Suppose the text files file1.txt and file2.txt contain the
following data.
file1.txt

file2.txt

Below is the program implementation.

Mr. Mohammed Afzal, Asst.Professor in AIML Dept. @SPHN


Mob: +91-8179700193, Email: [email protected]
2. Save the program.
3. Execute the program. (RunRun Moduile) or press F5.

OUTPUT:

file3.txt

PROGRAM – 2:
Aim: Write a Python code to open a given file and construct a function to check for given words
present in it and display on found.
Tools required:

Mr. Mohammed Afzal, Asst.Professor in AIML Dept. @SPHN


Mob: +91-8179700193, Email: [email protected]
1. Python distribution.
2. Python IDLE.
Procedure:
1. Open the Python IDLE  open the new file editor, and type the following code.
Note: To successfully run the below program file1.txt must exist in the same
folder. Suppose the text files file1.txt contain the following data.

Below is the program implementation.

2. Save the program.


3. Execute the program. (RunRun Moduile) or press F5.
OUTPUT:

Mr. Mohammed Afzal, Asst.Professor in AIML Dept. @SPHN


Mob: +91-8179700193, Email: [email protected]
PROGRAM – 3:
Aim: Write a Python code to Read text from a text file, find the word with most number of
occurrences.
Tools required:
1. Python distribution.
2. Python IDLE.
Procedure:
1. Open the Python IDLE  open the new file editor, and type the following code.
Note: To successfully run the below program file1.txt must exist in the same folder.
Suppose the text files file1.txt contain the following data.

Below is the program implementation.

Mr. Mohammed Afzal, Asst.Professor in AIML Dept. @SPHN


Mob: +91-8179700193, Email: [email protected]
2. Save the program.
3. Execute the program. (RunRun Moduile) or press F5.
OUTPUT:

PROGRAM – 4:
Aim: Write a function that reads a file file1 and displays the number of words, number of
vowels, blank spaces, lower case letters and uppercase letters.
Tools required:
1. Python distribution.
2. Python IDLE.
Procedure:
1. Open the Python IDLE  open the new file editor, and type the following
code.
Note: To successfully run the below program file1.txt must exist in the same
folder. Suppose the text files file1.txt contain the following data.

Mr. Mohammed Afzal, Asst.Professor in AIML Dept. @SPHN


Mob: +91-8179700193, Email: [email protected]
2. Save the program.
3. Execute the program. (RunRun Moduile) or press F5.
OUTPUT:

Mr. Mohammed Afzal, Asst.Professor in AIML Dept. @SPHN


Mob: +91-8179700193, Email: [email protected]

You might also like