Unit 3: Conditional Execution. if-else and while loops

 

Conditional Execution

Until now, all of the programs that we have worked with followed the same set of instructions every time. While this can be useful from time to time, we are quite limited if our programs can not make decisions. In this unit, we explore some ways to get our code to “make decisions”. We start with if and if-else statements, discuss the elif keyword, examine nested conditionals and finally learn to control iteration with the while loop.

 

Lesson 14A: Basic control Structure, if and else.


Lesson 14B: Nested Conditionals

Flowcharts: Managing complexity

Flowcharts provide us with a great tool for dealing with the complexity that arises when we try to tackle large programming projects. The next few videos cover the anatomy of flow charts. When viewing these videos, bear in mind that an experienced programmer would probably not need to flow chart these programs. In fact, even a complete beginner would probably find the task to feel futile. We are using these simple programs to introduce flow charts so that later on, when you really need them, you will be familiar with how they work. In the future, you will use flowcharts to plan large, complicated problems or to communicate effectively as a member of a team.

 

Lesson 15A: The if flowchart structure.

Lesson 15B: The if-else flowchart structure.


Lesson 15C: The if-else-elif flowchart structure.


if statement assignment

 While loop assignment: Sorting lists.

whileLoopSortExercise