Question

In: Computer Science

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 and last names
passed in as arguments. The first_last argument will be True if you should
return the name as <fname lname> and False if you shoudl return the name
as <lname, fname>.
* expected output:

# just return the name
>>> print(get_full_name("John","Doe",True))
John Doe
>>> print(get_full_name("John","Doe",False))
Doe John
* function name: get_circle_area
* parameters: radius (float)
* returns: float
* operation:
Return the area of a circle with the given radius. Use 3.14 as Pi. And Google if for
some reason you've forgotten how to get the area of a circle.
* expected output:

Just return the value
>>> print(get_circle_area(5.0))
78.5
>>> print(get_circle_area(2.5))
19.625

Solutions

Expert Solution

Hopefully all yours doubt will clear if you have left with any doubt please let me know in comment. I will try my best to resolve that.

Here i am posting code and screenshot of program so that you have a clear idea about indentation and output with it.

Code :-

# Function will return name (John)
def get_name():
    # store name in variable name which will be return to main function
    name = "John"
    return name

# Function will return full name based on first and last name
def get_full_name(fname, lname, first_last):
    # If value of first_last is True means first name come first in full name then last name
    if first_last:
        # string concatenation of first name, space and last name
        return (fname + " " + lname)
    # If value of first_last is False means last name come first in full name then first name
    else:
        # string concatenation of last name, space and first name
        return (lname + " " + fname)

# Function will calculate area of circle
def get_circle_area(radius):
    # calculate area and store in area variable
    area = 3.14 * radius * radius
    # return  area of circle to main function
    return  area

# print name using get_name function
print(get_name())

# print full name using get_full_name function
print(get_full_name("John","Doe",True))
print(get_full_name("John","Doe",False))

# print area of circle using get_circle_area
print(get_circle_area(5.0))
print(get_circle_area(2.5))

Screeenshot of program :-

Screenshot of output :-


Related Solutions

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...
''' 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...
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.
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
Give the name of cranial nerve X and one of its functions. Give the name and...
Give the name of cranial nerve X and one of its functions. Give the name and number of a cranial nerve - other than I, II, VIII, or X - and state one of its functions. Describe in detail the process of synaptic transmission. Start with the arrival of an action potential at a knob.  Include details regarding an IPSP and an EPSP example in the postsynaptic neuron. Also include clearing the synaptic cleft (gap). Use the back of this page...
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...
Please answer using python 3 and def functions! Lab 2 Drill 3: (function practice) create and...
Please answer using python 3 and def functions! Lab 2 Drill 3: (function practice) create and use a function named highest() that takes three inputs and returns the highest number. After you have got it working, try calling the function with inputs ‘hat’, ‘cat’, ‘rat’.
Write python 3 code to define a function that uses three arguments, and returns a result....
Write python 3 code to define a function that uses three arguments, and returns a result. The function returns True if the first argument is more than or equal to the second argument and less than or equal to the third argument, otherwise it returns False. Write a python 3 code for function main, that does the following: creates a variable and assign it the value True. uses a while loop which runs as long as the variable of the...
In PYTHON 3 using functions. Per the client, you have the following information:  customer name, burger choice,...
In PYTHON 3 using functions. Per the client, you have the following information:  customer name, burger choice, time of purchase, and total bill. By the end of the day, your program will provide the following information: 1. Top three best clients with the highest spending 2. Name of client with second to last lowest bill 3. busiest hour of the day based on number of clients Assumptions 1. Your program will not handle more than 100 clients per day 2. The...
Task 2 requires you to accurately complete the activities described in each question. Complete the answers...
Task 2 requires you to accurately complete the activities described in each question. Complete the answers in your own Excel document, putting your name at the top along with the Task and Task letter appropriate to each answer and submit below for your Assessor. a) Make the Journal entry to record the sale of merchandise that cost $6,000, for $10,000 cash. b) Record journal entries for the following transactions. Purchased office furniture for $3,200, agreed to pay the entire amount...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT