Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

python
+
-
*
communitycreator

What are basic arithmetic operators in Python?

Rameen Farrukh

Python supports unique symbols that perform basic arithmetic and logical calculations. In this shot, we’ll be discussing some of the basic arithmetic operators used in Python.

The + operator

Just like basic mathematics, the + sign in Python is used to add two variables together. If you want to add two variables, all you have to do is write variable 1, followed by the + operator, and then variable 2.

var1=2
var2=4
print (var1 + var2)

The - operator

The - operator can be used to subtract two variables. In order to subtract two variables, just write variable 1, followed by the - operator, then variable 2.

var1=8
var2=4
print (var1 - var2)

The * operator

In Python, you can use the * operator to easily multiply two variables.

var1= 4
var2= 4
print(var1 * var2)

The / operator

Use the / operator to divide variable 1 by variable 2.

var1= 16
var2= 4

print(var1 / var2)

RELATED TAGS

python
+
-
*
communitycreator
RELATED COURSES

View all Courses

Keep Exploring