Sign InNuggetsTutorials CodePadCheatsheet

Getting Loopy

Three Types of Control Flow

In programming, there are 3 important types of control flow structures.

  1. Sequential structure (do something)
  2. Conditional structure (do something under a condition)
  3. Loop structure (do something again and again)

Most programming languages support these kinds of structures. If you can master them, your solutions will become much more powerful.

Loops

In the previous unit, you've learned the conditional branch structure. This unit leads you to explore the wonderful world of loops.

Why Loops?

Let's face it -- repeating the same thing over and over again is BORING! This is when loops come handy because computers excel at helping us with repetitive tasks.

Indeed, loops will save us a lot of typing! :)

print 'Celsius', 'Fahrenheit' for c in range(20, 30, 1): f = c * 9 / 5 + 32 print c, ' ', f
© CS Wonders·Home·About·Contact·Classes·Gallery·Glossary·Fun Facts