R

Ram Sharma • 3.40K Points
Extraordinary

Q. What happens if you call a function before it is defined?

Code:
print(square(3))

def square(x):
return x * x
  • (A) It works fine
  • (B) Runtime error
  • (C) Syntax error
  • (D) Logical error
  • Correct Answer - Option(B)
  • Views: 2
  • Filed under category Python
  • Hashtags:

Explanation by: Ram Sharma
In Python, functions must be defined before they are called; otherwise, it raises a NameError.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.