Topic Practice · Advanced
Context Managers problems
50 problems: 22 Easy, 18 Medium, 10 Hard.
✓1. with open()
4 test casesEasy✓2. Enter and Exit
4 test casesEasy✓3. Nested Tags
4 test casesEasy✓4. @contextmanager
4 test casesEasy✓5. Suppress an Error
4 test casesEasy✓6. Start and End Messages
4 test casesEasy✓7. What as Gives You
4 test casesEasy✓8. Yield a Value
4 test casesEasy✓9. Closed Automatically
4 test casesEasy✓10. Write With with
4 test casesEasy✓11. Hello and Goodbye
4 test casesEasy✓12. @contextmanager Hello
4 test casesEasy✓13. The Value After as
4 test casesEasy✓14. __exit__ Runs After an Error
4 test casesEasy✓15. Ignore a Missing Key
4 test casesEasy✓16. Two Files in One with
4 test casesEasy✓17. Closed After the Block
4 test casesEasy✓18. Enter Returns a List
4 test casesEasy✓19. Underlined Heading
4 test casesEasy✓20. Count the Blocks
4 test casesEasy✓21. Append With with
4 test casesEasy✓22. Which Error Reached __exit__?
4 test casesEasy✓23. Clean-up After an Error
4 test casesMedium✓24. Swallow One Error Type
4 test casesMedium✓25. Capture Printed Output
4 test casesMedium✓26. Indentation Manager
4 test casesMedium✓27. Temporary Setting
4 test casesMedium✓28. Two Files at Once
4 test casesMedium✓29. Timer Without Time
4 test casesMedium✓30. closing()
4 test casesMedium✓31. Safe File Stats
4 test casesMedium✓32. Count and Ignore Errors
4 test casesMedium✓33. A Pool of Resources
4 test casesMedium✓34. Nested Log Prefixes
4 test casesMedium✓35. Which Errors Were Suppressed?
4 test casesMedium✓36. Undo a List on Error
4 test casesMedium✓37. Nested Depth Counter
4 test casesMedium✓38. Temporary Decimal Precision
4 test casesMedium✓39. A Writer That Counts Lines
4 test casesMedium✓40. Record the Error, Keep Going
4 test casesMedium✓41. All or Nothing
4 test casesHard✓42. Many Resources
4 test casesHard✓43. Inspect the Exception
4 test casesHard✓44. Lock Simulation
2 test casesHard✓45. Working in a Folder
4 test casesHard✓46. Optional Context
4 test casesHard✓47. All or Nothing File Write
4 test casesHard✓48. Cleanup Even on Errors
4 test casesHard✓49. Nested Transactions
4 test casesHard✓50. Profile Sections With a Fake Clock
4 test casesHard
4 test casesEasy✓2. Enter and Exit
4 test casesEasy✓3. Nested Tags
4 test casesEasy✓4. @contextmanager
4 test casesEasy✓5. Suppress an Error
4 test casesEasy✓6. Start and End Messages
4 test casesEasy✓7. What as Gives You
4 test casesEasy✓8. Yield a Value
4 test casesEasy✓9. Closed Automatically
4 test casesEasy✓10. Write With with
4 test casesEasy✓11. Hello and Goodbye
4 test casesEasy✓12. @contextmanager Hello
4 test casesEasy✓13. The Value After as
4 test casesEasy✓14. __exit__ Runs After an Error
4 test casesEasy✓15. Ignore a Missing Key
4 test casesEasy✓16. Two Files in One with
4 test casesEasy✓17. Closed After the Block
4 test casesEasy✓18. Enter Returns a List
4 test casesEasy✓19. Underlined Heading
4 test casesEasy✓20. Count the Blocks
4 test casesEasy✓21. Append With with
4 test casesEasy✓22. Which Error Reached __exit__?
4 test casesEasy✓23. Clean-up After an Error
4 test casesMedium✓24. Swallow One Error Type
4 test casesMedium✓25. Capture Printed Output
4 test casesMedium✓26. Indentation Manager
4 test casesMedium✓27. Temporary Setting
4 test casesMedium✓28. Two Files at Once
4 test casesMedium✓29. Timer Without Time
4 test casesMedium✓30. closing()
4 test casesMedium✓31. Safe File Stats
4 test casesMedium✓32. Count and Ignore Errors
4 test casesMedium✓33. A Pool of Resources
4 test casesMedium✓34. Nested Log Prefixes
4 test casesMedium✓35. Which Errors Were Suppressed?
4 test casesMedium✓36. Undo a List on Error
4 test casesMedium✓37. Nested Depth Counter
4 test casesMedium✓38. Temporary Decimal Precision
4 test casesMedium✓39. A Writer That Counts Lines
4 test casesMedium✓40. Record the Error, Keep Going
4 test casesMedium✓41. All or Nothing
4 test casesHard✓42. Many Resources
4 test casesHard✓43. Inspect the Exception
4 test casesHard✓44. Lock Simulation
2 test casesHard✓45. Working in a Folder
4 test casesHard✓46. Optional Context
4 test casesHard✓47. All or Nothing File Write
4 test casesHard✓48. Cleanup Even on Errors
4 test casesHard✓49. Nested Transactions
4 test casesHard✓50. Profile Sections With a Fake Clock
4 test casesHard