Answered step by step
Verified Expert Solution
Question
1 Approved Answer
COMPUTER PROGRAMMING ERRORS & EXCEPTIONS TUTORIALS (PYTHON) Problem 1 Handle the exception thrown by the code below by using try and except blocks. In [4]:
COMPUTER PROGRAMMING ERRORS & EXCEPTIONS TUTORIALS (PYTHON) Problem 1 Handle the exception thrown by the code below by using try and except blocks. In [4]: for i in ['a','b', 'c']: print(i**2) TypeError Traceback (most recent call last) in 1 for i in ['a', 'b', 'c']: ----> 2 print(i**2) TypeError: unsupported operand type(s) for ** or pow(): 'str' and 'int' Problem 2 Handle the exception thrown by the code below by using try and except blocks. Then use a finally block to print 'All Done.' In [2]: x = 5 y = 0 z = x/y ZeroDivisionError Traceback (most recent call last) in () 2 y = 0 3 ----> 4 Z = x/y ZeroDivisionError: division by zero
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started