Python for Humans · Draft v0.5 · Nov 10, 2026 · Introduction · Introduce the Python example in the language comparison and format its inline code.
Introduction
Hi! Welcome to Python for Humans, a free online course for learning how to code with the Python programming language. Learning Python has changed my life, and it can change yours, too.
Why Python?
Python is particularly friendly to beginners because its syntax is relatively straightforward and readable. To display a message, for example, you can simply write print("Hello, World!"). Other programming languages often require more setup and syntax to accomplish the same thing.
And Python isn't just for beginners. It's used professionally for websites, artificial intelligence, scientific research, automation, and much more.
Want to see Python vs other programming languages?
In Python, displaying "Hello, World!" takes one line:
print("Hello, World!")
In Java, another popular programming language, it looks like this:
public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, World!"); } }
And in C++, again a programming language used often by professional programmers, the syntax required is this:
#include <iostream> int main() { std::cout << "Hello, World!" << std::endl; return 0; }
Quite a difference, right? All three programs display the same message, but Python requires considerably less code.
At this point, traditionally you would need to install Python on your computer and figure out how to run it. But we're going to skip all that for now (later in the course it will be covered). You can write and run Python directly on this page and for the first chapters of this course we'll only work in the browser.
Your First Python Program
Python comes with a built-in print() function that displays messages on the screen. To display text, put it between quotation marks, either double "" or single ''. Try it out for yourself.
print("Will this really print anything I type?") print('Yes, it should.')
Now get creative. Update the text within print(" ") above to prove to yourself that what I just said was true and then Run it. I'll wait.
Do you need some inspiration? That's ok. Here are several lines of code to run and update as you like.
print("This is pretty cool, right?") print("What happens if you use numbers?") # Swap out the numbers below with something new print("2 + 2") print(2 + 2)
Did you notice something strange there? When numbers like 2 are surrounded by quotes, "", they are treated like text. But if you remove the quotes then Python will perform basic arithmetic on them. That's a little odd, right? You're seeing that the + operator will add numbers when they are present, otherwise it will join together words and spaces. Interesting, right?
Now get creative. Change the text inside print() to say anything you want, then click Run again. Try adding a third print() statement to display another message. I'll wait.
We'll exploit this fact in some fun ways soon.
Errors
Wouldn't it be nice if every program worked perfectly the first time? Unfortunately, that's rarely the case. Even after years of programming, I still make mistakes all the time. Errors are a normal part of programming, and learning how to fix them is an important skill.
# This code has an error in it. What happens when you select Run? print("I mixed my single and double quotes here!')
Uh oh! Python gives us a SyntaxError in angry red text. But don't worry. Error messages often provide useful clues about what went wrong.
Can you spot the problem? We started our message with a double quote but ended it with a single quote. Python expects them to match. Try fixing the code and running it again.
Numbers and Text
So far, we've used Python to print out messages. But Python can also do math! Try running the following code:
print(2 + 2) print(6 - 3) print(5 * 5) print(10 / 2)
Pretty straightforward, right? Python can add, subtract, multiply, and divide numbers. Notice that we use * for multiplication and / for division.
But here's something interesting. What do you think will happen when you run these two lines of code?
print(2 + 8) print("2" + "8")
The first line prints 10, as you'd expect. But the second prints 28! What's going on?
When you put quotation marks around something, Python treats it as text, even if it looks like a number. In programming, we call text a string. Without quotation marks, Python treats 2 and 8 as numbers and adds them together.
You can also use + to join strings together and * to repeat them.
print("Hello" + " World!") print("ha" * 5)
Your turn: Change "ha" to something else and experiment with the number 5. What happens if you make it 100?
As you've discovered, Python uses the same symbols for different purposes depending on whether you're working with numbers or strings. And we're going to take advantage of that soon!
Variables
So far, we've been typing words and numbers directly into our programs. But what if we wanted to use the same piece of information again and again? Or change it in one place and have that change affect the rest of our program?
message = "ha" print(message * 3) print(message * 10) print(message * 20)
Run it once, then change "ha" to "🐍" and run it again.
We changed just one line of code, but the result changed in three different places.
That's the power of a variable. It's simply a name we've given to a piece of information so we can use it again. Here we called it message, but we could have called it almost anything.
Imagine changing one variable in a program with thousands of lines of code. A single change could affect the entire program!
Input
A final tool to add before we put everything together is input(), a built-in function that pauses the program and waits for the user to type something. A function is a named piece of code that performs a task. You've already used one with print(). Now let's try another: input().
name = input("What's your name? ") print("Hello,", name)
Now let's put everything we've learned together.
Time Machine
We've played around with strings, numbers, and variables. Now let's put them together and build our first little program: a time machine! Click Run to see where it takes you.
print("Welcome to the Future Machine!") name = input("What's your name? ") age = int(input("How old are you? ")) future_age = age + 20 print(name, "in 20 years you'll be", future_age)
Notice the int() around our second input()? Python treats anything someone types using input() as text, even if it looks like a number. The int() function converts that text into a whole number (an integer) so we can do math with it. Without int(), Python wouldn't know how to add 20 to our age.
Okay, so we haven't actually traveled through time. But look at what our program is doing. We've printed out a greeting, stored a string and a number in variables, then created another variable future_age that adds 20 to the number, and finally displayed the result.
Your turn: Upgrade the Time Machine
Change 20 to 50 and give your Time Machine a more interesting welcome message.
Bonus: Can you turn it into a Past Machine that calculates how old someone was five years ago?
Need help with a code box?
- Start over: Click Restore original example to bring back the course's starting code and clear the output. Undo restore brings your edit back until you edit again or leave the page.
- Stop a program: Click Restart to stop it and clear its output. Your edited code stays in the box.
- Keep your code: This browser remembers your edits when browser storage is available. To keep a separate copy, select your code and copy it into a plain-text file. Clearing your browser's data also clears those saved edits.
We'll learn to save and run Python files on your computer later. For now, you can keep experimenting here.
What's Next?
It may not seem like it but you've already learned a lot in just one short chapter. You've written your first Python code, played with strings and numbers, and used variables to change what a program does. And we've barely scratched the surface.
Python can be used to build games, websites, and apps, analyze data, automate boring tasks, and create things nobody has thought of before. You don't need to understand everything before you start building. You can learn as you go, one little program at a time.
Ready for more? Let's write some Python!