Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Appreciate the assistance of question 2 for my Cse 101 lab Tutor. The first phot

ID: 3586936 • Letter: A

Question

Appreciate the assistance of question 2 for my Cse 101 lab Tutor. The first photo is the question, and the second photo is an example of the question. Thank you for your time

filename as "lab4.py (all lowercase) to avoid breaking our testing setup. If you rename the skeleton file or any of the functions that it contains, you may lose points on the assignment 1. Start by completing the student() function. This function does not take any arguments, and it sh return a single string containing your smith") ful name and Blackboard username (NetiD) (e.g. -John Smith- and 2. Finally, tunction takes a single list argument whose ferst complete the lunchBillo function. This element is a numerical value (the base price of my lunch order) and whose remaining elements ( any) are 2-element sublists that modity the base price as d A sublist whose first element is the string "ip" means to add a tip of the given percentage (the second element) to the total so far. For example, the sublist [ . tip", 25] means-apply a 25% tp" by multiplying the current bill amount by 1.25 (thus increasing it by 25%). To get the to mumpler, ao amount / 100) to 1.0 p A subist whose first element is the string "extra" means to add the specified amount (the second element) to the total so far. For example, te sublist [ "extra", si means"add 5 to the cument bil amount" A sublist whose first element is the string "coupon" means to subtract the specified amount (the second element) from the total so far. For example, ["coupon", 31 means subtract 3 from the current bill amount A sublist whose first element is the string "discount means to subtract the specified percentage (the second element) from the total so far. For example, riscount", 35) means to apply a 35% discount by multiplying the current bill amount by 0.65 (to get the discount multiplier, subtract (discount amount / 100) from 1) The function argument may contain any number of tip, extra, coupon, and discount sublists, in any order. These modifiers MUST be applied in the same order that they appear in the main list. For each modifier, print a brief summary of the adjustment (e g-Adding a 20% tip. The tunction should return the final bill amount, or 0 if the final amount is less than 0 (meaning that my lunch was tree) Stony Brook University

Explanation / Answer

def student():
   return "John Smith" , "jsmith"

def lunchbill(list):
    order = list[0]
  
    for i in range(1,len(list)):
       
        if list[i][0] == "tip":
           order = order + (list[i][1]/100) * order
        if list[i][0] == "discount":
           order = order - (list[i][1]/100) * order
        if list[i][0] == "coupon":
           order = order - list[i][1]
        if list[i][0] == "extra":
           order = order + list[i][1]
    if order < 0 :
       return 0
    else:
       return order
  

name, username = student()
print(" %.2f " % lunchbill([12.34,["tip",15],["discount",25],["extra",1.5]]))
print(" %.2f " % lunchbill([10,["tip",20],["discount",20],["coupon",2],["coupon",2],["coupon",1],["discount",50],["coupon",2.55]]))

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote