April 2024
Beginner to intermediate
500 pages
24h 20m
English
Now we know the chatbot can handle each question as a string. We also know that we want the chatbot’s answer to depend on the first word in the sentence. So, the chatbot needs some way to determine which word starts the question the user is asking. To do that, we can use Boolean expressions and a selection statement.
A Boolean expression compares values of objects. The result is one of the two Boolean data values: True or False. These Boolean values are another primitive type in Python.
The easiest type of Boolean expression compares the results of two expressions. To make this comparison, we use operators you might recognize from mathematics: equality operators to compare if two values are equal, ...
Read now
Unlock full access