1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Delicious77 [7]
3 years ago
15

Write a Python function that takes as input parameters base_cost (a float) and customer_type and prints a message with informati

on about the total amount owed and how much the tip was. You may recognize this program from HW1. We'll write a very similar program, just modifying it and using string formatting. Feel free to copy/paste code from before and modify it. As a reminder, the tip amounts are 10%, 15% and 20% for stingy, regular, and generous customers. And the tax amount should be 7%. The total amount is calculated as the sum of two amounts: check_amount = base_cost*1.07 tip_amount = tip_percentage*check_amount To receive full credit, you must use string formatting to print out the result from your function, and your amounts owed should display only 2 decimal places (as in the examples below). To "pretty print" the float to a desired precision, you will need to use this format operator (refer back to class slides for more explanation): %.2f Print the results to the console like in the example below, including the base cost of the meal, tax, three tip levels, and total for regular customers. Test cases: inputs: check_amount = 20, customer_type = "regular" --> output: Total owed by regular customer = $24.61 (with $3.21 tip) inputs: check_amount = 26.99, customer_type = "generous" --> output: Total owed by generous customer = $34.66 (with $5.78 tip) inputs: check_amount = 26.99, customer_type = "generous" --> output: Total owed by stingy customer = $16.83 (with $1.53 tip)

Computers and Technology
1 answer:
PSYCHO15rus [73]3 years ago
8 0

Answer:

Explanation:

Thanks for the question, here is the code in python

The 3rd example given in question is incorrect

inputs: check_amount = 26.99, customer_type = "generous" --> output: Total owed by stingy customer = $16.83 (with $1.53 tip)

the customer type in the above passed is generous but why the output is showing for stingy, I think this is incorrect

Here is the function, I have given explanatory names so that you can follow the code precisely and also used pretty formatting.

thank you !

===================================================================

def print_tip(base_cost, customer_type):

   TAX_PERCENTAGE = 1.07

   STINGY_PERCENTAGE = 0.1

   REGULAR_PERCENTAGE = 0.15

   GENEROUS_PERCENTAGE = 0.20

   check_amount = base_cost * TAX_PERCENTAGE

   tip_amount = 0.0

   if customer_type == 'regular':

       tip_amount = check_amount * REGULAR_PERCENTAGE

   elif customer_type == 'generous':

       tip_amount = check_amount * GENEROUS_PERCENTAGE

   elif customer_type == 'stingy':

       tip_amount = base_cost * STINGY_PERCENTAGE

   total_amount = tip_amount + check_amount

   print('Total owed by {} customer = ${} (with ${} tip)'.format(customer_type, '%.2f' % total_amount,'%.2f' % tip_amount))

print_tip(20, 'regular')

print_tip(26.99, 'generous')

print_tip(14.99, 'stingy')

You might be interested in
When the code that follows is executed, a message is displayed if the value the user entersvar userEntry = (prompt("Enter cost:"
Reika [66]

Answer:

The answer is "Option b".

Explanation:

In the given-code variable "userEntry" is defined that prompt the user to input value and in the next step, the conditional statement is used, which checks the input value is not a number and greater than 500 with use of OR operator. if the condition is true it uses the alert box to print the message, that's why in this question except "choice b" all were wrong.

4 0
3 years ago
Which is a software application used to analyze an organization’s data to improve decision making?
Ostrovityanka [42]

The software application used to analyze an organization’s data to improve decision making is said to be Business intelligence software.

<h3>What is Business intelligence?</h3>

Business intelligence is known to be a kind of app that has been set up and it is known to have a set of data analysis applications that has been made to meet a lot of information needs.

Business intelligence are known to be a kind of procedural and technical input that takes , stores, and analyzes the data made by a company's activities.

Learn more about Business intelligence from

brainly.com/question/13339276

3 0
1 year ago
Formatting. Given input that represents a floating point number, that is, made up of digits and at least one decimal point, conv
Ronch [10]

Answer:

s = input("Input a float: ")

print("{:12.2f}".format(float(s)))

Explanation:

  • Read a number  from user using the input function of Python.
  • Use the format function of Python to correctly format the output according to the given requirements.
  • Note: Use Python 3.6 or above for this code to run without any issue.

Output:

Input a float: 1234.56789

1234.57

3 0
3 years ago
Olivia wants to add buttons and clickable features to her website. Which language should she use?
Feliz [49]

B. HTML. I hope this helps!!!

8 0
3 years ago
Read 2 more answers
Three different numbers need to be placed in order from least to greatest. For example, if the numbers are ordered 9, 16, 4, the
Savatey [412]

Answer:

what are the three different numbers?

8 0
2 years ago
Other questions:
  • What can a folder on a computer contain?
    13·2 answers
  • 12. Noodle Tools is a website that
    8·1 answer
  • Which of the following definitions describes a chemical hazard?
    8·2 answers
  • If you have machines doing jobs, fewer staff are needed, therefore costs are
    5·2 answers
  • HELP ME PLZ QUICK Adam is writing a program that: 1) has the user guess a number, and 2) tells the user how many guesses it took
    11·1 answer
  • Important tools used in the _____ phase of the DMAIC process include a project charter, a description of customer requirements,
    10·1 answer
  • What other options are there besides jail for 16 year old that commit a crime?
    8·2 answers
  • What is bug in computer?​
    12·1 answer
  • Check all that apply to Raster Graphics
    13·1 answer
  • A numeric test score is to be converted to a letter grade of A, B, or C according to the following rules: A score greater than 9
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!