December 2017
Beginner
412 pages
10h 8m
English
Take a look at the following line of code and guess what value is assigned to x:
| | >>> x = 15 > 5 |
If you said True, you were right: 15 is greater than 5, so the comparison produces True, and since that’s a value like any other, it can be assigned to a variable.
The most common situation in which you would want to do this comes up when translating decision tables into software. For example, suppose you want to calculate someone’s risk of heart disease using the following rules based on age and body mass index (BMI):

One way to implement this would be to use nested ...
Read now
Unlock full access