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
- int
- float
- bool
- 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
Which of the following is not a built-in function in Python?
- input()
- print()
- len()
- add()
What would be the return type of the following function in Python?
def mul(x, y): return x * y result= multiply(5, 2) print(result)- int
- float
- char
- string
Which of the following keywords is used to create a user-defined function?
- None
- define
- def
- func
The structure of a Python function contains a function header and …………… .
- return Statement
- Indented Block
- Function Body
- def Statement