what 27s the difference between a statement and an expression in python 3f

Solutions on MaxInterview for what 27s the difference between a statement and an expression in python 3f by the best coders in the world

showing results for - "what 27s the difference between a statement and an expression in python 3f"
Alejandra
24 Mar 2016
1#Here’s a general rule of thumb: If you can print it, or assign it to a 
2#variable, it’s an expression. If you can’t, it’s a statement.
3
4#Here are some examples of expressions:
52 + 2 
63 * 7 
71 + 2 + 3 * (8 ** 9) - sqrt(4.0) 
8min(2, 22) 
9max(3, 94) 
10round(81.5) 
11"foo" 
12"bar" 
13"foo" + "bar" 
14None 
15True 
16False 
172 
183 
194.0 
20
21#All of the above can be printed or assigned to a variable.
22#Here are some examples of statements:
23if CONDITION: 
24elif CONDITION: 
25else: 
26for VARIABLE in SEQUENCE: 
27while CONDITION: 
28try: 
29except EXCEPTION as e: 
30class MYCLASS: 
31def MYFUNCTION(): 
32return SOMETHING 
33raise SOMETHING 
34with SOMETHING: 
35  
36#Remaining answer can be found in the source
37###Answered by Ryan Lam
38