[Tutor] difference between expressions and statements

Dave Angel davea at davea.name
Thu Apr 10 02:59:16 CEST 2014


Jared Nielsen <nielsen.jared at gmail.com> Wrote in message:
> Hi Pythons,
> Could someone explain the difference between expressions and statements?
> I know that expressions are statements that produce a value.
> I'm unclear on functions and especially strings.
> Are any of the following expressions?
> 
> print(42)
> print("spam")
> spam = 42
> print(spam)
> 
> Is the first example producing a value or simply displaying an integer?
> Does a string count as a value?
> Is a variable assignment considered a value?
> If I print a variable is that considered production of a value?
>

Can't answer till you specify Python version.  The other answers
 all seem to assume version 3.x. In version 2, these are all
 statements,  none are expressions.


-- 
DaveA



More information about the Tutor mailing list