top of page

Assignment (Shortcut) operators

If

variable = variable op expression

then

variable op= expression

i += 2 * j => i = i+2*j

var /= 2 => var = var /2

rem %= 10 => rem = rem % 10

j -= (i + var + rem) => j-(i + var + rem)

x **= 2 => x = x **2

x *= 2 => x = x*2

sheep += 1 => sheep = sheep +1

Reference:

 

In fact, shortcut operators put a parenthesis to the whole right side.

a = 6

b = 3

a /= 2 * b

print(a)

a /= 2 * b => a = a/(2*b) => a = 6/(2*3) = 1

For this reason, this is also called Python Assignment Operators

aboutME

I am John Fan Zhang, a data analyst and finance researcher. I hold a PhD in finance, CFA charter and full membership of CFA New Zealand Society. I have fifteen-year experience in corporate investment and eight-year experience in advanced data analysis. My research focuses on the effect of social psychology (culture) on financial decisions. Finance research involves heaps of data analyses that lead me to the data field. I am a Microsoft Certified Solutions Expert (MCSE): Data Management and Analytics (Excel, Power BI, and SQL). Aside from Excel, Power BI and SQL, I am also familiar with econometric tools such as Stata, Eviews, and MATLAB. I use OX and Python for programming. I am an active data community event participant, volunteer, speaker, moderator, program reviewer, including PASS Marathon 2020, Global AI BootCamp Auckland 2019, SQL Saturday Auckland (2017, 2018, 2019), and Definity Conference (2018, 2019, 2020, Auckland, New Zealand).

Auckland, New Zealand

  • Google Site
  • Twitter
  • LinkedIn

©2016 BY JOHN'S DATA STORY

bottom of page