Question

In: Computer Science

Python 3 Forming Functions Define and complete the functions described below. * function name: say_hi *...

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.

Solutions

Expert Solution

/* 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 */


Related Solutions

Python 3 Functions that give answers Define and complete the functions described below. * function name:...
Python 3 Functions that give answers Define and complete the functions described below. * function name: get_name * parameters: none * returns: string * operation: Here, I just want you to return YOUR name. * expected output: JUST RETURNS THE NAME...TO VIEW IT YOU CAN PRINT IT AS BELOW >>> print(get_name()) John * function name: get_full_name * parameters: fname (string) lname (string) first_last (boolean) * returns: string * operation: Return (again, NOT print) the full name based on the first...
''' Problem 1: Formin' Functions Define and complete the functions described below. The functions are called...
''' Problem 1: Formin' Functions Define and complete the functions described below. The functions are called in the code at the very bottom. So you should be able simply to run the script to test that your functions work as expected. ''' ''' * function name: say_hi * parameters: none * returns: N/A * operation: Uhh, well, just say "hi" when called. And by "say" I mean "print". * expected output: >>> say_hi() hi ''' ''' * function name: personal_hi...
''' Problem 1: Formin' Functions Define and complete the functions described below. The functions are called...
''' Problem 1: Formin' Functions Define and complete the functions described below. The functions are called in the code at the very bottom. So you should be able simply to run the script to test that your functions work as expected. ''' ''' * function name: say_hi * parameters: none * returns: N/A * operation: Uhh, well, just say "hi" when called. And by "say" I mean "print". * expected output: >>> say_hi() hi ''' ''' * function name: personal_hi...
''' Problem 2: Functions that give answers Define and complete the functions described below. The functions...
''' Problem 2: Functions that give answers Define and complete the functions described below. The functions are called in the code at the very bottom. So you should be able simply to run the script to test that your functions work as expected. ''' ''' * function name: get_name * parameters: none * returns: string * operation: Here, I just want you to return YOUR name. The expected output below assumes that your name is Paul. Of course, replace this...
Use Python for this quetions: Write a python functions that use Dictionary to: 1) function name...
Use Python for this quetions: Write a python functions that use Dictionary to: 1) function name it addToDictionary(s,r) that take a string and add it to a dictionary if the string exist increment its frequenc 2) function named freq(s,r) that take a string and a record if the string not exist in the dictinary it return 0 if it exist it should return its frequancy.
which statements are true about Python functions? a)Different functions cannot use same function name b)a function...
which statements are true about Python functions? a)Different functions cannot use same function name b)a function always returns some value c)different function cannot use the same variable names d) function must use the same parameter names as the corresponding variables in the caller what benefits does structuring a program through defining functions bring? a) there is a possibility of reducing the number of variables and/or objects that must be managed at any cost at any one point b)the program is...
PYTHON: Complete these functions in the module: f2c, a function to convert Fahrenheit temperatures to Celcius....
PYTHON: Complete these functions in the module: f2c, a function to convert Fahrenheit temperatures to Celcius. c2f, a function to convert Celcius termperatures to Fahrenheit. Write f2c() and c2f() as functions that return a true value or False. In other words, these functions do not print — they return. A "true value", in this case, would be a number that corresponds to a temperature. If the user enters an invalid temperature, the function should return False. Create _main(), a function...
python 3 please Define a function voweliest that takes as input a string and returns as...
python 3 please Define a function voweliest that takes as input a string and returns as output a tuple where the string that has the most vowels in it is the first element and the second is the number of vowels in that string. Note: don't worry about ties or capital letters Hint: consider defining and using a separate function that counts the number of vowels in a given string
python: modify an image (just show me how to write the two functions described below) 1.One...
python: modify an image (just show me how to write the two functions described below) 1.One way to calculate the contrast between two colours is to calculate the brightness of the top pixel (the average of the red, green and blue components, with all three components weighted equally), and subtract the brightness of the pixel below it. We then calculate the absolute value of this difference. If this absolute value is greater than a threshold value, the contrast between the...
Write code in Python: The edge-detection function (detectEdges) described in Chapter 7 and shown below returns...
Write code in Python: The edge-detection function (detectEdges) described in Chapter 7 and shown below returns a black and white image. Think of a similar way to transform color values so that the new image is still in its original colors but the outlines within it are merely sharpened. Then, define a function named sharpen that performs this operation. The function should expect an image and two integers as arguments. One integer should represent the degree to which the image...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT