Lesson 01.01 · ~28 min read

Hello, Python

How Python runs. Scripts vs. notebooks. print(), comments, variables, basic data types, and type conversion.

By Kelvin AmoabaUpdated May 12, 2026

What we're doing today

By the end of this session, you will have made a computer write back to you. You will have given it a question to ask you, and got it to use your answer in a sentence. That is the whole goal. If you have never written code before, this is the moment it starts to feel real.

It will feel strange for the first half hour. That is normal. Everyone who writes code today felt the same on their first day. Push through it.

Where do we even type this?

Open Google Colab in your browser. Click "New notebook". You will see a page split into rectangles called cells. Think of each cell as a little box where you can type some Python. When you press the play button on the left of a cell (or hit Shift + Enter), Python looks at what you wrote, does it, and shows the result right underneath. That is it. That is the loop you are going to do all term — type something, run the cell, look at what came out.

You do not need to install anything. Colab is a website. It runs the Python for you.

Making the computer say something

The first thing every programmer writes is a program that shows a message. In Python, that looks like this:

print("Hello.")

Type that into a cell. Run it. The word Hello. appears below.

Let me unpack what just happened, because every piece of that one line matters.

  • print is a small built-in tool that comes with Python. Its only job is to show you something. You can think of it as the computer's voice — when you want the program to say something, you use print.
  • The two round brackets ( ) are how you tell print what to say. Whatever you put between the brackets is what shows up.
  • The double quotes " " are how you mark off a piece of text. Anything inside the quotes is treated as words, not as a command. Without the quotes, Python would try to do something with Hello and fail, because it has no idea what Hello means on its own.

Try this and run it:

print("My name is Kojo.")
print("I live in Accra.")

You will see both sentences, one per line. That is your first program. You wrote it. Move on with confidence.

Notes you can leave in your own code

Imagine you are following a recipe your aunt wrote down. Next to one of the steps, she has scribbled in pen: "Don't add too much salt, it ruins the stew." That note is not part of the recipe. The pot does not care that it is there. But future-you, cooking the stew next month, will be very grateful she wrote it.

In code, you can leave the same kind of notes. They are called comments. A comment is a line in your file that Python pretends does not exist. It does not run. It is only there for human eyes — yours, or someone else's reading your code later.

You write a comment by starting the line with a # symbol:

# This program greets the user.
print("Hello.")

When Python runs that, it sees the first line, sees the #, and skips it entirely. It only runs the print.

Why bother? Two reasons.

The first is that next week, when you open this file, you will not remember why you wrote it. A one-line note saves your future self ten minutes of staring at the screen trying to figure out what you were doing. The second reason is that you will eventually share code with other people. A comment is how you tell them what is going on without making them guess.

Use them when something would be confusing without context. Don't use them to explain things that are already obvious from the code itself. This is bad:

# Print hello.
print("Hello.")

The print line already says it prints "Hello." The comment adds nothing. Keep them for the why, not the what.

Keeping something so you can use it again

So far our programs are throwaway. We say one thing, we move on. But most programs need to remember things — a name, a number, a result from earlier. The way you remember something in Python is by giving it a name and storing it.

Think of it like a jar on a kitchen shelf. You put something in the jar — say, ground pepper — and you write pepper on a label and stick it on the front. Later, when you need pepper, you look at the labels, find the one that says pepper, and take it out.

In Python that looks like this:

name = "Amara"
print("Hello,", name)

Read the first line out loud: "name equals Amara." You are taking the word Amara and storing it in a labelled container called name. From this point on, anywhere you write name, Python knows you mean Amara.

In the second line, notice there are no quotes around name. That is on purpose. If you had written print("name"), Python would have shown the letters n-a-m-e, because the quotes mean "treat this as plain text." Without the quotes, it looks up your label and shows what is inside the jar — Amara.

The thing you store can change later:

mood = "tired"
print(mood)
 
mood = "awake"
print(mood)

That program shows tired first, then awake. The label stayed the same. What was in the jar changed.

Pick labels that mean something. name is good. n is bad. country_i_am_applying_to is fine — long is better than meaningless.

Different kinds of things you can store

You can store a name in a jar. You can also store a number, a price, a yes-or-no answer. The kind of thing inside the jar matters, because Python treats them differently. There are four kinds you will see every single day.

full_name = "Kojo Mensah"   # text — letters and spaces, anything inside quotes
age       = 27              # a whole number
height_m  = 1.78            # a number with a decimal point
is_okay   = True            # a yes-or-no answer

Quick tour of those four:

  • Text lives between quotes. It can be a single letter, a sentence, a whole paragraph. The technical word for this is string, because it is a string of characters joined together. From now on, whenever I say "string," I mean text in quotes.
  • Whole numbers — 1, 2, 27, 1000. No decimal point. The technical word is integer. Use them for counts, ages, year, anything that does not need fractions.
  • Decimal numbers — 3.7, 1.78, 0.5. Anything with a dot in the middle. The technical word is float. Use them for measurements, money, averages.
  • Yes-or-no answersTrue or False, with capital letters and no quotes. The technical word is boolean. Use them for facts that are either true or not — "is the user logged in," "did the form pass validation," "is GPA above 3.0."

Why do you care which kind is which? Because Python cares. You will see why in the next section.

Asking the user a question

Most programs you write this course will start by asking the user something. The tool for that is input(). You give it a question; it shows the question and waits for the user to type a reply.

your_name = input("What's your name? ")
print("Welcome,", your_name)

Run that. Python pauses at the input line, shows your question, and waits. Type your name and hit Enter. The program continues and prints the welcome.

So far so good. Now here is the thing that will trip you up the first time, and it trips everyone up:

input() always gives you back a string. Even if the user types the number 27, what you get back is the text "27", not the number 27. Python does not know you wanted a number. It just took what was typed and handed it back as text.

So this code looks fine but blows up:

age = input("Your age? ")
print(age + 10)

Python complains because you are trying to add the number 10 to the text "27". To Python, that is like asking it to add 10 to your name. It does not know how. You have to convert the text to a number first:

age_text = input("Your age? ")
age = int(age_text)
print("In ten years you will be", age + 10)

The int(...) part takes the text and turns it into a whole number. Now the math works.

You will need three converters all term:

  • int("27") — text into a whole number
  • float("3.7") — text into a decimal number
  • str(27) — a number back into text

That is it. When in doubt, ask yourself: "what kind of thing is in this jar right now, and what kind of thing do I actually need it to be?"

Your exercise

Write a short program in a new Colab cell that does the following:

  1. Asks the user for their name.
  2. Asks the user for their favourite city.
  3. Prints a two-line greeting that uses both answers.

The output should look something like:

Hello, Kojo.
I hear Kumasi is a beautiful city.

Try it. Run it. If it breaks, read the error message — it almost always tells you what went wrong. We will spend real time on reading errors in a future session.

If you finish early, also ask the user for their age, turn it into a whole number with int(...), and add a third line that says something like "In ten years, you will be 37."

Mistakes you will probably make today

These are not failures. They are the same mistakes every beginner makes. When you hit one, you will recognise it from this list and fix it in ten seconds.

  • Forgetting the brackets. print "hello" will not work. It must be print("hello").
  • Forgetting the quotes around text. print(hello) makes Python go looking for a labelled jar called hello, and if you never made one, it gives up. Quotes mean "treat this as text."
  • Mixing up = and ==. We have not used == yet, but you will see it next session. For today, a single = is the only one you need. It means "store this thing in this label."
  • Forgetting to convert input. Anything that comes out of input() is text. If you want a number, wrap it in int(...) or float(...).

That is the whole session. Run the exercise, take a screenshot of your program working, and bring questions to our next live session. You have written your first program. From here, it is just adding to what you already know.

Resources

★ recommended