Skip to content

Your First Python Program

1 min read2 lessons in topic

Learning objective

By the end of this lesson you will be able to write and run a Python program that prints output.

Python is a general-purpose language known for its clear, readable syntax. It is a great first language and is used for web apps, data science and automation.

Running Python

  • Write code in a .py file, e.g. hello.py
  • Run it with: python hello.py (or python3 on some systems)
  • Or type code directly into the Python interpreter (the REPL)

Your first program

print("Hello, world!")

Comments

# This is a comment — Python ignores it
print("Hello, ITDS!")  # prints a message

Variables & f-strings

name = "Ama"
course = "Information Technology"
print(f"{name} studies {course}.")

An f-string (the f before the quotes) lets you insert variable values directly into text.

Code playground

Run and edit the starter code — experiment freely.

python · runnable

Output appears here when you press Run.

Practice exercise

Print your name, your programme and your favourite colour using three print statements.

Check your understanding

1. Which function prints output in Python?

2. What symbol starts a comment in Python?

Self-graded — answer then check below.