Boolean operation in if : If « Language Basics « Python






Boolean operation in if

Boolean operation in if

# number <= 10 and number >= 1 could be written as 1 <= number <= 10

number = 1
if number <= 10 and number >= 1:
    print 'Great!'
else:
    print 'Wrong!'

           
       








Related examples in the same category

1.Nested if statementNested if statement
2.if-else structureif-else structure
3.if-elif-else structureif-elif-else structure
4.if structureif structure
5.if Statements: if, elif and elseif Statements: if, elif and else
6.elif demoelif demo
7.if with elseif with else
8.If statement: a dictionary-based 'switch'If statement: a dictionary-based 'switch'
9.Leap Year checkerLeap Year checker