Iteration 1: s$um=0$ and $x=0$ $\Rightarrow$ $sum = 0+0$ and $x$ increase by $10$
Iteration 2; $sum=0+10=10$ and $x$ increase by $10$ so it becomes $x=20$
Iteration 3: $sum=10+20=30$ and $x$ increase by $10$ so it becomes $x=30$
.
.
.
.
Iteration 51: $sum=12250+500=12750$ and $x$ increase by $10$ so it becomes $x=510$, now the condition $x\leq500$ will become false and it will come out of for loop
so we see that $sum$ is nothing but A.P $0+10+20+30+…….$, with $n=51, a=0, d=10$
using $S_n=\frac{n}{2}(2a+(n-1)d)$ we will get $12750$