Question

In: Computer Science

''' 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
* 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.

'''


# FUNCTIONS ARE CALLED BELOW HERE...NO NEED TO TOUCH ANYTHING
# UNLESS YOU WANT TO COMMENT SOMETHING OUT TO TEST THINGS
# ALONG THE WAY...

say_hi()
personal_hi("Larry")
personal_hi("Naomi")
introduce("Larry","Naomi")

Solutions

Expert Solution

'''
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

'''


def say_hi():
    print("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

'''


def personal_hi(name):
    print("Hi, " + name)


'''
* 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.

'''


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))


# FUNCTIONS ARE CALLED BELOW HERE...NO NEED TO TOUCH ANYTHING
# UNLESS YOU WANT TO COMMENT SOMETHING OUT TO TEST THINGS
# ALONG THE WAY...

say_hi()
personal_hi("Larry")
personal_hi("Naomi")
introduce("Larry", "Naomi")


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...
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...
complete sudoku problem //*************************************************************** // D.S. Malik // // This class specifies the functions to solve...
complete sudoku problem //*************************************************************** // D.S. Malik // // This class specifies the functions to solve a sudoku problem. //*************************************************************** class sudoku { public: sudoku(); //default constructor //Postcondition: grid is initialized to 0 sudoku(int g[][9]); //constructor //Postcondition: grid = g void initializeSudokuGrid(); //Function to promt the user to specify the numbers of the //partially filled grid. //Postcondition: grid is initialized to the numbers // specified by the user. void initializeSudokuGrid(int g[][9]); //Function to initialize grid to g //Postcondition: grid =...
1. Complete the calculations for the time value of money problem below. Type the answer to...
1. Complete the calculations for the time value of money problem below. Type the answer to your calculations in the text box. Then provide a short sentence to explain the appropriate investment decision and why. Question: Veda Financial offers an investment opportunity that pays $65 p.a. over a 25-year period, but the first payment commences 6 years from today. The security currently trades on the market at a price of $525. Your required rate of return for investing in these...
Complete the project functions for this week. These functions are winner(), save_game() and load_game(). To complete...
Complete the project functions for this week. These functions are winner(), save_game() and load_game(). To complete these functions, first remove the library function call from the function in the template (save_game_lib, etc), then replace that with your own code to complete the function. You can test your functions separately from the project by creating a small main() function that calls them (with appropriate inputs), or you can compile the entire project and see if it works. winner(): The winner function...
This exercise requires designing a program which solves the problem described in the problem statement below....
This exercise requires designing a program which solves the problem described in the problem statement below. Provide comments in your pseudo-code and Java program as necessary. Your solution must include these components: UML Class diagram Flowchart Pseudo-code Program Coded Program Output Problem Statement Design a class named Pet, which should have the following fields: name: The name field holds the name of a pet. type: The type field hold the type of animal that a pet is (for example, “dog”,...
Problem 1. Complete the table below. Please use the spreadsheet for your convenience and to submit...
Problem 1. Complete the table below. Please use the spreadsheet for your convenience and to submit your responses. Given: total Fixed Costs = $60 (i.e., the fixed cost of $60 does not change with output). The price of the product is $55 Production Schedule for a widget firm Output (Q) Total Fixed Costs (TFC) Total Variable Cost               (VC) Total Cost (TC) Average Fixed Cost (AFC) Average Variable Cost (AVC) Average Total Costs (ATC) Total Revenue (TR) Profit 0 0 1...
The picture below shows an incomplete pictorial representation of the situation described in this problem
The picture below shows an incomplete pictorial representation of the situation described in this problem. For symmetry reasons, the coordinate system is chosen so that its origin coincides with the point P at which you want to calculate the magnetic field, and the wire lies in the xy plane. The z axis is perpendicular to the page, pointing out of to the page.As outlined in the strategy above, the wire has been divided into very short segments. For clarity, only...
The diagram below shows the situation described in the problem. The focal length of the mirror...
The diagram below shows the situation described in the problem. The focal length of the mirror is labeled f; the scale on the optical axis is in centimeters. Draw the three special rays Ray1, Ray2, and Ray3 as described in the Tactics Box above, and label each ray accordingly. Draw the rays from the tip of the object to the mirror plane (dashed vertical line). Do not draw the reflected rays. Draw the vectors starting from the tip of the...
Directions: Write a SOAP note for the patient scenario described below. A complete S, O and...
Directions: Write a SOAP note for the patient scenario described below. A complete S, O and A section addressing all problems should be written. Only those problems that are primary or secondary priority need to be addressed in the plan (P section). Be sure to include references for recommendations. Date of encounter: 5/25/20 CC: Post-discharge follow-up Patient “Paul” is a 54 year-old Caucasian male being seen in the clinic following a recent hospital discharge 1 week ago for acute myocardial...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT