TutorialsPreview
LearnDeepReferenceCheatsheetBuild with AI
LearnBuildbeginner12 min

Your first Python program

A temperature converter — a function, a loop, and readable output.

You will build

A program that converts a few Celsius temperatures to Fahrenheit and prints them.

You will learn

Defining a function, returning a value, f-strings, and a simple loop.

Prerequisites

Python installed locally to run it, or just read along — the code is here.

Python is famous for reading almost like plain English. Here is a small, complete program — a temperature converter. Open it in /code to edit, and run it locally to see it work.

project · py-temperature Open in Code
main.pyPYTHON
def to_fahrenheit(celsius: float) -> float:
"""Convert a Celsius temperature to Fahrenheit."""
return celsius * 9 / 5 + 32
for c in (0, 37, 100):
print(f"{c}°C = {to_fahrenheit(c)}°F")
The converter — open it in Code
Concept · python/functions
Catalog

Functions

`def name(args):` defines a reusable unit of work. `return` hands a value back to whoever called it.

PYTHON
def to_fahrenheit(celsius):
return celsius * 9 / 5 + 32
print(to_fahrenheit(100)) # 212.0
bash
$python main.py
0°C = 32.0°F
37°C = 98.6°F
100°C = 212.0°F

Milestone

You wrote and ran a Python program.

A function, a loop, and formatted output — the three things almost every Python script is built from.

More like this

M
Build·beginner·12 min

Make a page respond: a click counter

A page becomes alive the moment JavaScript listens for an event and changes the page in response. Build a counter, then open it in /code.

B
Build·beginner·9 min

Build interaction with AI

The vibe-coder path for JS events: the event→state→render loop you must hold in your head, the prompt, and the review.

B
Build·beginner·8 min

Build a script with AI

The vibe-coder path for Python: the shape of a small program, the prompt, and the edge cases AI forgets.

Liked this one?

Pass it on

Discussion

Be the first to ask

Your questions stay private with the team. We can pin answers to share with everyone.

Sign in to ask a question privately on this tutorial.

Sign in

No pinned answers yet for this tutorial.