Important Notice:

Course Content
Conditional and Iterative Statements (Chapter-5) M3-R5.1
About Lesson
assert statement:-

            Python Program में debugging के लिए ‘assert’ keyword का इस्तेमाल किया जाता है। ‘assert’ keyword के साथ जब condition true होता है तब कुछ नहीं होता और जब condition false होता है तब ‘AssertionError’ occur होता है।

assert 4==4 #No Exception

assert 4==5 #AssertionError Exception Occurred

 

num=int(input(‘enter a number ‘))

assert num>=0

print(‘You entered: ‘,num)

 

assert statement:-

     ‘Assert’ keyword is used for debugging in Python program. With ‘assert’ keyword, when the condition is true then nothing happens and when the condition is false then ‘AssertionError’ occurs.

assert 4==4 #No Exception

assert 4==5 #AssertionError Exception Occurred

num=int(input(‘enter a number ‘))

assert num>=0

print(‘You entered: ‘,num)

           

error: Content is protected !!