File Handling
✕Text Files
Question 1 of 3
- Create a text file python.txt on your desktop and write short essay about python on it.
- Open this file python.txt. Add text
I will learn Error Handling Nextat end - Create a new file java.txt. Copy the content of python.txt to java.txt but replacing the text
pythonwithjava. - Calculate and display the size of python.txt and java.txt in KB. (Hint: use
osmodule & AI) - Read file
nobel_prize_speech.txtand display most repeated word on it.
CSV Files
Question 2 of 3
- Create a csv file std_1.csv with columns:
Name,Age,Grade. Add 5 records to it using list of list. - Create a csv file std2.csv with columns:
Name,Age,Grade. Add 5 records to it using list of dict. - Read file
2022-01-03.csvand display records as list of list. - Read file
2022-01-03.csvand display records as list of dict.
- Create a csv file std_1.csv with columns:
JSON File
Question 3 of 3
- Store 5 students data in dict as
{"9843": {"name": "Rabindra", "age": 30, "course": "Python"}, "9844": {"name": "Hari", "age": 25, "course": "Java"}....}. Save this data in fileinfo.json. - Load
info.jsonfile. Convert the data in list of dictionary like[{"phone": "9843", "name": "Rabindra", "age": 30, "course": "Python"}, ....]. Save coverted data ininfo.csvfile. - Read file
election_result.json. Find name of winner, associated party and votes obtained - Read file
election_result.json. Find total vote casted and average vote per candidate. - Convert the file
election_result.jsonin csv format and save it aselection_result.csv.
- Store 5 students data in dict as
