From 243cf176ebb41727a1e40179cba531ddd90905dd Mon Sep 17 00:00:00 2001 From: Andy <159312225+Mw4mba@users.noreply.github.com> Date: Mon, 12 Aug 2024 16:11:24 +0200 Subject: [PATCH] Update week3-theory.html Signed-off-by: Andy <159312225+Mw4mba@users.noreply.github.com> --- python/week3-theory.html | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/python/week3-theory.html b/python/week3-theory.html index 0023494..74685e6 100644 --- a/python/week3-theory.html +++ b/python/week3-theory.html @@ -160,7 +160,7 @@
Control structured are ways to control the direction of a program based of a given condition. A useful analogy to keep in mind is the way that conditions may make you choose one route over another when driving, be it the amount of traffic or the overall distance of the path. Now there is significantly less variability in the nature of the conditions used in programming, however we can highlight a few of the condition types:
Conditional: This includes if and switch statements, this primarily checks if a described condition has been met and executes a block of code based of that.
@@ -172,13 +172,13 @@ What is an if statement?
An if statement is a conditional structure that checks if a given condition is true and executes the applicable block of code if true.
When do we use an if statement
We use if statements if some form of verification is required, and if dynamic execution is required in the program.
What is the scope of variables in an if statemen
You are capable of using if statements almost everywhere in you program, you are even capable of using an if statement in the executable for your if statement.
When do we use an if statement?
We use if statements if some form of verification is required, and if dynamic execution is required in the program.
What is the scope of variables in an if statement?
You are capable of using if statements almost everywhere in you program, you are even capable of using an if statement in the executable for your if statement.
It follows the general syntax:
- if *condition*:
- *block of code*
+ if condition:
+ block of code
Here indentation is important to denote that the block of code is in the scope of the if statement. Here is a more complete example:
@@ -248,31 +248,32 @@This code uses a match-case statement to match a number to a month with its corresponding numerical position. In this code block the default case is sed for error handling to manage invalid inputs.