Francis Landford.
← Python for Beginners: Write Your First Programs
text

Hello, Python: Run Your First Program

Programming means giving a computer clear, step-by-step instructions. Python is a language for writing those instructions that reads almost like English.

What you can build with Python

  • Websites and web services
  • Tools that automate boring tasks, such as renaming files or sending reports
  • Data analysis and charts
  • Games and small apps
  • Artificial intelligence and machine learning

Where to write Python

You have two easy options:

  1. Online editor: search for "online Python editor" and open one in your browser. Nothing to install, which is ideal if your computer is limited.
  2. Install Python from the official website, python.org, together with a simple editor such as IDLE (included) or Visual Studio Code.

Your first program

Type this and run it:

print("Hello, world!")

The output is:

Hello, world!

print() is a function that shows something on the screen. The text inside the quotation marks is called a string.

Comments

Lines beginning with # are notes for humans. Python ignores them.

# This prints my name
print("My name is Mary")

Errors are normal

Every programmer sees errors every day. When Python shows an error message, read it from the bottom, because the last line tells you what went wrong and the lines above show where.

Common beginner mistakes: forgetting a quotation mark, mistyping print, or using the wrong capital letter. Python cares about spelling and capitalisation.

Your task

Write a program that prints three lines: your name, your town and your favourite food.

Questions & answers (0)

Sign in or create a free account to join the conversation.

No questions yet. Ask the first one.