We all know that programming is a set of instructions, but many a times we forget to think that this set of instructions should make sense to be called a computer program. You can get your dog to fetch a stick just by yelling “FETCH” but if type an instruction like “calculate” it will do nothing other than just sitting there and gaping at your face with that ugly python command prompt look.
To command a machine to do a task we need to pass a set of “precise and clear set of instructions that flows seamlessly from one step to another”. This flow of instruction is known as flow control or instruction flow control in the programming world. One handy tool to do this is a flowchart.
What the hell is a flowchart?
Well simply put a flowchart is a graphical representation of instructions/logic sets that helps you to visualize the logic that you have formulated for a task.
Let’s get into an example….
Let’s say that you want to automate the login to your facebook account and want to code the entire process in python, but before you get cosy with your keyboard you need to think and devise a series of steps as below-
- Type the facebook url
- Search for the user id & password text box
- Enter your credentials
- Press the Enter button
It’s time to visualize the steps via a flowchart like the one below -
The above flowchart is a visual representation of the steps that you want your code to follow. The boxes represent the different units/steps of the logic that was devised earlier and the arrows represents the “flow” of the program control between different steps of the logic. In actual practice your program should flow through the steps in the same manner as is represented in the above flowchart.
Endnotes
Devising steps/algorithm for a computer program is not as straightforward as is represented in the above example but I to get a taste of what a flowchart is and how to design a basic flowchart the above example will suffice.
Below are some practice exercises that will help you get going till the next tutorial which will be coming your way soon.
Quiz
- You want to prepare a large jug of lemonade. Write down the steps by step procedure for the same and devise a flowchart that represents the steps.
- Devise a flowchart to visualize the steps to login to Gmail.
- Create a flowchart to represent a up of coffee. Also include the necessary steps to check if the gas stove is on or not and whether water has boiled already etc.
So, folks this was all for this week but we shall return with another part of this tutorial with some new concepts to learn.
Comments
Post a Comment