CBSE Class 12 Computer Science — File Handling in Python
All previous year questions from Chapter: File Handling in Python
5 questions found
2026(5 questions)
- 10
Consider the statement given below : ```python f1 = open("pqr.dat","________") ``` Which of the following is the correct file mode to open the file in read only mode ?
1 mark· A· File Handling - File Opening Modes - 32
(a) Write a Python function that counts and returns the number of digits appearing in the text file "Space.txt". For example, if the file contains : ``` Space exploration has unlocked incredible advancements in technology and science. Since the first moon landing in 1969, space agencies have sent probes to Mars, Jupiter and beyond. The ISS, orbiting Earth at about 400 km, serves as a hub for research. With missions planned for 2030, humanity's cosmic journey continues! ``` Then the function should return 11. OR (b) Write a Python function that displays the words in which the lowercase letter 'e' appears at least twice in the text file 'Space.txt'. For example, if the file contains : ``` Space exploration has unlocked incredible advancements in technology and science. Since the first moon landing in 1969, space agencies have sent probes to Mars, Jupiter and beyond. The ISS, orbiting Earth at about 400 km, serves as a hub for research. With missions planned for 2030, humanity's cosmic journey continues! ``` Then the function should display : agencies serves incredible advancements science. research.
3 marks· C· Text File Handling in Python - 36
A csv file "States.csv" contains some data about all the states of India. Each record of the file contains the following data : - Name of the State - Capital of the State - Population of the State - Official Language of the State For example, a sample record in the file is : ['Andhra Pradesh','Amaravati',52221000,'Telugu'] Write a Python program which reads the data from this file and appends all those records where population is more than 10000000 into another csv file 'More.csv'. Note : "States.csv" also contains the Header row. The Header row should NOT be copied to "More.csv".
4 marks· D· CSV File Handling — Reading, Filtering and Writing Records - 42
Append() - To input the data of a Resource Person and write it in the file RESOURCES.DAT.
2 marks· E· Binary File Handling — Writing Records with pickle - 43
Update() - To increase the Charges of each resource person by 500.
3 marks· E· Binary File Handling — Updating Records