1. Introduction to Python Programming: Basics, Features, and Applications
2. Python Environment Setup: How to Install Python on Your Computer
3. Introduction to Python Programming: A Beginners Guide with Examples
4. Python Variables: A Comprehensive Guide with Examples
5. Python Numbers: A Comprehensive Guide with Examples
6. Python Strings Tutorial: Learn Strings Manipulation with Codes and Examples
7. Python If-Else Statement: Learn Conditional Statements with Codes and Examples
8. Python Loops: A Complete Guide with Codes and Examples (2023)
9. Python Lists: A Comprehensive Guide with Codes and Examples in 2023
10. Python Dictionary Tutorial with Codes and Examples in 2023
11. Python Sets, Set Comprehension, and Looping - A Complete Guide with Examples
12. Python Classes and Objects Tutorial with Codes and Examples in 2023
13. Python Tuples: An Overview with Examples and Code Snippets - 2023

**Article by:** Manish Methani

**Last Updated:** October 7, 2021 at 8:04am IST

- Numeric Data Types in Python Python has three main numeric data types:

- Integers (int): Whole numbers, positive or negative, without a decimal point.
- Floating-point numbers (float): Numbers with a decimal point or an exponent notation.
- Complex numbers (complex): Numbers with a real and imaginary part.

Here are some examples:

# Integers x = 5 y = -10 z = 0 # Floating-point numbers a = 3.14 b = 1.23e-5 # Complex numbers c = 3 + 4j d = complex(1, -2)

2. Basic Arithmetic Operations

Python supports all basic arithmetic operations for numerical data types. Here are some examples:

x = 5 y = 3 # Addition z = x + y # Output: 8 # Subtraction z = x - y # Output: 2 # Multiplication z = x * y # Output: 15 # Division z = x / y # Output: 1.6666666666666667 # Floor Division z = x // y # Output: 1 # Modulo z = x % y # Output: 2 # Exponentiation z = x ** y # Output: 125

3. Type Conversion

Python allows you to convert numerical data types from one to another. Here's an example:

x = 5 y = 3.14 # Convert x to a floating-point number and add it to y z = float(x) + y print(z) # Output: 8.14

In this example, we convert the integer "x" to a floating-point number using the `float()`

function and add it to the floating-point number "y".

4. Built-in Functions Python has several built-in functions for working with numbers. Here are some examples:

# Absolute value x = abs(-10) # Output: 10 # Round to a certain number of decimal places y = round(3.14159, 2) # Output: 3.14 # Maximum and minimum values z = max(1, 2, 3) # Output: 3 a = min(4, 5, 6) # Output: 4

5. Math Module

Python also has a math module that provides additional mathematical functions. Here's an example:

import math # Square root x = math.sqrt(25) # Output: 5.0 # Trigonometric functions y = math.sin(0) # Output: 0.0 z = math.cos(math.pi) # Output: -1.0

6. Floats

Floats are used to represent real numbers with decimal points. They are also known as floating-point numbers. In Python, float is represented by `float`

class. We can create a float variable by assigning a value with a decimal point to it.

Here's an example:

# Example of float x = 3.14 y = 2.5 print(x) print(y)

Output:

3.14 2.5

We can also use mathematical operations with floats:

# Example of float with mathematical operations x = 3.14 y = 2.5 z = x + y print(z)

Output:

5.64

Complex numbers are used to represent numbers with a real and imaginary part. In Python, complex numbers are represented by `complex`

class. We can create a complex number by specifying the real and imaginary parts separated by a `+`

or `-`

sign.

Here's an example:

# Example of complex number x = 2 + 3j y = 4 - 2j print(x) print(y)

Output:

(2+3j) (4-2j)

We can also use mathematical operations with complex numbers:

# Example of complex number with mathematical operations x = 2 + 3j y = 4 - 2j z = x + y print(z)

Output:

(6+1j)

We can convert one type of number into another using type conversion functions. Here are some type conversion functions in Python:

`int(x)`

converts x to an integer.`float(x)`

converts x to a floating-point number.`complex(x)`

converts x to a complex number with a zero imaginary part.`complex(x, y)`

converts x and y to a complex number with real part x and imaginary part y.

Here are some examples:

# Example of type conversion x = 10 y = 3.14 z = 2 + 3j # convert x to float a = float(x) # convert y to int b = int(y) # convert z to float c = float(z) print(a) print(b) print(c)

Output:

10.0 3 (2+3j)

We have covered the basics of Python Numbers in this tutorial.

Firebase & Angular.

Looking to learn how to create the production-ready apps

from scratch? Well, you are at the right place.

₹1299 or $15.56

## Learn to create the Dating App using No-Code Tool FlutterFlow

Level: **Advanced**

Mock Tests.

Test your C Programming skills with this comprehensive mock test on C Programming.

Take TestSolve most asked Interview Questions on Flutter and Test your foundational skills in flutter.

Take TestSolve most asked GATE Questions in Operating Systems and test your Gate Score.

Take TestThis is a mock test designed to help you assess your knowledge and skills in HTML and CSS.

Take TestSolve most asked GATE Questions in Data Structures and Algorithms and test your Gate Score.

Take TestMobile App