dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
2.2 KiB
2.2 KiB
id, title, challengeType, dashedName
| id | title | challengeType | dashedName |
|---|---|---|---|
| 694596b0585c11170ac7c7fa | Challenge 162: Energy Consumption | 29 | challenge-162 |
--description--
Given the number of Calories burned during a workout, and the number of watt-hours used by your electronic devices during that workout, determine which one used more energy.
To compare them, convert both values to joules using the following conversions:
- 1 Calorie equals 4184 joules.
- 1 watt-hour equals 3600 joules.
Return:
"Workout"if the workout used more energy."Devices"if the device used more energy."Equal"if both used the same amount of energy.
--hints--
compare_energy(250, 50) should return "Workout".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(compare_energy(250, 50), "Workout")`)
}})
compare_energy(100, 200) should return "Devices".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(compare_energy(100, 200), "Devices")`)
}})
compare_energy(450, 523) should return "Equal".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(compare_energy(450, 523), "Equal")`)
}})
compare_energy(300, 75) should return "Workout".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(compare_energy(300, 75), "Workout")`)
}})
compare_energy(200, 250) should return "Devices".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(compare_energy(200, 250), "Devices")`)
}})
compare_energy(900, 1046) should return "Equal".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(compare_energy(900, 1046), "Equal")`)
}})
--seed--
--seed-contents--
def compare_energy(calories_burned, watt_hours_used):
return calories_burned
--solutions--
def compare_energy(calories_burned, watt_hours_used):
workout_energy = calories_burned * 4184
device_energy = watt_hours_used * 3600
if workout_energy > device_energy:
return "Workout"
if device_energy > workout_energy:
return "Devices"
return "Equal"