English

What would be the output of the following code? def evenNumber (number): assert (number % 2 == 0), "not even" print ("Number is even")evenNumber (7) -

Advertisements
Advertisements

Question

What would be the output of the following code?

def evenNumber (number):
           assert (number % 2 == 0), "not even"
           print ("Number is even")
evenNumber (7)

Options

  • No output

  • Not even

  • Number is even

  • Assertion Error: not even

MCQ

Solution

Assertion Error: not even

Explanation:

The number seven is not even. AssertionError is raised because the remainder for 7/2 is not zero.

shaalaa.com
Built-in Exceptions
  Is there an error in this question or solution?
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×