A shop recorded five sales (in Nakfa). Use a for loop to: Print each sale as Sale: 120 and so on. Add each sale to total. After the loop, print the total. Expected output: Sale: 120 Sale: 95 Sale: 150 …
A vegetable seller in Keren updates her lists. Make these changes in order: Remove the first “onion” from stock. Sell the last item: take it out with pop() and store it in sold. Delete the items at index 1 and …
Five people are waiting at a bank in Asmara. Change the list queue in this order: Yonas leaves: remove “Yonas” by value. The first person is served: take them out with pop(0) and store them in served. The last person …
A delivery driver plans a route. Build the list route, starting from an empty list: Add all the morning stops with extend(). Add the item “Lunch break” with append(). Add all the afternoon stops with extend(). The urgent stop must …
Change the list students in this order: Add “Hana” to the end with append(). Insert “Merhawi” at the beginning with insert(). Add the two new students [“Yonas”, “Ruth”] with extend(). Then print the list and its length. Expected output: [‘Merhawi’, …
A shop in Massawa updates its prices (in Nakfa). Starting from prices = [40, 25, 60, 15, 80], make these changes in order: Replace the items at index 1 and 2 with 30 and 65 using one slice. Increase the …
Change the list timetable with three lines of code, in this order: Change “Science” (index 2) to “Biology”. Insert “Art” at index 1. Change the last item to “Geography” using a negative index. Then print the list. Expected output: [‘Maths’, …
A bus travels this route from Asmara to the west of Eritrea: route = [“Asmara”, “Keren”, “Akordat”, “Barentu”, “Tesseney”] Create these variables without typing any city names (use indexes, slices, len() and in): start — the first stop, and end …
Use the list students to create four variables: first — the first student. last — the last student (use a negative index). middle — a slice with the 2nd, 3rd and 4th students. count — the number of students, using …
Abel orders 3 shirts at 150 Nakfa and 2 hats at 60 Nakfa from a shop in Asmara. He gets a 10% discount on the items (multiply their total by 0.9), and then 25 Nakfa is added for delivery. Create …
