Two tuples are given: names and marks. The mark at each index belongs to the name at the same index. Loop with range(len(names)) and print a numbered line for each student, like 1. Selam: 78. In the same loop, find …
Use a for loop over the tuple prices to: print each price followed by Nakfa, and add each price to a variable total (start it at 0). After the loop, print the total. Expected output: 12 Nakfa 25 Nakfa 40 …
The finishing order of a race in Asmara is stored in race. In one line, unpack race into first, *middle and last. Print first, then last, then middle. Two variables x = 10 and y = 20 are given. Swap …
A library stores each book as a tuple: book = (“Python Basics”, “Merhawi”, 2026). Unpack book into three variables: title, author and year — in one line. Print title, the word “by” and author with one print() (use commas). Print …
A shop in Massawa stores its products in a tuple. Sugar is sold out, and coffee has arrived. Remove “sugar” from stock (use a list and remove()). Add “coffee” at the end by joining with a one-item tuple using +. …
The tuple team holds three names. Abel has left the team and Ruta takes his place. Yonas also joins at the end. Replace “Abel” with “Ruta”. Add “Yonas” at the end. team must still be a tuple when you finish. …
A cafe in Keren has this menu: menu = (“tea”, “coffee”, “juice”, “milk”, “water”). Create middle — a slice with the three middle drinks (coffee, juice, milk). Create every_other — every second drink, starting with tea (use a step). Create …
A tuple months with all twelve months is given. Create three variables: first_month — the first item (use an index) last_month — the last item (use a negative index) summer — a slice with June, July and August Print the …
Do two things: Create capital, a tuple with only one item: “Asmara”. A list of marks is given. Create marks_tuple by converting marks into a tuple with tuple(). Then print the type of capital, the length of capital, and marks_tuple. …
Create a tuple called cities that contains “Asmara”, “Keren” and “Massawa”, in that order. Then print the tuple, its length and its type, each on its own line. Expected output: (‘Asmara’, ‘Keren’, ‘Massawa’) 3 <class ‘tuple’>
