Python_assignment-4
Python_assignment-4
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?
Q8. Explain the use of “with” statement in Python with an example program?