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

Python File Handling and Data Structures

The document outlines five programming assignments focused on Python fundamentals. Tasks include file operations such as writing and reading names and logs, using list comprehensions, managing JSON data for city populations, and handling exceptions for file access. Each assignment emphasizes practical coding skills and file management in Python.

Uploaded by

Sanjay saini
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)
6 views1 page

Python File Handling and Data Structures

The document outlines five programming assignments focused on Python fundamentals. Tasks include file operations such as writing and reading names and logs, using list comprehensions, managing JSON data for city populations, and handling exceptions for file access. Each assignment emphasizes practical coding skills and file management in Python.

Uploaded by

Sanjay saini
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

Python Fundamentals

(Assignment5)
Assignment Problems
Q1. Create a program that:
1. Opens a file "[Link]" in write mode
2. Writes 5 names (one per line) entered by the user
3. Then opens the same file in read mode and prints all names
Q2. Create a program that:
1. Opens a file "[Link]" in append mode
2. Adds a new log entry (like "Program run successfully")
3. Opens the file in read mode and prints all logs
Q3. Create a program that:
1. Has a list of numbers: [5, 10, 15, 20, 25]
2. Uses a list comprehension to create a new list with only numbers greater
than 15
3. Prints the new list
Q4. Create a Python dictionary of 3 cities and their populations. Save it to
"[Link]".
1. Then load the JSON and print each city and its population.
2. Ask the user for a new city & its population - update this info in the json
file.
Q5. Write a program that tries to open "[Link]" in read mode. If the file does not
exist, catch the exception and print "File not found!".

You might also like