15. the big if


Hi, I got stuck and don't know what is wrong. May someone suggest a solution? Thanks :smile:

Make sure that the_flying_circus() returns True

def the_flying_circus():
if < 20 or > 30:
print "Fair enough"
elif > 20 or < 24:
print "Hello"
print "Jupp"
return True


= https://docs.python.org/2/library/stdtypes.html
5.3. Comparisons¶

Comparison operations are supported by all objects. They all have the same priority (which is higher than that of the Boolean operations). Comparisons can be chained arbitrarily; for example, x < y <= z is equivalent to x < y and y <= z, except that y is evaluated only once (but in both cases z is not evaluated at all when x < y is found to be false).

This table summarizes the comparison operations:

Operation    Meaning
     <      strictly less than   
    <=      less than or equal   
    >       strictly greater than   
    >=      greater than or equal   
    ==      equal   
    !=      not equal (1) 
    is      object identity
    is not  negated object identity

4.2. Boolean Operations — and, or, not¶

These are the Boolean operations, ordered by ascending priority:

Operation  Result                               Notes

x or y     if x is false, then y, else x        (1) 
x and y    if x is false, then x, else y        (2) 
not x      if x is false, then True, else False (3)

1.This is a short-circuit operator, so it only evaluates the second argument if the first one is False.
2.This is a short-circuit operator, so it only evaluates the second argument if the first one is True.
3.not has a lower priority than non-Boolean operators, so not a == b is interpreted as not (a == b), and a == not b is a syntax error.


Write an if statement in the_flying_circus(). It must include:
01. if, elif, and else statements;
02. At least one of and, or, or not;
03. A comparator (==, !=, <, <=, >, or >=);
04. Finally, the_flying_circus() must return True when evaluated.

 40 < 20 or 20 > 30
 30 > 20 and 30 < 24


Thanks, awesome, now it worked!


def the_flying_circus():
if( 3<4) and (5>4):
print "start engine"
return True# Start coding here!
# Don't forget to indent
# the code inside this block!
elif (1<9)or (9>10):
print " fill fuel"
return True
return False

whats wrong with this code ?