Question

Python programming:   (10pts) Write a function that calculates the tip for a meal.The user can choose...

Python programming:

  1.   (10pts) Write a function that calculates the tip for a meal.The user can choose the percentage of tip they wish to give. Show that it works by calculating an 18% tip for a meal that costs 45.89.
  1. (15pts) Write a program that computes and display the charges for a patients hospital stay. The program should ask if the person is an in-patient or an out-patient. If the patient is an in-patient, ask the user to enter the number of days spent in the hospital, the daily rate will be $250. Also ask for the hospital’s medication charges. Include in the bill lab services which will be $100/per patient. If the patient is an out-patient ask for the medication charges and charge them the lab fee. Please use at least two functions in your program (one for in-patients and one for out-patients).

Test your program with an inpatient who stays 5 days in the hospital with $300 of medicine expenses and an out-patient who has medication bills of $1000.

Homework Answers

Answer #1

1.

def tip(per,cost):
    tipp=per*cost/100
    print (tipp)
tip(18,45.89) # prints 8.2602


2

a=input("Enter i for in_patient o for out_patient: ")
def in_patient():
    d=int(input("Enter number of days spent in the hospital:"))
    m=int(input("Enter medication charges:"))
    lab=100
    total=d*250+m+lab
    print('$',total)
def out_patient():
    m=int(input("Enter medication charges:"))
    lab=100
    total=m+lab
    print('$',total)
if (a=='i'):
    in_patient()
elif (a=='o'):
    out_patient()
else:
    print ("Invalid input")

Know the answer?
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
Similar Questions
Write a Python program which calculates the average of the numbers entered by the user through...
Write a Python program which calculates the average of the numbers entered by the user through the keyboard. Use an interactive loop and ask the user at each iteration if he/she wants to enter more numbers. At the end dispay the average on the screen. Using built-in library functions for finding average is not allowed. Sample output of the program: Enter a number > 23 More numbers (yes or no)? y Enter a number > 4 Do you have more...
Function Example: Write a Python function that receives two integer arguments and writes out their sum...
Function Example: Write a Python function that receives two integer arguments and writes out their sum and their product. Assume no global variables. def writer(n1, n2): sum = n1 + n2 product = n1*n2 print("For the numbers", n1, "and", n2) print("the sum is", sum) print("and the product is", product) ... 1) Create a PYHW2 document that will contain your algorithms in flowchart and pseudocode form along with your screen shots of the running program. 2) Create the algorithm in both...
Python programming Write a program that prompts the user to input the three coefficients a, b,...
Python programming Write a program that prompts the user to input the three coefficients a, b, and c of a quadratic equationax2+bx+c= 0.The program should display the solutions of this equation, in the following manner: 1. If the equation has one solution, display ONE SOLUTION:, followed by the solution, displayed with4 digits printed out after the decimal place. 2. If the equation has two real solutions, display TWO REAL SOLUTIONS:, followed by the two solutions, each displayed with4 digits printed...
I only need/want question #4 answered. Only Question 4! Thanks! Twin Falls Community Hospital is a...
I only need/want question #4 answered. Only Question 4! Thanks! Twin Falls Community Hospital is a 250-bed, not-for-profit hospital located in the city of Twin Falls, the largest city in Idaho’s Magic Valley region and the seventh largest in the state. The hospital was founded in 1972 and today is acknowledged to be one of the leading healthcare providers in the area. Twin Falls’ management is currently evaluating a proposed ambulatory (outpatient) surgery center. Over 80 percent of all outpatient...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT