为什么在更改变量后显示相同的值

我写这段代码:

a=5
b=4
s=a*b
print(s)
20

然后我将变量“ a”更改为6:

a=6
print(s)
20

I changed variable "a" and when i say print(a) it shows new variable(6) but when I say print(s) it shows the same number(20) I wonder why this happens. I expected it shows me s=24 but why it shows 20 again?

评论
  • eut
    eut 回复

    您必须再次计算s才能更改s。

    a=6
    s=a*b
    print(s)
    

  • 留景同
    留景同 回复

    After you changed a=6 you have to compute s=a*b again to take in account the new value of a.