Answer to Question #237082 in Python for Joel

Question #237082

Create a function that takes an argument . Give the function parameter a unique name . Show what happens when you try to use that parameter name outside the function. Explain the results.


1
Expert's answer
2021-09-15T17:25:55-0400
friend="Tosh"
def Birthday(friend):
    print("Happy Birthday " + friend + ".")
    
Birthday("John")
print(friend)

When a parameter has the same name as a name defined outside the function, the function will not use the variable defined outside, it will only referenced the value that was passed to the parameter. So parameters will be used over variables of the same name within a function.



Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS