Math Examples

# Example 1

Assign the variable a to 2. Assign the variable b to 3. Print the sum of the variables.
1
a = 2
2
b = 3
3
print(a + b)
Copied!

# Example 2

Assign the variable a to 2. Assign the variable b to 3. Print the difference of a and b.
1
a = 2
2
b = 3
3
print(a - b)
Copied!

# Example 3

Assign the variable a to 11 and the variable b to 7. Print the product of a and b.
1
a = 11
2
b = 7
3
print(a * b)
Copied!

# Example 4

Assign the variable a to 121 and the variable b to 11. Print the quotient of a and b.
1
a = 121
2
b = 11
3
print(a / b)
Copied!

# Example 5

Assign the variable a to 121 and the variable b to 10. Print the result of a modulus b.
1
a = 121
2
b = 10
3
print(a % b)
Copied!

# Example 6

Assign the variable a to 2 and the variable b to 6. Print the result of a raised to the power of 6.
1
a = 2
2
b = 6
3
print(a ^ b)
Copied!

# Example 7

Assign the variable a to 2 and the variable b to 2. Print the result of a raise to the power of negative b.
1
a = 2
2
b = 2
3
print(a ^ -b)
Copied!