Generation

generate functionMon, 12 Dec 2022

Complete function saleHotdogs/SaleHotDogs/sale_hotdogs, function accepts 1 parameter:n, n is the number of hotdogs a customer will buy, different numbers have different prices (refer to the following table), return how much money will the customer spend to buy that number of hotdogs. Use the only ternary operator number of hotdogs price per unit (cents) if n < 5 then 100 if n >= 5 and n < 10 then 95 if n >= 10 90

def sale_hotdogs(n): return (n < 5) * (n * 100) + (n >= 5 and n < 10) * (n * 95) + (n >= 10) * (n * 90)

Questions about programming?Chat with your personal AI assistant