Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Apprendre Fundamentals of Basic Math Operations in Python | Getting Familiar With Numbers in Python
Data Types in Python

bookFundamentals of Basic Math Operations in Python

Python supports fundamental arithmetic operations: addition (+), subtraction (-), multiplication (*), and division (/). These operations work with both integers (int) and floating-point numbers (float).

Addition (+)

Addition is used to sum two or more numbers.

1234
a = 5 b = 3 result = a + b print(result) # Output: 8
copy

5 + 3 returns 8, and the result is stored in the result variable.

Subtraction (-)

Subtraction finds the difference between two numbers.

1234
a = 10 b = 4 result = a - b print(result) # Output: 6
copy

10 - 4 equals 6, which is printed to the console.

Multiplication (*)

Multiplication calculates the product of two numbers.

1234
a = 6 b = 7 result = a * b print(result) # Output: 42
copy

The number 6 is multiplied by 7, resulting in 42.

Division (/)

Division returns the quotient of two numbers.

1234
a = 20 b = 5 result = a / b print(result) # Output: 4.0
copy

The result of 20 / 5 is 4.0 (a floating-point number).

Exponentiation (**)

Exponentiation is used to raise a number to the power of another number. In Python, this is done using the ** operator.

1234
base = 2 exponent = 3 result = base ** exponent print(result) # Output: 8
copy
question-icon

Follow the comments.

# Calculate the addition of integer and floating number
number_1 =


# Raise floating point number to the power of integer number
number_2 =


print(number_1)
print(number_2)
184.2
274.625

Click or drag`n`drop items and fill in the blanks

Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 1. Chapitre 4

Demandez à l'IA

expand

Demandez à l'IA

ChatGPT

Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion

Awesome!

Completion rate improved to 3.03

bookFundamentals of Basic Math Operations in Python

Glissez pour afficher le menu

Python supports fundamental arithmetic operations: addition (+), subtraction (-), multiplication (*), and division (/). These operations work with both integers (int) and floating-point numbers (float).

Addition (+)

Addition is used to sum two or more numbers.

1234
a = 5 b = 3 result = a + b print(result) # Output: 8
copy

5 + 3 returns 8, and the result is stored in the result variable.

Subtraction (-)

Subtraction finds the difference between two numbers.

1234
a = 10 b = 4 result = a - b print(result) # Output: 6
copy

10 - 4 equals 6, which is printed to the console.

Multiplication (*)

Multiplication calculates the product of two numbers.

1234
a = 6 b = 7 result = a * b print(result) # Output: 42
copy

The number 6 is multiplied by 7, resulting in 42.

Division (/)

Division returns the quotient of two numbers.

1234
a = 20 b = 5 result = a / b print(result) # Output: 4.0
copy

The result of 20 / 5 is 4.0 (a floating-point number).

Exponentiation (**)

Exponentiation is used to raise a number to the power of another number. In Python, this is done using the ** operator.

1234
base = 2 exponent = 3 result = base ** exponent print(result) # Output: 8
copy
question-icon

Follow the comments.

# Calculate the addition of integer and floating number
number_1 =


# Raise floating point number to the power of integer number
number_2 =


print(number_1)
print(number_2)
184.2
274.625

Click or drag`n`drop items and fill in the blanks

Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 1. Chapitre 4
some-alt