Selam and Abel want to change shifts. Swap morning and evening in one line, without a third variable. Unpack the list marks into three variables: low, middle and high. Create total = low + middle + high. Print morning and …
Write two lines of assignment: In one line, create name, age and city with the values “Merhawi”, 15 and “Massawa”. In one line, set wins, draws and losses all to 0. The print() lines are already written. Expected output: Merhawi …
Selam has 200 Nakfa in her wallet. Create balance = 200 and print it. She buys bread for 25 Nakfa. Reassign balance using its old value (balance = balance – 25) and print it. Her brother Merhawi gives her 50 …
This program does not run because all three variable names break a naming rule. Press Run to see the error. Rename the variables to first_name, home_city and grade, and update the print() lines to match. Keep the values the same. …
A student gets a scholarship if their average is at least 85 and they missed fewer than 5 days. Create good_marks and good_attendance using comparisons. Create eligible that is True only when both are true (use and). Print the three …
Given age = 20: Create is_adult that is True when age is 18 or more. Use a comparison — do not just type True. Print is_adult. Print bool(0). Print bool(“hello”). Expected output: True False True
Prices arrived as text: coffee = “15.5” and cake = “22”. Create total as a float (the sum of both prices). Create whole — the total as an int (decimals cut off). Create receipt = “Total: 37.5 Nakfa” built with …
Two prices arrived as text: a = “10” and b = “5”. Create total, the number sum of a and b (it should be 15). Create message = “Total: ” joined with total. Print total, then message. Expected output: 15 …
Abel scored 78, 85, 90 and 71 in four exams. Create total — the sum of the four marks. Create average — the total divided by 4, rounded to 1 decimal place. Print total, then average. Expected output: 324 81.0
Create three variables: x = 7 (int) y = 2.5 (float) z = 3j (complex) Print the type of each one, in that order. Then print x + y. Expected output: <class ‘int’> <class ‘float’> <class ‘complex’> 9.5
