A runner from Keren finished a long race in 7384 seconds. Turn this into hours, minutes and seconds. hours — whole hours (3600 seconds in an hour). minutes — whole minutes left after taking away the hours. seconds — seconds …
A bus trip from Asmara to Massawa took 200 minutes. Create hours: the number of whole hours, using //. Create minutes: the minutes left over, using %. Print them as shown. Expected output: 3 hours 20 minutes
Clean up a student record using string methods: name — raw_name with spaces removed from both ends and every word capitalised with title() number — raw_number padded with zeros to 5 digits using zfill() valid — True if raw_number contains …
Given the variable text, create: times — how many times “Asmara” appears (use count()) position — the index of the word “capital” (use find()) starts — True if text starts with “Asmara” (use startswith()) Print them in that order. Expected …
Create a variable card that holds a three-line student card in one normal string (not triple quotes). Use \t between each label and value, and \n between lines. Then create folder as a raw string holding C:\new\tests. Print card, then …
This program crashes because of the quotes and the backslash. Fix each string using escape characters (keep the double quotes around every string): quote must hold: He said “Selam!” sentence must hold: It’s hot in Massawa path must hold: C:\Users\Abel …
Create three strings with f-strings so the price list lines up in two columns: header — the text Item left-aligned in 10 characters, then Price right-aligned in 8 characters row1 — item1 left-aligned in 10, then price1 right-aligned in 8 …
Using an f-string, create a variable message that uses name and total to make this exact text, with the total shown with 2 decimal places: Hello Selam, you owe 152.50 Nakfa Then print message.
Merhawi buys 4 kilos of tomatoes at 30 Nakfa per kilo. Using the given variables, create: line — 20 equals signs, made with * receipt — “Tomatoes x 4 = 120 Nakfa”, built with + and str(). Let Python calculate …
Using the variables first and last, create: full_name — the first name, a space and the last name: “Abel Tesfay” greeting — “Hello, ” + full_name + “!” Use + for both. Then print greeting. Expected output: Hello, Abel Tesfay!
