Task 1: What is 5 to the power of 5 minus 5?
Notebook Cell
5**5 - 53120Task 2: Create variables for the efficiency of 45% and the input_energy of 1000 MWh. Compute and print the output_energy using these variables.
Notebook Cell
efficiency = 0.45
input_energy = 1000 # MWh
output_energy = efficiency * input_energy
print(output_energy)450.0
Task 3: Split the following string into a list by splitting on the space character:
Notebook Cell
s = "Data Science for Energy System Modelling"
s.split(" ")['Data', 'Science', 'for', 'Energy', 'System', 'Modelling']Task 4: Create a list with the names of every planet in the solar system (in order).
Have Python tell you the name of the third planet.
Have Python tell you the total number of planets.
Have Python tell you whether “Pluto” is in the list of planets.
Iterate through your planets and print the planet name only if it has an “s” at the end.
Notebook Cell
planets = [
"Mercury",
"Venus",
"Earth",
"Mars",
"Jupyter",
"Saturn",
"Uranus",
"Neptune",
]Notebook Cell
planets[2]'Earth'Notebook Cell
len(planets)8Notebook Cell
for p in planets:
if p.endswith("s"):
print(p)Venus
Mars
Uranus
Task 5: Create a dictionary that contains the main facts about the Reuter West power plant.
Have Python tell you the main fuel type used in the power plant.
Add the power plant’s approximate latitude and longitude to the dictionary.
Notebook Cell
rw = {
"Country": "Germany",
"Electricity Capacity": 564,
"Heat Capacity": 878,
"Technology": "Combined heat and power (CHP)",
"Main Fuel": "Hard coal",
"Vattenfall ownership share": "100%",
"Status": "In Operation",
}Notebook Cell
rw["Main Fuel"]'Hard coal'Notebook Cell
rw["x"] = 13.24
rw["y"] = 52.53Task 6: Write a function that converts units of energy from ‘ktoe’ to ‘GWh’
https://
www .iea .org /data -and -statistics /data -tools /unit -converter
Notebook Cell
def ktoe_to_gwh(x):
return 11.63 * xTask 7: Write a more general unit conversion function that converts between all units of energy listed under the link below. The function should take arguments: for the original value, the original unit and the target unit. Implement the function in a way that the default target unit is “Wh”. Verify that function by converting 200 ‘toe’ to ‘Wh’.
https://
www .iea .org /data -and -statistics /data -tools /unit -converter
Notebook Cell
def to_joule(value, from_unit):
if from_unit.endswith("cal"):
return value / 0.2390
elif from_unit.endswith("Btu"):
return value / 0.0009478
elif from_unit.endswith("Wh"):
return value / 0.0002778
elif from_unit.endswith("toe"):
return value * 2.388e11
elif from_unit.endswith("tce"):
return value * 3.412e11
else:
raise NotImplementedError()Notebook Cell
def convert_unit(value, from_unit, to_unit="Wh"):
x = to_joule(value, from_unit)
if to_unit.endswith("cal"):
x *= 0.2390
elif to_unit.endswith("Btu"):
x *= 0.0009478
elif to_unit.endswith("Wh"):
x *= 0.0002778
elif to_unit.endswith("toe"):
x /= 2.388e11
elif to_unit.endswith("tce"):
x /= 3.412e11
else:
raise NotImplementedError()
return xNotebook Cell
convert_unit(200, "toe")13267727999.999998