mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 10:22:16 +00:00
fix(curriculum): correct text errors in lecture-booleans-and-conditionals (#67514)
This commit is contained in:
+1
-1
@@ -73,7 +73,7 @@ if age >= 18:
|
||||
print('You are an adult') # IndentationError: expected an indented block after 'if' statement on line 3
|
||||
```
|
||||
|
||||
Though you can use any number spaces (as long as you are consistent) to determine each level of indentation, the Python style guide recommends using four spaces.
|
||||
Though you can use any number of spaces (as long as you are consistent) to determine each level of indentation, the Python style guide recommends using four spaces.
|
||||
|
||||
Blocks are also found in loops and functions, which you'll learn about in future lessons.
|
||||
|
||||
|
||||
+3
-3
@@ -52,7 +52,7 @@ print(bool(1)) # True
|
||||
print(bool('Hello')) # True
|
||||
```
|
||||
|
||||
Now that you understand truthy and falsy values, we can take a look at Boolean operators, which are also known as logical operators or Boolean operators. These are special operators that allow you to combine multiple expressions to create more complex decision-making logic in your code.
|
||||
Now that you understand truthy and falsy values, we can take a look at Boolean operators, which are also known as logical operators. These are special operators that allow you to combine multiple expressions to create more complex decision-making logic in your code.
|
||||
|
||||
There are three Boolean operators in Python: `and`, `or`, and `not`.
|
||||
|
||||
@@ -94,7 +94,7 @@ is_employed = False
|
||||
print(age or is_employed) # 19
|
||||
```
|
||||
|
||||
The following code will print the number 19 because the first operand `age` is `True`.
|
||||
The following code will print the number 19 because the first operand `age` is truthy.
|
||||
|
||||
If you need to check if one or more expressions is `True`, then you can use the `or` operator in a conditional like this:
|
||||
|
||||
@@ -136,7 +136,7 @@ else:
|
||||
|
||||
Since `is_admin` is `False`, then `not is_admin` is saying not `False` which is `True`. So the message `Access denied for non-administrators.` will be printed.
|
||||
|
||||
Now that you understand truthy and falsy values, the `and`, `or`, and `not` operators, and short-circuiting work, you can write more flexible and readable conditional logic.
|
||||
Now that you understand truthy and falsy values, the `and`, `or`, and `not` operators, and how short-circuiting works, you can write more flexible and readable conditional logic.
|
||||
|
||||
# --questions--
|
||||
|
||||
|
||||
Reference in New Issue
Block a user