Enrol to start learning
Reading is open to everyone. Enrolling is free, and it is what unlocks the audio lessons, practice tests and progress tracking.
13.7.3. Python
This section
Practice test
11 questions on this section. Wrong answers show you what to read again.
Sign up to take itWhole chapter
Revision test
Mixed questions from across the chapter. Your answers get marked.
Sign up to take itQuick
Flashcard drill
3 cards from this lesson. Good the night before a test.
Try these first
- 1.
What is the purpose of a try-except block?
Hint
Think about what happens when a program tries to access a file that doesn't exist.
- 2.
What exception do we catch when a file is not found?
Hint
It's a specific error related to files.
- 3.
What is raised if you try to open a file that doesn't exist?
- FileError
- FileNotFoundError
- ValueError
Hint
This is a specific type of error related to file operations.
- 4.
You should always handle errors specifically. True or False?
- True
- False
Hint
Think about the importance of knowing what error occurred.
- 5.
Create a Python script that reads user input for a filename and tries to read from that file, handling the exception if it does not exist.
Hint
Incorporate user input to allow dynamic filename handling.
- 6.
Write a function that attempts to open a file for writing and logs an error if the process fails.
Hint
Utilize the logging module for a professional touch.
Exercises
Total Questions
2
Estimated Time
4 min
Passing Score
70%
Instructions
- Read each question carefully
- You can use hints if you need help
- Complete all questions before submitting
4 more questions available
Enrol freeQuiz
Total Questions
2
Estimated Time
4 min
Passing Score
70%
Instructions
- Read each question carefully
- You can use hints if you need help
- Complete all questions before submitting
1 more question available
Enrol freeChallenge Problems
Total Questions
2
Estimated Time
4 min
Passing Score
70%
Instructions
- Read each question carefully
- You can use hints if you need help
- Complete all questions before submitting