Question

Using python, write a function that expects two parameters, one will be the amount of the...

Using python, write a function that expects two parameters, one will be the amount of the dinner check (a float), and the other one will be the percentage of the tip expressed as an integer(20 for 20 percent). The user will give as input these two values. The function will return to the amount that the tip should be. Output the results.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

PYTHON CODE

# function to compute tips
def compute_tips(check,tipp):

    #computing tips based on the check
    r=(tipp/100)*check

    # returning the tips
    return r

# testing
if __name__=="__main__":
    print(compute_tips(200.20,10))
    print(compute_tips(533.40,20))

SCREENSHOT OF OUTPUT

20.02 106.68

Add a comment
Know the answer?
Add Answer to:
Using python, write a function that expects two parameters, one will be the amount of the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a value- return function which accepts the cost and the tip percentage (tipPercentage) as parameters....

    Write a value- return function which accepts the cost and the tip percentage (tipPercentage) as parameters. The function must calculate the total meal amount that the customer must pay including the tip. Thus, values of tipPercentage can be 15 representing 15%, 18 representing 18%, and 20 representing 20%. An example of the cost of the meal with 15% is as follows : dinner cost * 0.15 + dinner cost. Double costOfMeal (double price, int tipPercentag) {

  • 1. Write code for a function that receives two parameters (a,and b) by value and two...

    1. Write code for a function that receives two parameters (a,and b) by value and two more parameters (c and d) by reference. All parameters are double. The function works by assigning c to (a/b) and assigning d to (a*b). The function has no return value. From main, use scanf to get two numbers, then call the function, and then display both outcome values to the output in a printf statement. 2. After part 1 is completed, write code to...

  • Write a complete program utilizing functions. The function accepts two parameters: one representing a radius of...

    Write a complete program utilizing functions. The function accepts two parameters: one representing a radius of type float, the other parameter is an integer “select” which chooses between finding the area of a circle or the volume of sphere. If the select variable is 1, then area is calculated. If the select value is 2, then volume is calculated. If the select value is any other value, then the function returns 0. Test your function in main by calling it...

  • Use Python 3.7 to Write a function called volume_of_box() that takes three parameters (the length, width,...

    Use Python 3.7 to Write a function called volume_of_box() that takes three parameters (the length, width, and height of the box) and returns the volume of the box. Then, use that function in a program which prompts the user to enter the dimensions of a box and returns the volume. Your program should include input validation to ensure that the values entered are positive and should be able to accept float values. Many thanks for all your time and effort...

  • Write a C++ program that contains a function called swapNums. This function takes two integer parameters,...

    Write a C++ program that contains a function called swapNums. This function takes two integer parameters, swaps them in memory, and outputs the results (there is nothing to return). In main, ask the user to enter two different numbers, output them as entered (step 1), call the function swapNums() which will output the numbers swapped (step 2), and then output the values again in main (step 3). You should have three sets of output. Sample run (10 and 5 were...

  • Python Simple Programming Write a program in Python that calculates the tip and total for a...

    Python Simple Programming Write a program in Python that calculates the tip and total for a meal at a restaurant. When your program is run it should ... Calculate the tip and total for a meal for a restaurant Print the name of the application "Tip Calculator" Get input from the user for cost of meal and tip percent Print the tip and total amounts. The formula for calculating the tip amount is: tip = cost of meal * (tip...

  • %%Python Question%% get_min_payment() • Parameters ◦ the total amount of the mortgage (called the principal; should...

    %%Python Question%% get_min_payment() • Parameters ◦ the total amount of the mortgage (called the principal; should be a positive number) ◦ the annual interest rate (should be a float between 0 and 1) ◦ the term of the mortgage, in years (should be a positive integer; default value: 30) ◦ the number of payments per year (should be a positive integer; default value: 12) • Functionality ◦ Compute the minimum mortgage payment. Should use the formula A= Pr(1+r) n (1+r)...

  • Python 3 code Write a function named coinflip that accepts an input called flips. The function...

    Python 3 code Write a function named coinflip that accepts an input called flips. The function should sim-ulate flipping a coin flips times. The function should return True if the coin was the same result for every flip. You can assume the function receives a positive integer as input. Write a second function named simulation that runs trials of the coin flip experiment. simulation should accept two parameters: the number of trials, and the number of coin flips to do...

  • IN PYTHON Write a function that does not receive parameters but the user must enter numbers...

    IN PYTHON Write a function that does not receive parameters but the user must enter numbers until they give him a 0. While the user does not give him a 0, the program must show how many numbers were entered, the sum of these numbers and the average (not counting the 0) example: 16 4 42 8 23 15 0 output: numbres = 6 sum = 108 average = 18.0

  • Python Write a function that takes in two numbers as parameters. The function will then return...

    Python Write a function that takes in two numbers as parameters. The function will then return the value of the first parameters squared by the second parameter. Print the value of the return statement. Take a screenshot of both your code and your properly executed code after you have run it. Submit the screenshots here along with your .txt file.

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT