© 2019 BrainStemSchool.com

December 13, 2016

December 9, 2016

December 7, 2016

Please reload

Basic Concepts of Programming

November 7, 2016

You could get by in programming only knowing three concepts: Sequence, Selection, Iteration.

 

You could get buy, but it would be tough. These are the basics of basic - the foundations that you use in every program you'll ever write.

Sequence

Things happen in order.

  1. Put your socks on

  2. put your shoes on

If you flip the order you have: 

  • dirty socks

  • stinky shoes

Likewise commands follow an order - usually top to bottom, line by line.

 

Selection

Making decisions. Computers make decisions based on conditions. If the condition changes, so does the decision.

 

Think of a thermostat - if the room gets cold, the heat goes on. If the room warms up, the heat goes off.

 

Code decisions follow the if THIS then DO THAT format.

 

if isRaining:
    open(umbrella)

Iteration

Loops. Computers are great because they can do the same thing over and over again and never get tired, never complain, never need to be fed or sleep. Computers can count forever without losing their place and they can repeat and repeat and repeat ... the sun rises, the sun sets. Lather, Rinse, Repeat.

 

Sequence

Selection

Iteration

 

If you understand these concepts it's just a matter of putting them into words.

 

Code is putting thoughts into words.

 

Only you have a very limited set of words you're allowed to use.

 

Next Post: Why are there different languages?

Share on Facebook
Share on Twitter
Please reload

Please reload

Recent Posts
Tags