You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lessons/03_conditional_statements.qmd
+6-6Lines changed: 6 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -145,7 +145,7 @@ if my_name == 'Anja':
145
145
146
146
### Indentation Matters
147
147
148
-
You may have noticed that the code block is indented. This is not just for the readability, it is actually required in Python. The indentation tells Python which lines of code belong to the `if` statement. If you forget to indent, you will get an error or the code will not execute as expected.
148
+
You may have noticed that the code block is indented. This is not just for the readability; it is actually required in Python. The indentation tells Python which lines of code belong to the `if` statement. If you forget to indent, you will get an error or the code will not execute as expected.
149
149
150
150
```{python}
151
151
#| label: if_statement_indentation_error
@@ -232,7 +232,7 @@ We can join together the functionality of multiple `if` statements using `elif`
232
232
233
233
### `else` Statements
234
234
235
-
Sometimes you may want to have a "catch-all" block of code that executes when the `if` statement is not met. This is where `else` comes in! We can build upon the "Alice" example from above and add an `else` statement to handle the case where `name != "Alice"`:
235
+
Sometimes you may want to have a "catch-all" block of code that executes when the `if` statement is not met. This is where `else` comes in! We can build upon the "Anja" example from above and add an `else` statement to handle the case where `name != "Anja"`:
236
236
237
237
```{python}
238
238
#| label: if_else_example
@@ -287,12 +287,12 @@ if my_name == 'Anja':
287
287
# Otherwise
288
288
else:
289
289
# Print this message
290
-
print("You aren't Alice or Bob!")
290
+
print("You aren't Anja or Noor!")
291
291
# Otherwise, check if my_name matches 'Noor'
292
292
# Note that this syntax of putting elif after the else is going to return an error on line 14
293
293
elif name == "Noor":
294
294
# If true, print this message
295
-
print("Hello, Bob!")
295
+
print("Hello, Noor!")
296
296
```
297
297
298
298
:::
@@ -354,7 +354,7 @@ The `not` operator allows us to check if a condition is `False` and returns a `T
354
354
not x > 10
355
355
```
356
356
357
-
This is sometimes more intuitive to read than writing `x <= 10:`.
357
+
This is sometimes more intuitive to read than writing `x <= 10`.
358
358
359
359
### Combining Logical Operators
360
360
@@ -390,4 +390,4 @@ While the second example will return `False`:
0 commit comments