KnowledgeBoat Logo
|

Robotics & Artificial Intelligence

What would be the return type of the following function in Python?

def is_positive(number): 
    if number > 0: 
        return True 
    else: 
        return False
  1. int
  2. float
  3. bool
  4. char

Python Functions

3 Likes

Answer

bool

Reason — The return type of a function depends on the value returned by the return statement. In the given function, the return statements return either True or False, which are Boolean values. Therefore, the return type of the function is bool.

Answered By

2 Likes


Related Questions