Lesson 1 of 30 · Getting Started
What Is Python?
Meet Python, the language behind most AI. Learn what it is, why it is so popular and run your first line of code right here in your browser.
- 7 min read
- Beginner
- Reviewed
- What a programming language is, in plain words
- Why Python is the number one language for AI
- How to run real Python code on this page, with nothing to install
What is a programming language?
A computer is very fast, but it cannot guess what you want. You have to give it instructions, one step at a time. A programming language is the way we write those instructions so the computer can follow them.
Think of a recipe. A recipe is a list of steps written in a language the cook understands. A program is a list of steps written in a language the computer understands.
Python is one of those languages. It was created by Guido van Rossum and first released in 1991. He wanted a language that was easy to read, almost like plain English.
Your first look at Python
Here is a complete Python program. It is one line long.
print("Hello, world!")When you run it, the computer shows this:
Hello, world!
That is all. print tells Python to show something on the screen, and the text inside the quotation marks is what it shows.
Try it yourself
You do not need to install anything. The box below is a real Python editor. Press Run, then change the message and run it again.
print("Hello, world!")
print("I am learning Python.")Why is Python so popular?
Python is used by beginners and by the engineers who build systems like ChatGPT. Here is why.
- It is easy to read. Python code looks close to English, so you spend your time learning ideas, not symbols.
- It is short. A task that takes ten lines in other languages often takes two or three in Python.
- It is free. Anyone can download and use it, on Windows, macOS or Linux.
- It has a library for almost everything. A library is code other people wrote that you can reuse.
To see how readable Python is, compare the same program in two languages.
| Python | Java |
|---|---|
print("Hello") | public class Main { public static void main(String[] args) { System.out.println("Hello"); } } |
Both programs do the same thing. Python just asks for less.
Why Python for AI?
Almost every major AI tool is built to be used from Python:
- NumPy and Pandas for working with data
- scikit-learn for machine learning
- PyTorch and TensorFlow for deep learning
- Hugging Face, LangChain and the OpenAI and Anthropic libraries for generative AI
So when you learn Python, you are learning the language that the whole AI world speaks. Every later course on this site builds on what you learn here.
Python can do maths, too
print can show numbers and the results of calculations. Run this and then try your own sums.
print(2 + 3)
print(10 * 5)
print("2 + 3 =", 2 + 3)Notice two things. Numbers do not need quotation marks. Text does. Text inside quotation marks is called a string, and you will learn all about strings in a later lesson.
Common mistakes
Errors are normal. Every programmer sees them every day. Try breaking the code below on purpose: remove one quotation mark, run it, and read the message Python gives you. Then fix it.
print("Errors help you learn")Make the program print exactly Hello, Python! and press Run. The exercise checks your output automatically.
# Change the line below so it prints: Hello, Python!
print("Hello")What does print() do in Python?
Summary
- A program is a list of instructions for a computer.
- Python is a programming language designed to be easy to read.
- Python is the main language of AI and data science.
print()shows text or numbers on the screen.- Text goes inside quotation marks. Numbers do not.
In the next lesson you will write a slightly longer program and learn how Python reads your code line by line.
Finished reading? Tick it off to track your progress.