fbpx

Boolean Expressions

What more can we do with Booleans?

We know that Booleans can hold either True or False values, but there are additional operations we can use to create simple and complex Boolean expressions. One way we can do this, which we just saw when dealing with if-else statements, is by using the comparison operators:

 

Try running the following segment of code to see what gets printed when we explore with Boolean expressions.

				
					print(5 < 3)
print(5 > 3)
print(type(5 < 3))
print(type(5 > 3))

my_fav_animal = "dog"
user_fav_animal = input("What is your favorite animal?") 
print(my_fav_animal == user_fav_animal)

				
			

Replit Practice

Loading...