-
Use logical operators and : Use the two conditions and Connected, the entire conditional expression is considered true only when both conditions are true. For example:
x = five y = ten
if x > zero and y > zero : print ( "X and y are both greater than 0" ) #Output: x and y are both greater than 0
-
Use logical operators or : Use the two conditions or If any condition is true, the entire conditional expression will be considered true. For example:
age = twenty-five nationality = "USA"
if age >= eighteen or nationality == "USA" : print ( "Adult or American" ) #Output: adult or American
x = five y = ten
if (x > zero ) and (y > zero ): print ( "X and y are both greater than 0" )