+ 5

Could anyone help me and explain me how to use "or" in Python?

21st Oct 2018, 6:50 PM
Małgorzata
Małgorzata - avatar
2 Antworten
+ 6
Or is a logicall operator. Or operator utilities: set up expressions for example: expression1 or expression2 Or checks if one of the expressions is true Let se some code: int x = 0 int y = 1 if (x =y or x !=y){ print("Left side or Right side of expression is True") } if(x != y or x < y ){ print("Both statments can be true") } if(x != y or x>y){ print("Never Happens"); } For first if. One side of expression is true ( Right side - x!=y) So the code will "enter" in if and prints the text. For second. Both are true. No problem still fits definition so the code is printed. And for last. Both are false. So the code never will executes the part inside third if.
21st Oct 2018, 9:00 PM
Anya
Anya - avatar
21st Oct 2018, 9:04 PM
Mbrustler
Mbrustler - avatar