From 7b4e48bd00d8ec5586153369a9909c575c54f889 Mon Sep 17 00:00:00 2001 From: ChristopherWMM Date: Mon, 3 Feb 2025 10:58:38 -0500 Subject: [PATCH] Add = vs == slide --- published/csci_1101/week_03/monday/slides.md | 54 ++++++++++++++++++-- 1 file changed, 49 insertions(+), 5 deletions(-) diff --git a/published/csci_1101/week_03/monday/slides.md b/published/csci_1101/week_03/monday/slides.md index 44ac9e4..f2abf2c 100644 --- a/published/csci_1101/week_03/monday/slides.md +++ b/published/csci_1101/week_03/monday/slides.md @@ -32,7 +32,7 @@ color: bowdoin-title
-#### In Python, they are always capitalized: `True` and `False`. +#### In Python, they are always capitalized as `True` and `False`.
@@ -54,7 +54,11 @@ color: bowdoin
-#### By themselves? Probably not very often.. However, `True` and `False` are used heavily because they are the result of a new type of expression! + + +

By themselves? Probably not very often.. However, `True` and `False` are used heavily because they are the result of a new type of expression!

+ +
@@ -75,13 +79,53 @@ color: bowdoin-title | Human Operator | Python Symbol | Example Expression | | :----------------------: | :-----------: | :----------------: | -| Equal to | `==` | `5 == 5.0` | +| Equal to | `==`| `5 == 5.0` | | Not equal to | `!=` | `True != False` | | Greater than | `>` | `7.0 > 3` | | Less than | `<` | `"A" < "B"` | | Greater than or equal to | `>=` | `4 >= 4` | | Less than or equal to | `<=` | `3.5 <= 5.0` | +--- +layout: side-title +titlewidth: is-2 +align: cm-lm +color: bowdoin-title +--- + +:: title :: + +# = vs == + +:: content :: + +## There are two ways we use the *"equals"* operator. + +
+ +```python +x = 5 +``` + + +### `=` tells the computer to set the value in `x` equal to `5`. +### We call this the ==assignment== operator! + +
+
+
+ +```python +x == 5 +``` + +### `=` asks the computer to check if `x` is equal to `5`. +### We call this the ==equal-to== operator! + +
+ +# It is critical that you do not mix these up! + --- layout: top-title color: bowdoin-title @@ -135,7 +179,7 @@ color: bowdoin-title :: content :: -#### An `if` statement, also called a "conditional" statement, allows us to ask questions about the state of data and *"conditionally"* execute code based the result. +#### An `if` statement, also called a ==conditional== statement, allows us to ask questions about the state of data and *"conditionally"* execute code based the result.
@@ -143,7 +187,7 @@ color: bowdoin-title
-#### Any indented code under the if statement only executes if the expression (also called the condition) evaluates to `True`. If the condition is `False`, the code doesn't run! +#### The indented code under an `if` statement only executes if the expression (called the ==condition==) evaluates to `True`. If the condition is `False`, the code doesn't run! ```python {monaco-run} {autorun:true, editorOptions: { lineNumbers:'on', fontSize:14}}