Python Introduction | Basics of Values and Calculations | Data Types
Data Types: Values Have Types
One of the first concepts new programmers encounter is that values have types.
Beginners often start with a scripting language such as Python. These languages let you write many programs without thinking much about data types, so it is easy to assume that any value can be placed in a variable and used in the same way.
Python values also have types. Numbers, text, and other kinds of values behave differently. Consider these three expressions.
print(123 + 456)
print('123' + '456')
print(123 + '456')
The first prints 579, the second prints 123456, and the third causes an error.

The first expression adds numbers. The second concatenates text. The third fails because it tries to combine values of different types.
Understanding data types is essential when using Python.
Common Value Types
Numbers
Python supports several numeric types.
- Integer (
int): An ordinary whole number. Write the number directly. - Floating-point number (
float): A number with a decimal point. - Complex number (
complex): A complex number. Writejafter the imaginary part.
For now, focus on integers and floating-point numbers. Learn complex numbers when you need them.
Text
Write text between quotation marks. Python supports single quotes, double quotes, and triple quotes.
'Hello' "Welcome" '''Bye'''
Single and double quotes behave the same way for ordinary text. Triple quotes are useful for text that spans multiple lines.
Boolean Values
A Boolean value represents one of two alternatives, such as true or false. Python provides the keywords True and False.
Using Common Value Types
Run the following examples one line at a time.
print(12345)
print('Hello')
print('''welcome,
and bye.''')
print(True)

Triple-quoted text may look unfamiliar at first. The other examples are straightforward.