Bird
0
0

Given a file greetings.py with this code:

medium📝 Predict Output Q4 of 15
Python - Modules and Code Organization
Given a file greetings.py with this code:
def say_hello():
    return 'Hello!'

What will be the output of this code?
import greetings
print(greetings.say_hello())
Agreetings.say_hello
Bsay_hello
CHello!
DError: function not found
Step-by-Step Solution
Solution:
  1. Step 1: Understand the function call

    The function say_hello returns the string 'Hello!'.
  2. Step 2: Check how the function is called

    Using greetings.say_hello() calls the function correctly from the module.
  3. Final Answer:

    Hello! -> Option C
  4. Quick Check:

    Function call output = 'Hello!' [OK]
Quick Trick: Call functions with module_name.function_name() [OK]
Common Mistakes:
  • Forgetting parentheses to call the function
  • Trying to print function name instead of return value
  • Assuming function is not found without import

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes