Question: Q5.(a). The following code executes without any errors. Provide 3 variants of the code having an error which runs each of the exceptions mentioned within
Q5.(a). The following code executes without any errors. Provide 3 variants of the code having an error which runs each of the exceptions mentioned within the code. (6-Marks) try: def fun1(a,b): print(a,b) in_file = open('input_file.txt', 'w') in_file.write('nothing') x = 2 y = x+2 fun1(2,3) except FileNotFoundError: print("File doesn't exist") except NameError: print('Variable Undeclared') except SyntaxError: print('non-default argument follows default argument')
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
