Close
Close

Practice questions on Boolean

Level 1

1.
Take two inputs from user and check whether they are equal or not.
print "Enter first number"
first = input()
print "Enter second number"
second = input()
print first == second

2.
Take 3 inputs from user and check :
all are equal
any of two are equal
( use and or )
print "first number"
first = input()
print "second number"
second = input()
print "third number"
third = input()
all = first == second and second == third and third == first
print "All are equal:",all
any = first == second or second == third or third == first
print "Any of three are equal:",any

3.
Take two number and check whether the sum is greater than 5, less than 5 or equal to 5.
print "Enter first number"
first = input()
print "Enter second number"
second = input()
sum = first+second
print "Sum is greater than 5:",sum>5
print "Sum is equal to 5:",sum==5
print "Sum is lesser than 5:",sum<5

4.
Judge the follwing expressions :
not(True and True)
True or False
not(False and True)
False and False
print not(True and True)
print True or True
print not(False and False)
print False and False

5.
Suppose passing marks of a subject is 35. Take input of marks from user and check whether it is greater than passing marks or not.
pm = 35
marks = input()
print "Marks is greater than passing marks:", marks>pm

Level 2

Level 3

Ask Yours
Post Yours