[Tutor] conditionals or comparison or expressions terminology

Peter Otten __peter__ at web.de
Tue Feb 4 13:22:27 CET 2014


Ian D wrote:

> Are:
>  
> <=
> ==
> !=
>  
> simple conditionals statements, conditionals, comparison operators,
> conditional expressions or what?

[comparison] operators:

http://docs.python.org/3.3/reference/lexical_analysis.html#operators

a <= b # expression (something is evaluated; ideally there are no side
                     effects)
c = a <= b # statement (something is done, ideally only the side effect
                        matters)

if a <= b: # conditional [expression] (some action is taken based on the
                                       result of the expression)
    ...

while a <= b: # conditional [expression]
    ...

Context is important:

c(a <= b) # statement, assuming c does something permanent
if c(a <= b): # expression, ideally only the result of c(...) matters.

> I am looking at a few different pages and am unsure what I should be
> calling these expressions.
>  
> http://anh.cs.luc.edu/python/hands-
on/3.1/handsonHtml/ifstatements.html#simple-conditions
>  
> http://www.tutorialspoint.com/python/python_basic_operators.htm
>  
> http://docs.python.org/2/library/stdtypes.html#truth-value-testing
>  
> Thanks




More information about the Tutor mailing list