From the course: Building Recommender Systems with Machine Learning and AI

Unlock this course with a free trial

Join today to access over 23,200 courses taught by industry experts.

Booleans, loops, and a hands-on challenge

Booleans, loops, and a hands-on challenge

- [Instructor] Okay, the other stuff is pretty straightforward. Here's what the syntax looks like for boolean expressions. You can use a double equal sign to test for equality. And you can also just use the word is. There's also a triple equal sign that you can use to compare actual objects together instead of their values but that's seen less commonly. True and false are a little weird in that they are capitalized in Python but only the first letter like so. And for operators like and, or, and not, you just use the words and, or, and not instead of special symbols. You can do something like a case or switch statement by using boolean expressions with an if, elif, else structure like this. In this example, we print "How did that happen" if one is three which always false, otherwise we move on to test whether one is greater than three, which should also be met with disbelief if it were true, when that test fails we fall back to our final else clause which prints "All is well with the…

Contents