Question

Q3 Coding challenge 2 5 Points Suppose you are hired as a developer in a pizzeria. This pizzeria wants to store its order in
0 0
Add a comment Improve this question Transcribed image text
Answer #1

def minPizza(pizza_orders):
   i=0
   for username in pizza_orders.keys():   #looping across the dictionary using keys (username)
       #calculating the total money spent
       total_cost=pizza_orders[username]["number_of_pizzas"] * pizza_orders[username]["price_per_pizza"]
       if(i==0):   #if first loop
           least_spent_username=username
           least_spent_value=total_cost
           i=1
       else:   #for all other loops except the first
           if(total_cost<least_spent_value):   #if less than least
               #replace the least with current values
               least_spent_username=username
               least_spent_value=total_cost

   return least_spent_username   #return username

pizza_orders={
   "mark123":{
       "number_of_pizzas":3,
       "price_per_pizza":20.00
   },
   "alice666":{
       "number_of_pizzas":2,
       "price_per_pizza":24.00
   }
}
print(minPizza(pizza_orders))

Please give a like

Add a comment
Know the answer?
Add Answer to:
Q3 Coding challenge 2 5 Points Suppose you are hired as a developer in a pizzeria....
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
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