The correct answer is option 1.
Concept:
The given python snippet is,
- print("Insert positive number")
- def positive(number):
- assert number>=0, "Error: Negative Number"
- print (positive(5))
- print (positive(-5))
Assert statement:
In Python, the assert statement is used to continue the execution of the specified condition that has been evaluated to True. If the assert condition returns False, the AssertionError exception is raised with the error message specified.
Python def keyword:
The Python def keyword is used to define a function; it is used before the name of a function given by the user to construct a user-defined function. A function is a logical unit of code in Python that has a sequence of statements indented under a name specified using the "def" keyword.
Explanation:
The print function prints the statement like Insert positive number. Assert condition returns False, the AssertionError exception is thrown with the supplied error message. And prints the none in the function.
So it gives the error like,
Insert positive number
None
Traceback (most recent call last):
File "", line 5, in
File "", line 3, in positive
AssertionError: Error: Negative Number