Merhawi owns a small shop in Keren. Create a dictionary called shop with exactly these five keys: “owner”: “Merhawi” “city”: “Keren” “open_days”: 6 (an integer) “products”: a list [“bread”, “milk”, “tea”] “has_delivery”: False (a boolean) Then print three lines: the …
Create a dictionary called student with these three pairs, in this order: “name”: “Selam” “age”: 16 (a number) “city”: “Asmara” Then print the dictionary, and on the next line print its length with len(). Expected output: {‘name’: ‘Selam’, ‘age’: 16, …
A delivery company keeps a set of the cities it serves. Make an independent copy of cities called backup (use copy()). Change cities: discard “Keren” and add “Nakfa”. Create changed — the cities that are in exactly one of cities …
Abel needs a pen, a notebook and a ruler. His bag contains the items in the set bag. Create ready — True if every item in required is in bag. Use issubset(). Create no_toys — True if bag has nothing …
A shop in Mendefera recorded its customers on Monday and Tuesday. Create: new_on_tuesday — customers who came on Tuesday but not on Monday came_both — customers who came on both days one_day_only — customers who came on exactly one day …
Two teams are stored in sets: asmara_team and keren_team. Some players play for both. Create all_players — every player in at least one team (union). Create in_both — the players in both teams (intersection). Print both with sorted(). Expected output: …
The set marks holds the different marks in a class test. The pass mark is 50. Create two empty sets: passed and failed. Loop through marks. Add each mark of 50 or more to passed and every other mark to …
Loop over the set visitors in alphabetical order. For each name, print Hello, NAME! In the same loop, add the length of each name to total_letters. After the loop, print Total letters: and the number. Expected output: Hello, Abel! Hello, …
Five people are waiting at a clinic in Asmara. Loop through the list served and take each person out of waiting. Some names in the list are not waiting (or appear twice), so choose the method that does not crash. …
The set stock lists the products in a shop in Keren. Sugar is sold out: remove “sugar” with remove(). The manager also asks to take out “coffee”, but it may not be in stock. Use discard() so there is no …
