Bird
Raised Fist0

What is wrong with this code if tools.py contains a function def greet():?:

medium📝 Debug Q6 of Q15
Python - Modules and Code Organization
What is wrong with this code if tools.py contains a function def greet():?:
import tools
tools.greet
AThe module tools is not imported correctly
BThe function greet is not called with parentheses
CThe function greet does not exist
DPython does not allow importing custom modules
Step-by-Step Solution
Solution:
  1. Step 1: Check function usage

    tools.greet is a reference to the function, but it is not called without ().
  2. Step 2: Understand function call syntax

    To execute the function, parentheses are needed: tools.greet()
  3. Final Answer:

    The function greet is not called with parentheses -> Option B
  4. Quick Check:

    Function call needs () [OK]
Quick Trick: Always add () to call a function [OK]
Common Mistakes:
MISTAKES
  • Forgetting parentheses to call functions
  • Thinking import is incorrect when it is correct
  • Assuming function does not exist without checking

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes