You need very little Python for Coding a Scientific Model — variables, loops, functions, and printing.
Variables and arithmetic
voltage = 12.0
resistance = 4.0
current = voltage / resistance
print("Current:", current, "A")Loops
# Half-life decay: how much remains after each half-life?
amount = 100.0
for half_life in range(1, 6):
amount = amount / 2
print("After", half_life, "half-lives:", round(amount, 2), "g")Functions
def kinetic_energy(mass, speed):
return 0.5 * mass * speed ** 2
print(kinetic_energy(1200, 25), "J")Getting input
distance = float(input("Distance in AU: "))
kilometres = distance * 1.5e8
print(distance, "AU is", kilometres, "km")Errors are information, not failure
NameErrormeans you used a name Python has not seen — usually a typo.TypeErrormeans you mixed text and numbers, often becauseinput()returns text and you forgotfloat(). Read the last line of the message first.
Curriculum connection
A1.4
apply coding skills to investigate and to model scientific concepts and relationships
Link to original