Python Questions
Python Questions
Total Questions: 10
Instructions:
- Write Python programs to solve the following problems.
- Use appropriate file handling modes and exception handling where necessary.
Q3. Write a Python script to append a new line `"This is an appended line"` to `sample.txt`
and display the updated content.
Q5. Write a Python program that reads a file and prints only those lines that contain the
word “Python” (case-sensitive).
Q6. Write a Python program to count the number of words and characters in the file
`sample.txt`.
Q7. Write a program to copy the contents of `sample.txt` to another file `copy_sample.txt`.
Q9. Write a Python program that reads numbers from a file `numbers.txt`, one per line, and
writes only the even numbers to a new file `even_numbers.txt`.
Q10. Create a program that accepts user input (name, age, city) and stores it in a CSV file
`users.csv`. Ensure that every new entry is stored on a new line.