B02B-2015 – Computer Sir Ki Class

Login


Lost your password?

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

Login
[lwa]



Exam Questions-CBSE12A-2015-B02B #PYTHON#6352    siteicon   siteicon  

Problem Statement - B02B-2015

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

A=0
B=6
print 'One'
try:
    print 'Two'
    X=B/A
    Print 'Three'
except ZeroDivisionError:
    print B*2
    print 'Four'
except:
    print B*3
    print 'Five'

Solution

TC++ #6352

One
Two
12
Four
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: 11-Jan-2019 | Updated: 11-Jan-2019|CBSE12A-2015









Back