Knowee
Questions
Features
Study Tools

Choose the correct answerWhat will be the output of the following program?def fun(): try: print(1) finally: print(2)fun()Select all the correct statements given below.Options211221

Question

Choose the correct answerWhat will be the output of the following program?def fun(): try: print(1) finally: print(2)fun()Select all the correct statements given below.Options211221

🧐 Not the exact question you are looking for?Go ask a question

Solution

The output of the program will be:

1 2

This is because the print(1) statement is executed first, and then, regardless of any exceptions, the finally block is executed, which contains the print(2) statement. So, the correct answer is 12.

Similar Questions

What will be the output of the following Python code?def fun(): x=15 print(x)x=12fun()Options: Pick one correct answer from belowError151215 12

Choose the Correct Answer(s)What will be the output after the following statements?def xyz(): a = 56 xyz() print(a)OptionsNameErrora = 56xyz56

Choose the correct answerWhat will be the output of the following program?def func(a, **b): print(type(b))func('python', A = '1', B = '2')Select all the correct statements given below.Options<class 'int'><class 'tuple'><class 'dict'><class 'str'>

Select the correct answerWhat will be the output of the following Python code?def fun(n): if (n > 100): return n - 5 return fun(fun(n+11)); print(fun(45))Options7410050Infinite loop

What will be the output of the following Python code?1.  def foo():2.     try:3.       print(1)4.    finally:5.        print(2)6.   7.  foo()

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.