0% found this document useful (0 votes)
3 views1 page

Python_assignment-4

This document is an assignment for Python Programming at Galgotias College of Engineering and Technology for the Even Semester 2023-24. It includes questions on argument-passing methods, file pointers, list comprehensions, file handling, and function elements in Python. Additionally, it requires comparisons between file types and methods, as well as the use of the 'with' statement in Python.

Uploaded by

vivaans0410
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)
3 views1 page

Python_assignment-4

This document is an assignment for Python Programming at Galgotias College of Engineering and Technology for the Even Semester 2023-24. It includes questions on argument-passing methods, file pointers, list comprehensions, file handling, and function elements in Python. Additionally, it requires comparisons between file types and methods, as well as the use of the 'with' statement in Python.

Uploaded by

vivaans0410
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/ 1

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?

You might also like