Contenido del Curso
Tipos de Datos en Python
Tipos de Datos en Python
Matemática Obligatoria
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.
a = 5 b = 3 result = a + b print(result) # output: 8
5 + 3
returns 8
, and the result is stored in the result
variable.
Subtraction (-
)
Subtraction finds the difference between two numbers.
a = 10 b = 4 result = a - b print(result) # output: 6
10 - 4
equals 6
, which is printed to the console.
Multiplication (*
)
Multiplication calculates the product of two numbers.
a = 6 b = 7 result = a * b print(result) # output: 42
The number 6
is multiplied by 7
, resulting in 42
.
Division (/
)
Division returns the quotient of two numbers.
a = 20 b = 5 result = a / b print(result) # output: 4.0
The result of 20 / 5
is 4.0
(a floating-point number).
⚠ Important!
You cannot divide by zero (0
). If you try to execute 10 / 0
, Python will raise a ZeroDivisionError
.
a = 10 b = 0 result = a / b # this will cause an error!
¡Gracias por tus comentarios!