Skip to Main Content

Introduction to Python

This guide was designed to supplement the INTRODUCTION TO PYTHON virtual workshop. If you have concerns or suggestions for this guide, feel free to reach out to scholarlyengagement@tulane.edu.

What are assignment operators?

Assignment operators are used to perform an operation on a variable AND store the output into the manipulated variable. 

In this section, you will learn how to:

  • Conduct basic mathematical operations that update a variable 

Assignment Operator Code

Copy the following code on the left in your IDE to execute the process shown in the image on the right.


x = 5
x += 5

print (x)

x = 5
x -= 2
print (x)

x = 5
x *= 3
print (x)

x = 5
x /= 4
print (x)

x = 5
x %= 6
print (x)

x = 5
x **= 9
print (x)

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.