0Pricing
Coding for Kids · Lesson

The Formula

Convert between them.

The Formula is a free Coding for Kids lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Coding for Kids learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

The Magic Formula 🪄

Hello again, temperature wizard! 🧙 Today we learn the secret spell to turn Celsius into Fahrenheit and back!

It is just a tiny bit of math. Don't worry, Python does the hard part! 🤖

print("Let's cast the temperature spell! 🪄")

Celsius to Fahrenheit ➡️

To go from Celsius to Fahrenheit, the spell is:

F = C × 9 / 5 + 32

Multiply by 9, divide by 5, then add 32. Let's try it! ✨

c = 20
f = c * 9 / 5 + 32
print(c, "Celsius is", f, "Fahrenheit 🔥")

Step by Step 🐾

Let's slow down and watch each step for 20°C! 🐌

  • 20 × 9 = 180
  • 180 ÷ 5 = 36
  • 36 + 32 = 68

So 20°C = 68°F! 🎉

c = 20
step1 = c * 9
step2 = step1 / 5
step3 = step2 + 32
print("Times 9:", step1)
print("Divide 5:", step2)
print("Add 32:", step3)

Try Another Number 🔢

Let's convert 0°C (freezing!) to Fahrenheit. ❄️

Can you guess the answer before running? 🤔

c = 0
f = c * 9 / 5 + 32
print("0 Celsius is", f, "Fahrenheit ❄️")

Fahrenheit to Celsius ⬅️

Now the spell the OTHER way, Fahrenheit to Celsius:

C = (F - 32) × 5 / 9

Subtract 32 first, then multiply by 5, then divide by 9! ✨

f = 212
c = (f - 32) * 5 / 9
print(f, "Fahrenheit is", c, "Celsius 🔥")

Use Parentheses! ()

See those parentheses ( )? They tell Python: do this part FIRST! 🥇

We must subtract 32 before multiplying, so we wrap it in parentheses.

f = 98.6
c = (f - 32) * 5 / 9
print("Body temp", f, "F is", round(c), "C 🤒")

Rounding Numbers 🔵

Sometimes the answer has lots of decimals like 36.66666. 😵

We use round() to make it neat and tidy! ✨

f = 98
c = (f - 32) * 5 / 9
print("Messy:", c)
print("Tidy:", round(c))

A Temperature Function 🛠️

We can put the spell in a function so we can reuse it again and again! 🔁

def to_fahrenheit(c):
    return c * 9 / 5 + 32

print(to_fahrenheit(10))
print(to_fahrenheit(25))

Both Directions 🔄

Let's make TWO functions, one for each direction! 🔄

Now we have a full temperature toolbox! 🧰

def c_to_f(c):
    return c * 9 / 5 + 32

def f_to_c(f):
    return (f - 32) * 5 / 9

print("30C =", c_to_f(30), "F")
print("86F =", f_to_c(86), "C")

A Fun Fact 🤩

There is ONE special temperature where Celsius and Fahrenheit are the SAME number! 😲

It is -40! -40°C equals -40°F. Super cold and super cool! 🧊

c = -40
f = c * 9 / 5 + 32
print("-40 C is", f, "F 🤯")

Formula Master! 🏆

You learned BOTH temperature spells! 🎉

  • C to F: C × 9 / 5 + 32
  • F to C: (F - 32) × 5 / 9

Next we will ask the USER to type a temperature! ⌨️

print("I am a formula master! 🥇")

Quick Check ✅

Let's test your spell-casting skills! 🪄

Recap Time! 🎒

Great job, formula master! 🌟

  • C to F: C × 9 / 5 + 32 🔥
  • F to C: (F - 32) × 5 / 9 ❄️
  • Use ( ) to do parts first
  • Use round() to tidy decimals
  • Put spells in functions to reuse them! 🛠️

Next: let the user type their own temperature! ⌨️

print("Formula lesson complete! 🚀")

Frequently asked questions

Is the “The Formula” lesson free?

Yes — the full text of “The Formula” is free to read here on the web, and the Coding for Kids course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Coding for Kids course, upgrade to CoddyKit PRO.

What will I learn in “The Formula”?

Convert between them. You practise Coding for Kids with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Coding for Kids?

No prior experience is required. Coding for Kids on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “The Formula” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Coding for Kids lesson?

Yes. Every Coding for Kids lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Celsius and Fahrenheit
  2. The Formula
  3. Asking the User
  4. Showing the Result
← Back to Coding for Kids