“””Task (30 pts total)——————-Create a simple business object that computes total revenue for a customer order. Part 1 (18pts): Constructor (__init__): Write a class Order with: – __init__(self, order_id: str, customer: str, item_tuples: list) * Store the arguments `order_id` and `customer` as instance attributes. * item_tuples is provided as a list of tuples, each in the form: (prod_code, price, quantity) where `prod_code` is a string, `price` is a float, and `quantity` is an integer. Here “prod_code” is a short product identifier (e.g., “P1001”). * Inside __init__, convert this list of tuples into a list of dictionaries, {“prod_code”: …, “price”: …, “quantity”: …}, and store it in self.items. Part 2 (6pts): Method (total_revenue): Implement total_revenue(self) -> float * Calls safe_line_total(item, 0.15) for each item to apply a 15% discount. * Returns the total after discount. Part 3 (6pts): Function (safe_line_total): Define safe_line_total(item: dict, discount: float) -> float * Computes: price × quantity × (1 – discount) * discount is a decimal reduction (e.g., 0.10 means 10% off)””” class Order: “””Simple business object representing a customer’s order.””” # (1) Constructor: 5pt + 5pts + 8pts = 18pts def __init__(self, order_id: str, customer: str, item_tuples: list): self.order_id = … # TODO: implement self.customer = … # TODO: implement # convert list of tuples to list of dicts (use tuple unpacking for clarity) self.items = … # TODO: implement raise NotImplementedError # (2) Method: 6pts def total_revenue(self) -> float: “””Return total revenue after 15% discount on all items.””” # TODO: implement raise NotImplementedError # (3) Helper Function: 6ptsdef safe_line_total(item: dict, discount: float) -> float: “””Compute line revenue for one item with a given discount rate.””” # TODO: implement raise NotImplementedError # testing:# sample input dataitem_tuples = [ (“P1001”, 10.0, 2), (“P1002”, 5.0, 3), (“P1003″, 2.5, 4),] # instantiate the Orderorder = Order(order_id=”O123″, customer=”Yankun”, item_tuples=item_tuples) # print testing infoprint(“testing:”)print(” order_id =”, order.order_id) # O123print(” customer =”, order.customer) # Yankunprint(” items =”, order.items) # [{‘prod_code’: ‘P1001’, ‘price’: 10.0, ‘quantity’: 2}, # {‘prod_code’: ‘P1002’, ‘price’: 5.0, ‘quantity’: 3}, # {‘prod_code’: ‘P1003’, ‘price’: 2.5, ‘quantity’: 4}] total = order.total_revenue()print(“\ncomputed total revenue (after 15% discount):”, total)# expected:# items: (10*2) + (5*3) + (2.5*4) = 20 + 15 + 10 = 45# after 15% discount → 45 * 0.85 = 38.25# computed total revenue (after 15% discount): 38.25
Blog
# B8. Given `rng = np.random.default_rng(404)`, assign a SIN…
# B8. Given `rng = np.random.default_rng(404)`, assign a SINGLE expression that draws # 5 random integers in [0, 10).rng = np.random.default_rng(404)B8 = … # your answer here
# B5. Given `s = “2025-10-06″`, assign the first four charac…
# B5. Given `s = “2025-10-06″`, assign the first four characters as a substring via a SINGLE expression.s = “2025-10-06″B5 = … # your answer here
# Q7. Which reads Excel sheet ‘Summary’ from ‘file.xlsx’?# …
# Q7. Which reads Excel sheet ‘Summary’ from ‘file.xlsx’?# A) pd.read_excel(‘file.xlsx’)# B) pd.read_excel(‘file.xlsx’, sheet_name=’Summary’)# C) pd.read_excel(‘Summary’, ‘file.xlsx’)# D) pd.read_excel(‘file.xlsx’).sheet(‘Summary’)
# Q5. Which keyword produces a GENERATOR when used in a func…
# Q5. Which keyword produces a GENERATOR when used in a function body?# A) return# B) yield# C) next# D) iter
# B3. Given `L = [1, 2, 3, 4]`, assign a SINGLE slicing expr…
# B3. Given `L = [1, 2, 3, 4]`, assign a SINGLE slicing expression that returns [2, 3].L = [1, 2, 3, 4]B3 = … # your answer here
For extemporaneous speaking, this type of outline is a detai…
For extemporaneous speaking, this type of outline is a detailed, full-sentence outline developed during the preparation process of extemporaneous speaking; it includes the entire message followed by a Works Cited (or bibliography).
Kafka Message Offset numbers are:
Kafka Message Offset numbers are:
Let there is a Black Friday sale coming up for an online sto…
Let there is a Black Friday sale coming up for an online store that you have implemented using a Kafka cluster comprised of three brokers. For the sale, you created a topic named black_friday_orders with with one partition with 1 replica count. Based on the amount of the incoming traffic to handle, you realize that the current configuration is not scalable. What changes will you make to yield higher throughput?
What is the first line in every Dockerfile? What is this use…
What is the first line in every Dockerfile? What is this used for?