CHAPTER 01 · BEGINNER4 min read

Welcome to Python

Write a complete tiny program and learn how to read its instructions and results.

Python 3.12+Free to readModule 1 of 13
YOUR NEXT SMALL WINS

By the end, you’ll be able to…

  • Run a program that prints text and a calculation.
  • Distinguish source code from the output it produces.
  • Use prediction and small edits to investigate a program.

01A program you can understand today

A program is a set of instructions expressed precisely enough for a computer to follow. Python is the language we will use to write those instructions. You do not need to memorize a dictionary of commands before beginning. Start with this complete program: it announces a short study session, calculates its duration, and prints a final message. Save it as welcome.py and run it with an installed Python interpreter. The next lesson walks through local setup if you need it.

Read from the top down. Each print call asks Python to display something. Text belongs inside matching quotation marks; a calculation can appear directly between the parentheses. Predict the three output lines before running the program. Your prediction is a small test of your understanding, even if you have never programmed before.

welcome.py🐍Python
Ctrl + ↵
Output
Click Run or press Ctrl+Enter
Output will appear here after you run the code.

02Instructions and results are different things

The source code contains punctuation that the output does not. Quotation marks mark the boundaries of text; they are not part of the message being printed. Parentheses surround the information passed to print. A function is a named operation, and calling a function means asking it to do its job. For now, print is the only function you need to remember.

Compare the two lines below. The first displays the characters 15, a plus sign, and 10 because they are inside quotes. The second evaluates an expression: a piece of code that produces a value. Both lines are valid, but they communicate different things. Programming often means choosing whether you want to describe some text or calculate a result.

text_or_calculation.py🐍Python
Ctrl + ↵
Output
Click Run or press Ctrl+Enter
Output will appear here after you run the code.

03Make one change and observe it

Learning code works well as a cycle: predict, run, compare, and explain. Change 15 to 20 in the first example, then predict which output line will change. You should expect the total to become 30 while both messages remain the same. If the result surprises you, reread the exact instruction instead of making several unrelated edits at once.

You can leave a note for a future reader with a comment. A hash sign starts a comment outside quoted text, and Python ignores the rest of that line. Use comments to explain a decision, such as why a session is divided into two parts. A comment that merely repeats the instruction adds less value than one that explains your intention.

study_plan.py🐍Python
Ctrl + ↵
Output
Click Run or press Ctrl+Enter
Output will appear here after you run the code.

04Errors are clues you can use

Python must be able to understand the shape of an instruction before executing it. A missing closing quote or parenthesis can produce a SyntaxError. When an error appears, first look at the reported line, then inspect the punctuation on that line and the preceding line. The marked location is where Python noticed a problem; the original mistake can be earlier.

An error message is feedback about a particular attempt, not a judgment about your ability. Keep a working version, change one thing, and rerun it. At this point you should be able to explain why quoted arithmetic stays text, why an unquoted calculation becomes a number, and why a comment disappears from the output. Those explanations matter more than typing quickly.

LET IT CLICK

The ideas worth keeping.

  • Source code describes instructions; output is what those instructions display.
  • Quoted text is a string, while an arithmetic expression calculates a value.
  • Predict, run, and change one detail at a time to build understanding.
TURN UNDERSTANDING INTO SOMETHING YOU CAN DO

Make it yours.

Type and test your code right here in the interactive workspace. Run your solution, check the output, and compare with the worked guide when ready.

01

A personal welcome

Print three lines: Learning Python, the result of 8 + 12, and Ready for the next step. Use a calculation for the middle line.

your_turn_1.py🐍Python
Ctrl + ↵
Output
Click Run or press Ctrl+Enter
Output will appear here after you run the code.
Explore a worked solution
one_possible_solution.pyPython
print("Learning Python")print(8 + 12)print("Ready for the next step")

The messages are string values enclosed in quotes. The addition is outside quotes, so the middle line displays 20.

02

Show the expression and its answer

Write a program that displays 7 + 9 on its first line and 16 on its second line. Compute the second line rather than writing 16 directly.

your_turn_2.py🐍Python
Ctrl + ↵
Output
Click Run or press Ctrl+Enter
Output will appear here after you run the code.
Explore a worked solution
one_possible_solution.pyPython
print("7 + 9")print(7 + 9)

The same visible symbols can be text or executable arithmetic. The quotation marks are what make the first line a description of the calculation.

A SMALL QUESTION. A USEFUL NEXT STEP.

What stayed with you?

Check the ideas while they’re fresh. Your answers stay in this page and feedback appears as you go.

A LITTLE ACTIVE RECALL0 / 3 answered
01What does print("4 + 6") display?
02You change only print(3 + 2) to print(3 + 5). What should you predict?
03Which line prints a hash sign as part of a message?
⚡CODING CHALLENGE
🔒Required to Mark Lesson Complete

A personal welcome

Print three lines: Learning Python, the result of 8 + 12, and Ready for the next step. Use a calculation for the middle line.

EXPECTED OUTPUT
Learning Python
8 + 12
Ready for the next step
challenge.pyPython 3
Ctrl + ↵
Execution Console
Click "Run & Verify" (or press Ctrl + Enter) to test your code against the challenge.

Keep exploring.

The official references behind this chapter, when you want a second angle or the full details.

One chapter closer.

Reading is a start. Trying it yourself makes the connection.

Solve the hands-on coding challenge in the knowledge section to verify your code and unlock chapter completion.