Skip to content
PythonExamples

LESSON 1 / 5 · 6 MIN

Introduction to Python

LET'S MAKE IT CLICK

Meet Python

A program is a set of instructions. Python is a language for writing those instructions in a form a computer can follow.

WATCH THE IDEA
A task5 minutes

Start with something you want to calculate.

Instructions5 × 60

Tell Python how to get the result.

A result300 seconds

Inspect the answer.

Programming connects a task to a result through explicit instructions.

Move through one idea at a time. Watch, experiment, and check your understanding along the way.

What can you do with Python?

WATCH THE IDEA
AutomateFiles → report

Combine repetitive steps.

AnalyzeData → insight

Explore patterns in information.

BuildRequest → response

Create services and applications.

Different projects share the same building blocks: values and instructions.

Automate repetitive tasks, work with data, build web services, or create tools that use AI. The same foundations—values, variables, decisions, and loops—appear in all of these projects.

You do not need to memorize every command. Start by connecting a small instruction to its result, then combine instructions into something useful.

Your first mental model

WATCH THE IDEA
Assignminutes = 5

A name refers to the starting value.

Calculateseconds = 300

5 multiplied by 60 gives a new value.

Display300

print(seconds) shows the result.

Follow the sequence from top to bottom. A later statement can use an earlier value.

In the examples here, Python follows statements from top to bottom. Some instructions create a value; others transform it or display a result. Later, conditions and loops will change that flow.

See the Python code
minutes = 5
seconds = minutes * 60
print(seconds)
Keep in mind

print() displays a value. The equals sign assigns a value to a variable; it does not ask whether two things are equal.

YOUR TURN TO EXPLORE

Choose a task. Follow the instructions.

Pick a small task and step through its program. Notice how values become a result.

example.pyPython
    CURRENT VALUESReady

    No assignments yet.

    OUTPUT

    No output yet.

    Predict the result, then take the first step.

    QUICK CHECK 1 / 2

    In the time-conversion example, what happens before print(seconds)?
    You can try again.

    Code, interpreter, output

    WATCH THE IDEA
    Codeprint(300)

    The instruction you write.

    InterpreterRun the call

    Python evaluates the instruction.

    Output300

    The displayed result.

    Code, the interpreter, and output have different roles.

    Code is the text you write. A Python interpreter runs that code. Output is what the program displays, such as the number 300 in the time-conversion example.

    The interactive examples in this course let you inspect specific programs without installing Python. When you move to your own projects, you can run Python in a terminal, an editor, or a notebook.

    Errors are information

    WATCH THE IDEA
    Tryprint(2 + "3")

    A number and text cannot be added this way.

    NoticeTypeError

    The error identifies incompatible types.

    Adjustprint(2 + 3)

    Use two numbers to produce 5.

    An error is useful feedback. Change one thing, then test the result.

    A typo or an unsupported operation can stop a program. The error message tells you what Python could not do. Learning to read those messages is part of learning to program.

    Keep experiments small: predict a result, run the example, and compare the result with your prediction.

    QUICK CHECK 2 / 2

    What is the role of a Python interpreter?
    You can try again.

    TAKE IT WITH YOU

    What you have learned

    • A program combines instructions to perform a task.
    • Simple Python programs run statements in order.
    • Output helps you inspect what a program is doing.

    Answer both quick checks correctly to mark this lesson complete. You can continue at any time.