Question

Problem 2: Restaurant Tipping IAE IOL (Fall 2015) HR . Problem 2 After many years, you have developed a system for determinin

please help me write the python code for this problem
0 0
Add a comment Improve this question Transcribed image text
Answer #1
# Solution
# Problem 2


def tip_amount(bill, good_service):
    # ADD YOUR CODE HERE
    if bill <= 30.00:     # when bill is less then or equals to $30.00
        return 5.00
    elif bill > 30.00 and good_service is True:    # when bill is greater the $30.00 and the service was good
        return bill*(25/100)     # 25% of the final bill
    else:
        return bill*(15/100)     # 15% of the final bill


# DO NOT DELETE THE FOLLOWING LINES OF CODE ! YOU MAY
# CHANGE THE FUNCTION CALLS TO TEST YOUR WORK WITH
# DIFFERENT INPUT VALUES.
if __name__ == "__main__":
    print("tip.amount(23.37, True) is", tip_amount(23.37, True))
    print()
    print("tip.amount(23.37, False) is", tip_amount(23.37, False))
    print()
    print("tip.amount(81.75, True) is", tip_amount(81.75, True))
    print()
    print("tip.amount(63.59, True) is", tip_amount(63.59, True))
    print()
    print("tip.amount(63.59, False) is", tip_amount(63.59, False))
    print()

Add a comment
Know the answer?
Add Answer to:
please help me write the python code for this problem Problem 2: Restaurant Tipping IAE IOL...
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
  • [3] In python, please help me write the functions needed for this problem: Another Way to do Parentheses: For this probl...

    [3] In python, please help me write the functions needed for this problem: Another Way to do Parentheses: For this problem, you will be given a string that contains parentheses, brackets, and curly braces ( (, ), [, ], {,} ) and other characters. As a human you are given a string of any characters, determine if the parentheses, brackets, and braces match. (No trailing or leading parentheses). The function called on an empty string will return True. Parentheses must...

  • 1) Translate the following equation into a Python assignment statement 2) Write Python code that prints...

    1) Translate the following equation into a Python assignment statement 2) Write Python code that prints PLUS, MINUS, O ZERO, depending on the value stored in a variable named N. 3) What is printed by: 3 - 1 while 5: while 10 Print ) Page 1 of 9 4) Write a Python while loop that reads in integers until the user enters a negative number, then prints the sum of the numbers. 1-2 of 9 4) Write a Python while...

  • Python 3 Problem: I hope you can help with this please answer the problem using python...

    Python 3 Problem: I hope you can help with this please answer the problem using python 3. Thanks! Code the program below . The program must contain and use a main function that is called inside of: If __name__ == “__main__”: Create the abstract base class Vehicle with the following attributes: Variables Methods Manufacturer Model Wheels TypeOfVehicle Seats printDetails() - ABC checkInfo(**kwargs) The methods with ABC next to them should be abstracted and overloaded in the child class Create three...

  • Using python, write code for problem. Please also put screenshot of your code. The following program...

    Using python, write code for problem. Please also put screenshot of your code. The following program will perform properly if the user enters 0 in response to the request for input. However, the program will crash if the user responds with "eight". Rewrite the program using a try/except statement so that it will handle both types of responses. See Fig. 6.1. while True: n = int (input ("Enter a nonzero integer: ")) if n! = 0: reciprocal = 1/n print...

  • use python IDEL Please highlight the answer Problem 2 Dictionary. Read the following code and answer...

    use python IDEL Please highlight the answer Problem 2 Dictionary. Read the following code and answer the next five questions about it. book1 = ("Alice":"arts", "Bob": "botany" "Clara": "chemistry", "Dasha": "digital media") book2 = {"Eve": "electronics", "Forest": "finances". "George": "geology", "Harry": "history". "Ivan": "Italian", "Joanna": "Japanese Arts") mybook=0 condition 1 = ? condition2 - ? condition3 = ? for key in book 1.keys(): mybook[key] =book 1.get(key) mybook.update(book 2) #first print statement print (mybook) if condition 1: mybook["Bob"] = "biochemistry" mybook["Eve"]...

  • can someone please help me write a python code for this urgently, asap Question: Write a Python function, minmp,...

    can someone please help me write a python code for this urgently, asap Question: Write a Python function, minmp, that is passed a file name and a metal alloy's formula unit structure*". The file will contain metal elements and their properties. The function will return a tuple of the element from the formula with the lowest melting point and that melting point Write a second function, molform, that will be called by the first function, to take the metal alloy's...

  • please help me with this python code thank you 1. Write a Student class that stores...

    please help me with this python code thank you 1. Write a Student class that stores information for a Rutgers student. The class should include the following instance variables: (10 points) o id, an integer identifier for the student o lastName, a string for the student&#39;s last name o credits, an integer representing the number of course-credits the student has earned o courseLoad, an integer representing the current number of credits in progress Write the following methods for your Student...

  • I need help with this problem. Using Python please. Thanks Construct a class “Monster” with the...

    I need help with this problem. Using Python please. Thanks Construct a class “Monster” with the following attributes: self.name (a string) self.type (a string, default is ‘Normal’) self.current_hp (int, starts out equal to max_hp) self.max_hp (int, is given as input when the class instance is created, default is 20) self.exp (int, starts at 0, is increased by fighting) self.attacks (a dict of all known attacks) self.possible_attacks (a dictionary of all possible attacks The dictionary of possible_attacks will map the name...

  • PYTHON. Continues off another code. I don't understand this. Someone please help! Comment the lines please...

    PYTHON. Continues off another code. I don't understand this. Someone please help! Comment the lines please so I can understand LinkedList ADT: class myLinkedList:     def __init__(self):         self.__head = None         self.__tail = None         self.__size = 0     def insert(self, i, data):         if self.isEmpty():             self.__head = listNode(data)             self.__tail = self.__head         elif i <= 0:             self.__head = listNode(data, self.__head)         elif i >= self.__size:             self.__tail.setNext(listNode(data))             self.__tail = self.__tail.getNext()         else:             current = self.__getIthNode(i - 1)             current.setNext(listNode(data,...

  • PYTHON. Continues off another code(other code is below). I don't understand this. Someone please help! Comment...

    PYTHON. Continues off another code(other code is below). I don't understand this. Someone please help! Comment the lines please so I can understand. There are short and med files lengths for each the list of names/ids and then search id file. These are the input files: https://codeshare.io/aVQd46 https://codeshare.io/5M3XnR https://codeshare.io/2W684E https://codeshare.io/5RJwZ4 LinkedList ADT to store student records(code is below). Using LinkedList ADT instead of the Python List. You will need to use the Student ADT(code is below) Imports the Student class...

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