coding180 icon
Coding180
Number Data type

Number Data type

Home > Tutorials > Python for beginners > Python Datatypes


In Python, there are different types of data that we can use in our programs, and one of these types is called "numbers." We use numbers to represent things like how many apples we have, or how much money we have in our piggy bank.

Here are some examples of numbers in Python:

# This is a whole number, also called an integer
7

# This is a decimal number, also called a float
3.14

We can use these numbers in different ways in our code. For example, we can use the + operator to add two numbers together:

# This code adds 2 and 3, and prints the result (5)
print(2 + 3)

Or, we can use the - operator to subtract one number from another:

# This code adds 2 and 3, and prints the result (5)
print(10 - 3)

We can also use numbers to keep track of how many times something happens, or to control how many times a loop runs in our code:

# This code prints "Hello" three times
for i in range(3):
  print("Hello")

 


user

Robort Gabriel

Lagos, Nigeria

Freelance Web Developer, Native Android Developer, and Coding Tutor.

Skills
  • UI / UX
  • JavaScript
  • Python
  • PHP
  • Kotlin
  • Java
  • Bootrap
  • Android
  • Laravel