Skip to content
Kuza Ndoto Academy

Your First Program

Beginner → IntermediateChapter 1 · Page 3 of 563 min readUpdated 15 Nov 2026

Every programmer starts by making the computer say something. On this page you will write a Python program in a file, save it and run it, and learn what the print() function does along the way.

Create a file

Open VS Code and open your kuza-python folder (see Installing Python & VS Code if you haven't set it up). Create a new file called hello.py. The .py ending tells your computer and your editor that the file contains Python code.

Type this single line into the file and save it with Ctrl+S (Cmd+S on a Mac):

print("Hello, world!")
Hello, world!

Run the program

There are two easy ways to run it.

  1. In VS Code: click the Run Python File triangle in the top-right corner. A terminal panel opens at the bottom and shows the output.
  2. From a terminal: move into the folder with cd, then ask Python to run the file.
cd kuza-python
python hello.py      # Windows
python3 hello.py     # macOS and Linux
Hello, world!

Congratulations: you have written and run a real program. Every app you will ever build follows the same cycle: write → save → run → check the output.

Understanding print()

print is a built-in function: a named piece of code that does a job for you. You call it by writing its name followed by brackets, and you put the thing you want to show inside the brackets. Text must go inside quotation marks. Text in quotes is called a string.

print("Habari! My name is Zawadi.")
print('I am learning Python.')
print()
print("Today's goal:", "write my first program")
Habari! My name is Zawadi. I am learning Python. Today's goal: write my first program
  • You can use double quotes "..." or single quotes '...', as long as both ends match.
  • An empty print() prints a blank line.
  • When you give print() several items separated by commas, it prints them on one line with a space between each.
  • Each print() starts on a new line.

Text vs. numbers

Numbers don't need quotes. Python can work them out before printing them. Watch what changes when you add quotes:

print(2 + 3)
print("2 + 3")
print("Total:", 450 + 120)
5 2 + 3 Total: 570

Without quotes, 2 + 3 is a calculation. With quotes, it is just text, and Python prints it exactly as written. You will learn much more on the Numbers & Arithmetic and Strings pages.

A slightly bigger program

Programs run from the top line to the bottom line, one instruction at a time. Here is a short "profile card" program you can personalise:

print("==== PROFILE ====")
print("Name:", "Baraka Mwangi")
print("Town:", "Nakuru")
print("Age next year:", 19 + 1)
print("=================")
==== PROFILE ==== Name: Baraka Mwangi Town: Nakuru Age next year: 20 =================

When things go wrong

Mistakes are normal, and Python's error messages are there to help. The last line of an error tells you what went wrong; the lines above it tell you where.

Common mistake

Python is case-sensitive. Print("Hi") with a capital P fails with a NameError, because Python only knows a function called print in lowercase.

Common mistake

Missing quotes or brackets cause a SyntaxError. For example, print("Hello) is missing its closing quote, and print("Hello" is missing its closing bracket. Python usually points to the exact spot with a ^ marker.

Common mistake

Forgetting to save. If your output doesn't change after you edit the code, you probably ran the old saved version. In VS Code, an unsaved file shows a white dot on its tab.

Key points

  • Python programs are saved in files ending in .py.
  • Run a file with the VS Code Run button, or with python file.py / python3 file.py in a terminal.
  • print() displays values; separate several items with commas.
  • Text goes in quotes; numbers and calculations don't.
  • Read error messages from the bottom line up. They point you to the problem.
Up next · Getting StartedHow Python Runs Your CodeInterpreters, scripts and the interactive shell explained.
→

Tip: use the ← and → keys to move between pages.