Solution: Using Functions
Review the solution of tracking the flow of the code in which functions are present.
We'll cover the following
Solution
Let’s go over the solution explanation for this challenge.
This program defines two functions, say_hi()
and say_bye()
. The say_hi()
function prints out two messages, "hi there! how are you?"
and "it's nice to see you!"
. The say_bye()
function prints out two messages, "goodbye!"
and "take care."
, and then calls the say_hi()
function.
When the program runs, it first prints out the message "starting program:"
. Then it calls the say_hi()
function, which prints out the messages "hi there! how are you?"
and "it's nice to see you!"
. Next, it calls the say_bye()
function, which prints out the messages "goodbye!"
and "take care."
, and then calls the say_hi()
function, which prints out the messages "hi there! how are you?"
and "it's nice to see you!"
again.
Finally, the program prints out the message "ending program."
.
The correct output of the pseudocode will be:
starting program:
hi there! how are you?
it's nice to see you.
goodbye!
take care.
hi there! how are you?
it's nice to see you.
ending program.
Get hands-on with 1400+ tech skills courses.