Why is it sometimes 'False' or 'True' and others False or True
Why in this section do you sometimes have to write ‘False’ or ‘True’ with quotation marks to Run correctly and others False and True without quotations makrs
2**3 == 108 % 100 or ‘Cleese’ == ‘King Arthur’
bool_one = False
Double check your value for bool_one! Oops, try again.
2**3 == 108 % 100 or ‘Cleese’ == ‘King Arthur’
bool_one = ‘False’
That’s correct! Next Exercise: Not
Answer 50fb12081c9116a6770018b0
Text in quotes are treated as Strings, while “True” or “False” without the quotations are treated as Boolean variables. They are different data types.
Strings are “string of text” that could be “printed” (output) to the screen, while Booleans are just variables used to store “yes” or “no”. For example:
print "True"
will output “True” (without quotes) to the screen, while
print True
will not. And
x = True
if x == True:
print "x is true"
else:
print "x is not true"
will print “x is true” (without quotes) to the screen, while
x = "True"
if x == True:
print "x is true"
else:
print "x is not true"
will print “x is not true” (without quotes) because the data type is different.
The system should not let you pass if you put quotes around “True” and “False”, but Codecademy still have some flaws and sometimes does that.
Comments below if you still do not understand.
Answer 50d6b1498d30304ea90035ba
Popular free courses
- Free course
Learn SQL
In this SQL course, you'll learn how to manage large datasets and analyze real data using the standard data management language.Beginner Friendly4 Lessons - Free course
Learn JavaScript
Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.Beginner Friendly11 Lessons - Free course
Learn HTML
Start at the beginning by learning HTML basics — an important foundation for building and editing web pages.Beginner Friendly6 Lessons