In: Computer Science
Python 3 Forming Functions
Define and complete the functions described below.
* function name: say_hi
* parameters: none
* returns: N/A
* operation:
just say "hi" when called.
* expected output:
>>> say_hi()
hi
* function name: personal_hi
* parameters: name (string)
* returns: N/A
* operation:
Similar to say_hi, but you should include the name argument in the
greeting.
* expected output:
>>> personal_hi("Samantha")
Hi, Samantha
* function name: introduce
* parameters: name1 (string)
name2 (string)
* returns: N/A
* operation:
Here you are simply including the two names in a basic
introduction.
* expected output:
>>> introduce("Samantha","Jerome")
Samantha: Hi, my name is Samantha!
Jerome: Hey, Samantha. Nice to meet you. My name is Jerome.
/* PLEASE INDENT CODE USING SCREENSHOT TO RUN WITHOUT ERROR */
Define and complete the functions described below.
* function name: say_hi
* parameters: none
* returns: N/A
Ans.
def say_hi():
print("hi")
say_hi()
* function name: personal_hi
* parameters: name (string)
* returns: N/A
* operation:
Ans.
def personal_hi(name):
print("Hi, {}".format(name))
personal_hi("Samantha")
* function name: introduce
* parameters: name1 (string)
name2 (string)
* returns: N/A
* operation:
Ans.)
def introduce(name1,name2):
print("{}: Hi, my name is {}!".format(name1,name1))
print("{}: Hey, {}. Nice to meet you. My name is
{}.".format(name2,name1,name2))
introduce("Samantha","Jerome")
/* PLEASE UPVOTE */