15 AnswersNew Answer
Koloroj Where is extra True and False? True or False returns on the basis of comparison
Koloroj Those are not comments. Those are values returned after comparing two values.
The True and False that get printed are the values of what's inside print(): x = (2 == 3) print(x) # False print(2 == 3) # False
Lisa Maybe. This is from the Python lesson on Booleans, by the way.
🅰🅹 🅐🅝🅐🅝🅣 and Lisa Well, thanks for helping me confirm.
🅰🅹 🅐🅝🅐🅝🅣 The "False" after "print(2==3)" and the "True" after "print("hello" == "hello")". The code displays the respective words at those lines even without the "True" and the "False".
Lisa So those are just comments? But why don't they have the hashtags, then?
print(x) is the code that is executed in console. False, for example is the value that is printed in console in you console it may look like this >>> False
🅰🅹 🅐🅝🅐🅝🅣 I have a feelong you thought that the "True"s and the "False" are just indicators or the outputs. Just in case you think so, no, that's the entire exact code, the Boolean values included. My problem is why they are there when the "print" commands already display the values "True" and "False" perfectly fine all by themselves.
Writing True anywhere in the script without assigning it or something like that doesn't do much? Maybe they were intended as comments???
Koloroj Are you talking about lesson? Why there those values are given after print statement?
Okay, maybe it was meant as comment or example... https://code.sololearn.com/cRkFl30uiN64/?ref=app
Koloroj That's just for Explanation to understand concepts nothing else.
🅰🅹 🅐🅝🅐🅝🅣 Precisely! I don't know why they're there after the print statements when the print statements already display the values by themselves perfectly fine.
Booleans represent one of two values: True or False. In programming you often need to know if an expression is True or False. You can evaluate any expression in Python, and get one of two answers, True or False. When you compare two values, the expression is evaluated and Python returns the Boolean answer: Example- print(10 > 9) # True print(10 == 9) # False print(10 < 9) # False When you run a condition in an if statement, Python returns True or False: Example Print a message based on whether the condition is True or False: a = 200 b = 33 if b > a: # False : the if statement doesn't run print("b is greater than a") else: print("b is not greater than a") The output of the above code: b is not greater than a I hope you understand it 😊