Intro to Python — Your First Real Program

Install Python, meet the REPL, and write a program that takes input from a human and does something useful with it — all in one sitting.

Python Beginner 12 min read Watch the video (10:47)

Most "learn to code" guides spend twenty minutes on history before you type anything. We are going to have working code on your screen in about four.

Here is the deal: Python is the language that gets out of your way. No semicolons, no curly braces, no compiler yelling at you about types you have not learned yet. You write what you mean, and it runs.

#What you need

Nothing but a computer and ten minutes. No paid tools, no accounts.

#Step 1 — Install Python

Go to python.org/downloads and grab the latest version for your operating system.

On macOS, the installer just works. On Linux, Python is almost certainly already there.

Now open your terminal — Command Prompt or PowerShell on Windows, Terminal on macOS and Linux — and ask Python to identify itself:

bash
python --version

You should see something like Python 3.13.1. If you get "command not found", try python3 --version instead. On macOS and most Linux systems, python3 is the correct name.

#Step 2 — Say hello from the REPL

Type python on its own and hit enter. The prompt changes to >>>. You are now inside the REPL — Read, Eval, Print, Loop. It reads a line, evaluates it, prints the answer, and loops back for more.

python
>>> print("Hello, world!")
Hello, world!
>>> 2 + 2
4
>>> "Dom" * 3
'DomDomDom'

That last one is not a typo. Multiplying a string by a number repeats it. Python is full of small, sensible surprises like that.

The REPL is your scratchpad forever. Any time you are unsure what a piece of code does, you paste it in here rather than guessing. Type exit() to leave.

#Step 3 — Your first real file

The REPL forgets everything when you close it. Real programs live in files.

Make a file called hello.py — in VS Code, Notepad, or whatever you have — and put this inside:

python
print("Hello, world!")
print("This is my first Python program.")

Save it, then in the terminal, navigate to that folder and run:

bash
python hello.py

Both lines print, in order, top to bottom. That is the whole execution model: Python starts at line one and works down. Everything else you will ever learn is a way of changing what happens on the way.

#Step 4 — Variables are labels, not boxes

A variable is a name pointing at a value.

python
name = "Dom"
subscribers = 119
average_rating = 4.8
is_free = True

No String name, no int subscribers. Python figures out the type from the value. That is called dynamic typing, and it is why Python code is so short.

Four types just showed up, and they cover most of what you will use:

TypeExampleWhat it holds
str"Dom"Text, in single or double quotes
int119Whole numbers
float4.8Decimals
boolTrue / FalseYes or no — note the capital letter

You can always ask what something is:

python
>>> type(subscribers)
<class 'int'>

#Naming rules that keep you out of trouble

  • Use snake_case: total_score, not totalScore or TotalScore.
  • Start with a letter or underscore, never a digit.
  • Names are case-sensitive — score and Score are two different variables.
  • Do not name things list, str, sum, or type. Those are built-in functions, and shadowing them breaks code in ways that are genuinely hard to debug.

#Step 5 — f-strings, the only way you should build text

You will constantly need to drop a variable into a sentence. Python has three ways to do it, and only one is worth learning:

python
name = "Dom"
videos = 15

print(f"{name} has published {videos} videos.")

Note the f before the opening quote. That is what makes the curly braces special. Output:

text
Dom has published 15 videos.

You can run real expressions inside the braces:

python
print(f"That is roughly {videos / 5:.1f} videos per track.")
text
That is roughly 3.0 videos per track.

The :.1f after the expression is a format spec — "render this float with one decimal place." Handy for money and percentages.

#Step 6 — Talk to the human

input() pauses the program, waits for someone to type something, and hands it back as a string.

python
name = input("What is your name? ")
print(f"Nice to meet you, {name}.")

Now the important part, and the source of about a third of all beginner bugs:

Watch it go wrong:

python
age = input("How old are you? ")   # user types 30
print(age + 10)                    # TypeError!

The fix is to convert explicitly:

python
age = int(input("How old are you? "))
print(f"In ten years you will be {age + 10}.")

int(), float() and str() convert between types. Use them the moment the value arrives, not fifty lines later.

#Step 7 — Make a decision

python
score = int(input("Enter your score: "))

if score >= 90:
    print("Grade: A")
elif score >= 80:
    print("Grade: B")
elif score >= 70:
    print("Grade: C")
else:
    print("Keep going — let us review together.")

Two things to notice.

The colon and the indentation are the syntax. Other languages use { and } to say "this block belongs to the if." Python uses indentation, and it is not optional styling — it is the actual structure of the program. Four spaces per level. Your editor will do it for you if you let it.

elif is only checked if everything above it failed. Order matters. If you put score >= 70 first, a score of 95 would print "Grade: C", because that check passes too and Python stops at the first match.

#Put it together

Save this as greeter.py and run it:

python
print("=" * 32)
print("  Coding with Dom — Lesson 1")
print("=" * 32)

name = input("What should I call you? ")
years = int(input("How many years have you been coding? "))

if years == 0:
    level = "you are starting today, which is the best time"
elif years < 2:
    level = "you are past the hardest part"
else:
    level = "you are dangerous already"

print()
print(f"Welcome, {name}.")
print(f"With {years} year(s) in, {level}.")
print(f"Next lesson unlocks in {3 - min(years, 3)} steps. Let us go.")

Every idea from this lesson is in there: strings, ints, input(), conversion, f-strings, and a branch. Thirteen lines, and it is a real program.

Check yourself

3 questions on what you just read. No score is kept — it is only here to catch the bits that did not stick.

  1. 1A user types 30 at an input() prompt. What is the type of the value your program receives?

    Show the answer

    A. str — always, no exceptions.

    input() hands back a string every single time. Wrap it in int() or float() the moment it arrives, or age + 10 raises a TypeError.

  2. 2Which of these prints Videos: 15 when videos = 15?

    Show the answer

    A. print(f"Videos: {videos}")

    The f prefix is what makes the braces special, and the variable has to be inside them. Miss either piece and you print the literal text.

  3. 3Why does this print Grade: C for a score of 95?

    Show the answer

    A. elif is only tested when every branch above it fails, and 95 >= 70 already passed.

    Order matters in a chain. Put the narrowest condition first, or the broad one swallows everything.

#Key takeaways

  • Python runs top to bottom; indentation defines structure.
  • Variables are names bound to values — no type declarations needed.
  • input() always hands you a string. Convert it immediately with int() or float().
  • f-strings (f"...") are the correct way to build text out of variables.
  • The REPL is not a toy. Use it every time you are unsure what something does.

Next up: the data structures that let you handle more than one thing at a time.

Finished this one?

The challenge above has no posted solution — that is deliberate. Get it working, then come back for the next lesson.

Next lesson Subscribe