B02B-2015D – Computer Sir Ki Class

Login


Lost your password?

Don't have an account ?
Register (It's FREE) ×
  

Login
[lwa]



Exam Questions-CBSE12D-2015-B02B #PYTHON#6522    siteicon   siteicon  

Problem Statement - B02B-2015D

What will be the output of the following python code ? Explain the try and except used in the code.

U=0
V=6
print 'First'
try:
    print 'Second'
    M=V/U
    print 'Third',M
    except ZeroDivisionError :
        print V*3
        print 'Fourth'
    except:
        print V*4
        print 'Fifth'

Solution

TC++ #6522

First
Second
18
Fourth

The code written within try triggers the exception written after except ZeroDivisionError: in case there is a division by zero error otherwise the default exception is executed


Share

CSKC| Created: 14-Jan-2019 | Updated: 14-Jan-2019|CBSE12D-2015









Back