Page 1 of 1

NO import and NO dictionary 1. Mee Mee and Lee Lee have come to visit Dee Dee and she remembers that there are cookies,

Posted: Tue Jul 05, 2022 10:26 am
by answerhappygod
NO import and NO dictionary
1. Mee Mee and Lee Lee have come to visit Dee Dee and she remembers that there are cookies, muffins and sweets, so she takes three plates and puts the same amount of each dessert on each plate and what is left on a table. In case there is not enough of any dessert (<3), Dee Dee puts that dessert on the table and nothing on each plate.
def dessert_distribution(qty_c, qty_m, qty_s):
Description: Given the quantity of cookies (qty_c), muffins (qty_m) and sweets (qty_s), return how they would be distributed on each plate and on the table.
Parameters: quantity of cookies (qty_c), muffins (qty_m) and sweets (qty_s). Each integer. Assume qty_c, qty_m, qty_s are >=1 and <=7
Return value: How the desserts would be distributed on each plate and on the table (string). Use a tab to separate each distribution. If a dessert is not placed on a plate or on the table, do not print any character for it.
Examples: dessert_distribution(2,4,7) → '🧁🍬🍬 🍪🍪🧁🍬'
dessert_distribution(3,6,3) → '🍪🧁🧁🍬 '
dessert_distribution(1,2,1) → ' 🍪🧁🧁🍬'
2. Mandak has heard about Dexter's new experiment and decides to buy what he needs to try to finish it first. On a list, he writes down (in order of priority) the items he must buy. He wants to know how many items can purchase with the cash he currently has.
def how_many_items(items, cash):
Description: Given a list of items and cash, return how many items can be purchase.
Parameters: items (list of strings), cash (float).
Assume The length of the list is >=1 and <=10
An item can be more than once in the list.
Return value: how many items can be purchase (int), based on the items list and these prices:
Examples:
how_many_items(["hammer","screws","box nails"],33.57) → 3
how_many_items(["batteries","screws"],5) → 0
how_many_items(["screws","screws","screws"],1.76) → 2