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!".