From the course: Introduction to Python: Learn How to Program Today with Python by Pearson
Unlock this course with a free trial
Join today to access over 25,400 courses taught by industry experts.
Identify true and false statements - Python Tutorial
From the course: Introduction to Python: Learn How to Program Today with Python by Pearson
Identify true and false statements
Okay, so before we get to conditionals with if and else, I first want to talk a bit more about comparisons and things returning true or false, you know, those Booleans. So let's see how Python does that. We can go into the Python console and compare some things. So say we had, actually, let's try to compare time and money. t equals time and m equals money here. We can check if they are the same thing or if they have the same value by using two equals sign, double equals. That might be unintuitive for you, but just remember that if we used a single equals sign, that is how we do variable assignment. So this is not going to give you what you want if you're trying to check if they're equal. So they are not equal. But then if we use an exclamation mark equal, that's actually checking, are they not equal? And that is true. Is time less than money? That's false. Is it greater than? That's true. So the way Python compares strings based on alphabetical order or like the number code for the…