Learn to code with step-by-step lessons. A place for students to work through programming fundamentals and build skills.
Computers work with different types of data. Knowing the main types helps you write code that does what you want.
int) — whole numbers: 3, 0, -7, 1003.14, 0.5, -2.1You can use them in maths: 2 + 3, 10 / 4, 3 * 5.
Strings are text. In Python you put them in quotes (single or double):
"hello"
'coding club'
"I'm learning Python"
Booleans are either True or False. They are used for yes/no decisions. In Python the capital T and F matter.
True
False
You can see what type something is with type():
type(42) # <class 'int'>
type(3.14) # <class 'float'>
type("hello") # <class 'str'>
type(True) # <class 'bool'>
Write a short program that prints your name (as a string) and your age (as a number). Use print() like this:
print("My name is Alex")
print(12)
Try printing a sentence that uses both text and a number (you can pass several things to print separated by commas).
Next: 1.2 Variables — storing values so we can use them again.