I don't understand the last question | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 1

I don't understand the last question

If not 1+1=y or x=4 and 7›8

31st Oct 2016, 8:05 PM
Sara Wael
Sara Wael - avatar
4 Réponses
+ 1
Thanx for your answer @Fianu Dovlo But you say that "False and True = True " it equal false not True ...
2nd Nov 2016, 12:41 AM
Sara Wael
Sara Wael - avatar
+ 1
The first part asks, If not 1+1=y, means 1+1 doesn't equal y, which is False because y is 2. So 1+1 is 2. Then the second part asks if x==4, this is True because x is 4. Since it is an "or" statement between the two equations( not 1+1=y or x==4), only one has to be True in an or statement, thus gets a True. True or True = True True or False = True False or True = True False or False = False The final equation asks if 7==8(or 7>8), which it isn't so it's False. Since the first set of equations eventually come out as True but the last one comes out as False, the entire line is False. You learn earlier that for a statement with "and", the entire equation has to be True. The final equation( 7>8 whichever showed up for you 7==8 ) makes the whole thing False. True and True = True True and False = False False and True = False *corrected False and False = False That makes the first print command invalid so it goes to the elif, which asks whether x > y, which it True, so "No" is printed.
7th Nov 2016, 3:17 AM
Fianu Dovlo
Fianu Dovlo - avatar
+ 1
Yes. Sorry, you're right. Was typing fast and made a lot of edits so ended up being a little sloppy.
7th Nov 2016, 3:18 AM
Fianu Dovlo
Fianu Dovlo - avatar
+ 1
Thanx for your reply 😊😊
22nd Nov 2016, 2:34 AM
Sara Wael
Sara Wael - avatar