Exercise
Functions: Hello And Goodbye
Objective
Develop a Python program where the main function should look like this:
SayHello()
SayGoodbye()
You must define the functions SayHello and SayGoodbye, and they will be called from within the main function.
Example Python Exercise
Show Python Code
# Define the function SayHello
def SayHello():
# Print a greeting message
print("Hello, welcome to the program!") # The greeting message is printed when SayHello() is called
# Define the function SayGoodbye
def SayGoodbye():
# Print a goodbye message
print("Goodbye, thank you for using the program!") # The goodbye message is printed when SayGoodbye() is called
# Main function to execute the program
def main():
# Call the SayHello function to display the greeting message
SayHello() # This will output: "Hello, welcome to the program!"
# Call the SayGoodbye function to display the goodbye message
SayGoodbye() # This will output: "Goodbye, thank you for using the program!"
# Call the main function to run the program
main() # This triggers the execution of SayHello and SayGoodbye
Output
Hello, welcome to the program!
Goodbye, thank you for using the program!
Share this Python Exercise