What is the difference between Statement and Expression?
[Is there a way to execute the stored Python code in the form of a string?] I saw a comment here.
I know the expression is in a smaller range
I'm inquiring because I don't know exactly how the statement and expression are different.
python expression
expression includes only identifier, literal, and operator and is later expressed as a "value".
Here, the operator includes arithmetic (+, -, /, etc.), boolean (and, or not), ()
(function call), []
(subscription), etc.
3 + 5
map(lambda x: x*x, range(10))
yield 7
You can think of a statement as a more comprehensive "line."
Because expression alone can make a line, expression is also included in the statement, so it is also called an expiration statement.
print 42
if x: do_y()
return
a = 7
© 2024 OneMinuteCode. All rights reserved.