curriculum/challenges/english/blocks/daily-coding-challenges-python/694596b0585c11170ac7c7fa.md
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:
Return:
"Workout" if the workout used more energy."Devices" if the device used more energy."Equal" if both used the same amount of energy.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")`)
}})
def compare_energy(calories_burned, watt_hours_used):
return calories_burned
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"