Member-only story

Cracking the Code: Unraveling the Mystery of Numbers in Python

A Beginner’s Guide to Mastering the Numeric Types and Operations in Python

Max N
2 min readJun 26, 2023
Photo by Waldemar on Unsplash

Introduction

In the world of Python, numbers are more than just digits. They are the building blocks of your code, the foundation of your algorithms, and the key to unlocking the full potential of Python.

In this article, we will explore the different types of numbers in Python, how to use them, and some tricks that will make your coding journey easier and more efficient.

The Basics — Integers and Floats

Python supports various types of numbers, but the most commonly used are integers and floats. Integers are whole numbers, positive or negative, without any decimal points.

Floats, on the other hand, are numbers that do have decimal points.

# Integer
x = 10
print(type(x)) # <class 'int'>

# Float
y = 10.5
print(type(y)) # <class 'float'>

Mathematical Operations with Integers and Floats

Python supports all the basic mathematical operations you would expect, such as addition (+), subtraction (-), multiplication (*), division (/), and exponentiation (**).

--

--

Max N
Max N

Written by Max N

A writer that writes about JavaScript and Python to beginners. If you find my articles helpful, feel free to follow.

No responses yet