Use this dictionary: marks = {“Selam”: 88, “Abel”: 45, “Merhawi”: 91, “Lidya”: 38} Create an empty list called passed. Loop with items(). A mark of 50 or more is a pass. Print Name – PASS or Name – FAIL, and …
Use the dictionary below: marks = {“Selam”: 88, “Abel”: 74, “Merhawi”: 91} Loop with items() and print each student as Name: mark. Inside the same loop, add each mark to a variable called total (start it at 0). After the …
A shop in Massawa keeps its stock in a dictionary: stock = {“bread”: 30, “milk”: 0, “tea”: 14, “salt”: 0, “rice”: 8} Create an empty list called sold_out. Loop over a list copy of the keys. For every item with …
A user profile contains two keys that should not be there: profile = {“name”: “Abel”, “age”: 15, “city”: “Keren”, “password”: “abc123”, “temp”: “delete me”} Remove “password” with pop() and store the returned value in a variable called removed. Remove “temp” …
Here are the drinks ordered at a café in Keren this morning: drinks = [“tea”, “coffee”, “tea”, “juice”, “tea”, “coffee”] Build a dictionary called counts that stores how many times each drink was ordered. Start with an empty dictionary. Loop …
A café in Asmara starts an order like this: order = {“customer”: “Selam”, “item”: “tea”} Add “quantity” with the value 2 using square brackets. With one update(), add “city”: “Asmara” and “paid”: False. Print order, then print its length. Expected …
Selam’s marks are stored in a dictionary: marks = {“math”: 72, “english”: 85, “science”: 64} The teacher gives 5 bonus points in math and in science. Add 5 to each value using its current value — do not type the …
A bus company stores one route like this: bus = {“route”: “Asmara – Keren”, “seats”: 40, “fare”: 50} Change “fare” to 60 using square brackets. With one update(), change “seats” to 45 and “route” to “Asmara – Massawa”. Print bus. …
The marks of a class are stored like this: marks = {“Selam”: 88, “Abel”: 74, “Merhawi”: 91} Create students, a list of all the keys. Create all_marks, a list of all the values. Create top_mark, the highest mark. Use the …
A contact is stored in a dictionary: contact = {“name”: “Merhawi”, “city”: “Massawa”, “phone”: “07-123456”} Create name with the value of the “name” key (use square brackets). Create email with get(). The key “email” does not exist, so use the …
