Booleans and Conditinals
whats a boolenan?
A boolen is a data type with two valuse true or false one bit
can use strings and print true and false print(“100 == 100:”,100==100) print(“Hello == Adios:”,”greeting”==”farewell”) print(“Hello != Adios:”,”greeting”!=”farewell”) print(“Hello == Hola:”,”greeting”==”greeting”) print(“5>=4:”, 5>=4) print (‘’)
Notice that relational operators can even work on lists!
For lists, the relational operator compares each respective component until an answer is derived
print(“[‘a’,’b’,’c’] > [‘x’,’y’,’z’]:”, [‘a’,’b’,’c’] > [‘x’,’y’,’z’]) print(“[1,2,3,5] > [1,2,3,4]:”, [1,2,3,5] > [1,2,3,4]) print(“[1,2,3,5] < [1,2,3,4]:”, [1,2,3,5] < [1,2,3,4]) print(“[1,2,3,5] == [1,2,3,4]:”, [1,2,3,5] == [1,2,3,4])
conditinals decide between true and false also known as if statments
nested conidtinals is if’s in ifs basicaly if else.