LearnFrenzy
Sign in Take a free test

Functions · Predict the Output · Question 11

Early returns and a bare return Answer, explanation & discussion

  • Output
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
Question 11 Back to Exercise

What is the output of the following Python program?

main.py
def check(n):
    if n < 0:
        return "negative"
    if n == 0:
        return
    return "positive"

print(check(-1), check(0), check(5))
  • A negative 0 positive
  • B negative None positive Correct
  • C negative positive
  • D negative positive positive
Correct Answer: Option B

A bare return ends the function and returns None.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links