What is an expression in Python?

前端 未结 4 1339
醉话见心
醉话见心 2020-12-13 05:13

I have some confusion about its meaning or definition.

Isn\'t that some code that produce or calculate new data values? (Says Zelle in his book)

Then I wond

4条回答
  •  -上瘾入骨i
    2020-12-13 05:40

    string is an expression. An expression is anything that has "a value". Like 3, 'Hello world', 1+1, math.sqrt(9), etc. Function names are expressions too.

    eval() gives you the value of the expression that you give to it as a string. If you say eval('1+1') it returns 2. So it returns the same that would be returned if you simply write: 1+1.

提交回复
热议问题