Python numbers

Numbers

Python has three built-in numeric data types: integers, floating-point numbers, and complex numbers. In this section, you'll learn about integers and floating-point numbers, which are the two most commonly used number types. You'll learn about complex numbers in a later section.

# numbers.py - file name

number = 1
decimal_number1 = .5
decimal_number2 = 10.5

# you can use the underscores to make the numbers more visible when coding
# The underscores will not be added to the output
salary = 21_500_000

pi = 3.142
r = 5

# simple arithmetic operation using python number type
area = pi * r ** r
print(area)

To run the code, simply open your terminal for Mac OS users, command prompt or powershell for Windows OS users and run the following command:

python numbers.py

Last updated