Skip to content

Commit

Permalink
Update week1A
Browse files Browse the repository at this point in the history
  • Loading branch information
jdtournier committed Dec 15, 2024
1 parent 5d3e5a0 commit 137ccf5
Showing 1 changed file with 239 additions and 0 deletions.
239 changes: 239 additions & 0 deletions week1A.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,34 @@ class: title

---

# Teaching team

## Teaching assistants

.center[.teamcols[
.col[
[Charel Junior Mangama Sindzi](mailto:[email protected]) ]
.col[
![:scale 100%](images/charel.jpg)]
.col[
![:scale 100%](images/yovin.jpg)]
.col[
[Yovin Yahathugoda](mailto:[email protected]) ]
] ]

.center[.teamcols[
.col[
[Jakub Grzelak](mailto:[email protected]) ]
.col[
![:scale 100%](images/jakub.jpg) ]
.col[
![:scale 100%](images/nashira.jpg) ]
.col[
[Paloma Nashira Rodriguez Baena](mailto:[email protected]) ]
] ]

---

# Course overview

## Structure
Expand Down Expand Up @@ -1315,6 +1343,31 @@ arguments to verify that everything works as expected.
---
# Other forms of iteration: `while` & `do ... while`
The `for` loop is by far the most commonly-used looping structure, but others exist and are sometimes more appropriate
--
The `while` loop takes this form:
```
while (condition)
statement;
```
This will keep running `statement` as long as `condition` is true
--
The `do ... while` loop takes this form:
```
do
statement;
while (condition);
```
This will also run `statement` as long as `condition` is true. The difference with the regular `while` loop is that `condition` is tested *after* running `statement`
---
# The dot operator
In the previous example, you will have noticed the use of syntax of this form:
Expand Down Expand Up @@ -2321,6 +2374,192 @@ Modify your own code to add these checks, then compile and test it

---

# Other forms of conditional execution

The `if` statement is by far the most common structure for conditional execution, but other forms exist.

The `switch` statement allows you to execute different section of code depending on the *value* of a variable. It takes this general form:
```
switch (variable) {
case value1:
statement;
...
statement;
break;
case value2:
statement;
break;
...
default:
statement;
}
```


---

# Other forms of conditional execution

The `if` statement is by far the most common structure for conditional execution, but other forms exist.

The `switch` statement allows you to execute different section of code depending on the *value* of a variable. It takes this general form:
```
`switch` (variable) {
case value1:
statement;
...
statement;
break;
case value2:
statement;
break;
...
default:
statement;
}
```
.explain-bottom[
the `switch` keyword denotes the start of our conditional section of code
]


---

# Other forms of conditional execution

The `if` statement is by far the most common structure for conditional execution, but other forms exist.

The `switch` statement allows you to execute different section of code depending on the *value* of a variable. It takes this general form:
```
switch (`variable`) {
case value1:
statement;
...
statement;
break;
case value2:
statement;
break;
...
default:
statement;
}
```
.explain-bottom[
`variable` is the variable whose value will determine the code to run
]


---

# Other forms of conditional execution

The `if` statement is by far the most common structure for conditional execution, but other forms exist.

The `switch` statement allows you to execute different section of code depending on the *value* of a variable. It takes this general form:
```
switch (variable) {
* case value1:
statement;
...
statement;
break;
case value2:
statement;
break;
...
default:
statement;
}
```
.explain-bottom[
for each value of `variable` that we want to handle (e.g `value1`), we use the `case` keyword to label the matching section of code, using this syntax
]


---

# Other forms of conditional execution

The `if` statement is by far the most common structure for conditional execution, but other forms exist.

The `switch` statement allows you to execute different section of code depending on the *value* of a variable. It takes this general form:
```
switch (variable) {
case value1:
* statement;
* ...
* statement;
break;
case value2:
statement;
break;
...
default:
statement;
}
```
.explain-bottom[
immediately after the `case` label, we insert the code to be run. This can consist of multiple lines – no need for braces here.
]


---

# Other forms of conditional execution

The `if` statement is by far the most common structure for conditional execution, but other forms exist.

The `switch` statement allows you to execute different section of code depending on the *value* of a variable. It takes this general form:
```
switch (variable) {
case value1:
statement;
...
statement;
* break;
case value2:
statement;
break;
...
default:
statement;
}
```
.explain-bottom[
... but we do need to close off the last statement of the code for that case with the `break` keyword!

More on the `break` statement shortly...
]

---

# Other forms of conditional execution

The `if` statement is by far the most common structure for conditional execution, but other forms exist.

The `switch` statement allows you to execute different section of code depending on the *value* of a variable. It takes this general form:
```
switch (variable) {
case value1:
statement;
...
statement;
break;
case value2:
statement;
break;
...
* default:
statement;
}
```
.explain-middle[
We can also have a catch-all `default` label at the end, which will be executed in case none of the other labels matched
]

---

# Exercises

To be added...
Expand Down

0 comments on commit 137ccf5

Please sign in to comment.