๐ Study helper: Before you read, try to answer this: which Python command shows words on the screen? (The answer is at the bottom of the page.)
This is your pocket map of Python โ the commands a beginner really uses. Every card shows a tiny example, what it does in plain words, and what you will see when you run it.
Tap the ๐ Copy button on any example to copy it, then paste it into IDLE and run it. Or type the example yourself โ typing is great practice. Every example on this page was run on a real Python before this page was written, and the "You will see" lines are what Python really printed.
Pick your grade:
print โ Say Something
What it does: Shows words or numbers on the screen. The words appear, but the quote marks do not.
print("Hello, world!")
You will see: Hello, world!
input โ Ask a Question
What it does: Asks a question and waits for an answer. Whatever you type is saved in a variable (here, the variable is called name).
name = input("What is your name? ")
print("Hello, " + name + "!")
You will see: Python asks the question and waits. If you type Alex and press Enter, you will see: Hello, Alex!
Variables โ Boxes With Names
What it does: A variable is like a box with a name on it. The = sign puts something in the box. Here, the number 9 goes into a box named age.
age = 9
print(age)
You will see: 9
Numbers and Math Signs
What it does: Python is a calculator. + adds. - takes away. * (the star) means multiply. / means divide.
You will see: 5, then 6, then 15, then 4.0. (Divide answers wear a ".0" โ that is Python telling you it used division.)
Words in Quotes โ Text
What it does: Words inside quotes are called text (grown-ups call it a "string"). A + glues text together. A * repeats it.
print(3 * "un" + "ium")
You will see: unununium โ "un" three times, glued to "ium". (This silly example comes right out of Python's own tutorial!)
if / else โ Making a Choice
What it does:if asks a yes-or-no question. If the answer is yes, Python runs the lines that are pushed in with spaces. else means "otherwise" โ run these instead.
points = 10
if points >= 10:
print("You win a star!")
else:
print("Keep playing!")
You will see: You win a star! (The spaces at the front of the middle lines matter โ they tell Python those lines belong to the if.)
for and range โ Do It Again
What it does:for repeats a job. range(3) counts 0, 1, 2 โ it gives one number at a time, and the loop runs once for each.
for n in range(3):
print(n)
You will see: 0, then 1, then 2, each on its own line.
Comments โ Notes With #
What it does: A # starts a note for people. Python skips notes completely โ they are only for you and other readers.
# This line is a note. Python skips it.
print("I run!")
You will see: I run!
print โ Show Something
What it does:print() writes what you give it to the screen. Text is printed without its quotes. You can print more than one thing by separating with commas โ Python puts a space between them.
print("Hello, world!")
You will see: Hello, world!
input โ Ask and Save the Answer
What it does:input() prints its question, waits for typing, and hands back what was typed โ always as text. Here the answer is saved in the variable name, then glued into a greeting with +.
name = input("What is your name? ")
print("Hello, " + name + "!")
You will see: the question first. Type Alex, press Enter, and you will see: Hello, Alex! (To use an answer as a number, wrap it: int(input(...)) turns typed digits into a real number โ the Guess-the-Number program in this series uses that.)
Variables โ Named Storage
What it does: The = sign assigns a value to a variable: the value on the right goes into the name on the left. You can read the box any time by using its name.
age = 9
print(age)
You will see: 9
Numbers and Math Signs
What it does:+ add, - subtract, * multiply, / divide. Parentheses () group things, just like math class. Dividing with / always gives an answer with a decimal point.
What it does: Two stars ** mean powers: 5 ** 2 is 5 ร 5. The % sign gives the remainder โ what is left over after dividing.
print(5 ** 2)
print(17 % 3)
You will see: 25, then 2. (17 รท 3 is 5 with 2 left over.) Both of these examples come straight from Python's own tutorial.
Text in Quotes โ Strings
What it does: Text in single or double quotes works the same either way. + glues strings together, and * repeats a string. len() tells you how long a string is.
print(3 * "un" + "ium")
You will see: unununium. (Python's tutorial uses this exact example โ with single quotes, which give the same result.)
if / elif / else โ Choosing a Path
What it does:if tests a question. If it is true, the indented lines under it run. else catches everything else. (There can also be elif โ "else if" โ parts in the middle, for more than two choices.) The indented lines must all line up with the same number of spaces.
points = 10
if points >= 10:
print("You win a star!")
else:
print("Keep playing!")
You will see: You win a star! Change 10 to 5 and run it again to watch the else path run.
for Loops โ One Round Per Item
What it does: A for loop runs its indented lines once for each item in a sequence โ a list, a string's letters, or a range of numbers โ in order.
for n in range(3):
print(n)
You will see: 0, 1, 2 โ each on its own line.
while Loops โ Keep Going While It's True
What it does: A while loop keeps running as long as its condition stays true. Here, a = a + 1 makes a grow each round, so the loop can finish. (If nothing inside ever changes the condition, the loop never stops!)
a = 0
while a < 3:
print(a)
a = a + 1
You will see: 0, 1, 2 โ each on its own line.
range โ Counting, Python Style
What it does:range makes a run of numbers. range(5, 10) starts at 5 โ and stops before 10. Python's tutorial says it plainly: "The given end point is never part of the generated sequence."
for i in range(5, 10):
print(i)
You will see: 5, 6, 7, 8, 9 โ each on its own line. No 10!
Lists โ [Things, In, Brackets]
What it does: A list keeps items in order, written with commas inside square brackets. Counting positions starts at 0, so pets[0] is the first item. len() counts how many items there are.
What it does: The word def starts a function โ your own command. Python's tutorial: "def introduces a function definition. It must be followed by the function name and the parenthesized list of formal parameters." The body lines are indented. After you define it, you call it by name to run it.
def say_hi(name):
print("Hi, " + name + "!")
say_hi("Sam")
You will see: Hi, Sam! Now say_hi is a command you invented โ call it with any name you like.
Comments โ Notes With #
What it does: Everything after a # on a line is a comment โ a note for human readers. Python's tutorial says comments "are not interpreted by Python": the computer ignores them completely. A comment can sit on its own line, or at the end of a code line.
# This line is a note. Python skips it.
print("I run!") # This note is at the end.
You will see: I run!
๐ Words to Know
Variable โ a named box that holds a value, like a number or some text.
String โ text in quotes. (It sounds funny, but that is really its name.)
Loop โ lines of code that run again and again.
Condition โ a yes-or-no question Python checks, like a < 3.
Indent โ the spaces at the front of a line. In Python, indents are part of the rules: they show which lines belong together.
Function โ a command you build yourself with def, or one Python already has, like print.
๐ Study helper: The answer โ the command is print. If you remember only one command from this page, remember print: it is how Python talks to you.
๐ Keep Exploring
Ready to use these for real? Go to Your First Python Programs โ three whole programs to copy, run, and tinker with.
No Python on your computer yet? Start with an install page: Windows ยท Mac ยท Chromebook.
Sources
docs.python.org โ The Python Tutorial, "An Informal Introduction to Python" (numbers and math signs, text in quotes, lists, comments, the first while loop): https://docs.python.org/3/tutorial/introduction.html
Every example on this page was also run with Python 3.12.3 on November 7, 2026, before this page was written โ the "You will see" lines match what Python printed. Checked against the sources above on November 7, 2026.