GALGOTIAS COLLEGE OF ENGINEERING AND TECHNOLOGY
1, Knowledge Park-II, Greater Noida, U.P.
Even Semester 2023-24
Python Programming BCC-302
ASSIGNMENT-4
CO-4: Identify the commonly used operations involving file systems.
Q1. Discuss the different types of argument-passing methods in python. Explain
the variable length argument with any suitable example?
Q2. What is a File Pointer? Explain use of Seek() and Tell() methods with an example?
Q3. Write a function lessthan(lst, k) to return list of numbers less than k from a list
lst. The function must use list comprehension.?
Example: lessthan([1, -2, 0, 5, -3], 0) returns [-2, -3]
Q4. Write a program to process a text file named “myfile.txt” and count occurrences of word
‘the’ in the file.
Q5. Demonstrate the file handling in Python in detail. Write a python code to create
a file with ‘P.txt’ name and write your name and father’s name in this file and then
read this file to print it.
Q6. What is a Function in Python? Discuss its elements in detail with an example?
Q7. Differentiate between:
a) text file and binary file
b) readline() and readlines()
c) write() and writelines()
Q8. Explain the use of “with” statement in Python with an example program?