0

Why is line 8 true

print(1 == 1 or 2 == 2) print(1 == 1 or 2 == 3) print(1 != 1 or 2 == 2) print(2 < 1 or 3 > 6) print(3 < 3 or 6 != 7)

2nd Dec 2018, 9:00 PM
Jordan Autrey
Jordan Autrey - avatar
5 Réponses
+ 4
Jordan Autrey I believe you want to know how to make it so false is printed if one of the expressions is false. If so, replace the "or" operator with the "and" operator. See differences below: print(false or true) # outputs true print(false and true) # outputs false With "or", only one of the expressions has to be true to return true. With "and", both expressions must be true to return true.
2nd Dec 2018, 10:15 PM
David Carroll
David Carroll - avatar
+ 1
The sign != is "not equal"
2nd Dec 2018, 9:09 PM
Gordon
Gordon - avatar
0
Correct? So it must match how line 5 is coded? So I can't ask a question like line8?
2nd Dec 2018, 9:18 PM
Jordan Autrey
Jordan Autrey - avatar
0
Thanks Jamie so what would I have to use inorder to run line 8 with out any errors could you create an example for me please. I'm like only one week into Python with udemy and still don't fully understand when and why you can't do and do certain things yet like this
2nd Dec 2018, 9:56 PM
Jordan Autrey
Jordan Autrey - avatar
0
Line 8 : print( 3 < 3 or 6 !=7) is true because,in plain english, 6 is not equal to 7 and that's true.
3rd Dec 2018, 2:02 AM
Rawy Murgany
Rawy Murgany - avatar