File Handling Questions 2
File Handling Questions 2
Example:
Tower of hanoi is an interesting problem.
Mobile phone tower is away from here. Views
from EIFFEL TOWER are amazing.
16. Write3 the function definition for WORD4CHAR() in PYTHON to read the content
of a text file FUN.TXT, and display all those words, which have four characters
in it.
Example:
19. Write a function in Python which accepts two text file names as parameters. The
function should copy the contents of first file into the second file in such a way
that all multiple consecutive spaces are replaced by a single space. For
example, if the first file contains:
Self conquest is the
greatest victory .
then after the function execution, second file should contain:
Self conquest is the
greatest victory .
20. Write a function in Python to input a multi-line string from the user and write
this string into a file named ‘Story.txt’. Assume that the file has to be created.
21. Write a function to display the last line of a text file. The name of the text file
is passed as an argument to the function.
22. Write a Python function to read and display a text file 'BOOKS.TXT'. At the end
display number of lowercase characters, uppercase characters, and digits
present in the text file.
23. Write a Python function to display the size of a text file after removing all the
white spaces (blanks, tabs, and EOL characters).