Config Router

  • Google Sheets
  • CCNA Online training
    • CCNA
  • CISCO Lab Guides
    • CCNA Security Lab Manual With Solutions
    • CCNP Route Lab Manual with Solutions
    • CCNP Switch Lab Manual with Solutions
  • Juniper
  • Linux
  • DevOps Tutorials
  • Python Array
You are here: Home / what does +=, -=, *= and /= stand for in Python? [duplicate]

what does +=, -=, *= and /= stand for in Python? [duplicate]

August 19, 2021 by James Palmer

These (+=, -=, *= and /=) are called augmented arithmetic assignments. They correspond to the following methods:
object.__iadd__(self, other)
object.__isub__(self, other)
object.__imul__(self, other)
object.__idiv__(self, other)

the i semantically means “in-place”, which means that they modify the object (or reference in the case of numerics) without having to additionally assign them:
while condition:
foo += bar

is equivalent to:
while condition:
foo = foo + bar

They are performing the operation and then assigning it into the variable:
a += b is the same as: a = a + b
a -= b is the same as: a = a – b
a *= b is the same as: a = a * b
a /= b is the same as: a = a / b
You can use them in a while loop in the same way you would use the extended forms:
i = 0
while i < 5: print i i += 1 # The same of i = i + 1

Related

Filed Under: Uncategorized

Recent Posts

  • How do I give user access to Jenkins?
  • What is docker volume command?
  • What is the date format in Unix?
  • What is the difference between ARG and ENV Docker?
  • What is rsync command Linux?
  • How to Add Music to Snapchat 2021 Android? | How to Search, Add, Share Songs on Snapchat Story?
  • How to Enable Snapchat Notifications for Android & iPhone? | Steps to Turn on Snapchat Bitmoji Notification
  • Easy Methods to Fix Snapchat Camera Not Working Black Screen Issue | Reasons & Troubleshooting Tips to Solve Snapchat Camera Problems
  • Detailed Procedure for How to Update Snapchat on iOS 14 for Free
  • What is Snapchat Spotlight Feature? How to Make a Spotlight on Snapchat?
  • Snapchat Hack Tutorial 2021: Can I hack a Snapchat Account without them knowing?

Copyright © 2025 · News Pro Theme on Genesis Framework · WordPress · Log in