A program can calculate or store information without showing it. To make a value visible in these examples, we use Python’s built-in print() function.
A function is a reusable operation that can be called by name. We will learn to create functions later; for now, Python already provides print. The parentheses hold the value we want it to display:
print("Platform 3")
Platform 3
The quotation marks tell Python that Platform 3 is text. They are part of the code’s notation, not part of the displayed text. The parentheses mark the call to print; they do not appear in the output either.
Text and numbers are different kinds of values
A value is a piece of data a program can work with. A sequence of text characters is called a string. A whole number such as 6 is an integer. These names describe different kinds of values, also called types.
print("6")
print(6)
Both lines display a 6:
6
6
The output alone does not reveal which value was a string. In the code, the quotation marks make the first 6 text; the second is a number. This difference matters when we ask Python to perform an operation. For example, adding two numbers calculates a sum, while adding two strings joins their text:
print(6 + 2)
print("6" + "2")
8
62
The second result is the characters 6 and 2 placed together, not the number sixty-two produced by arithmetic. Python does not automatically treat quoted digits as numbers in this expression.
What happens inside the parentheses?
An expression is a piece of code that produces a value. In 6 + 2, Python evaluates the addition before print displays the resulting value.
6 + 2 → 8 → print displays 8
The same distinction applies to other expressions: the expression is written in the program; its result is the value passed to print. This chapter uses small examples so that we can follow each step without needing other Python features yet.