Skip to main content

Flow charts in Python : How to become a Python Jedi - A Python programming Tutorial Part 2




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
  1. 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.


  1. Devise a flowchart to visualize the steps to login to Gmail.


  1. 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.


Subscribe to my youtube channel to watch new python programming tips and tutorials.

If you have any questions, suggestions or comments you can post your comment here or you can also bug me on Quora, Twitter or on Facebook.








Comments

Popular posts from this blog

What I learned from writing a guest post

                                                     Recently I wrote a python tutorial for Datacamp , while writing this tutorial I learned a couple of things which I am going to share with you right here in my blog post. May be you can use my experiences in your own endeavours as a writer. Idea The first step is idea generation. You can either search through any previous topics in your blog post if you have one or you can go through your past learning, experiences or any problem statement that you might have gone through and you will find that while doing that you can get tons of ideas to start your article. If you fall short of ideas then you can ask for help from may be your social media followings your friends or your family, for example I asked the people at Datacamp  themselves and they suggested me a couple of topics which got me st...

For Loop in python 3 : How to become a Python Jedi - Beginners Python Programming Tutorial - Part 7

I am back again with another part in the beginner python programming tutorial series. We will continue with "Loops" but this time we are going to learn how to use for loop in python 3.  Difference between For loop and While Loop A "For Loop" and "While Loop" have a common connection that both are looping statement, but major difference is that unlike while loop, a for loop gets executed a specified number of times. We can break down the For loop into the following components(Refer to the for loop flow chart below). for keyword variable name call to the range function colon operator clause or block of code Hovering over the flow-chart The above flow-chart is..well horrible I know, but I make my own drawings because I can't afford an artist. So, bear with me. In the above flowchart is a very basicy, laymanish representation of a for loop. The decision box contains the  For  statement along-with it's sou...

Expressions in Python : How to become a Python programming Jedi - A Python programming Tutorial Part 1

Long Long ago in a Galaxy far far away there was a planet named Quora. There was a growing agitation among the planet’s inhabitants to learn the way of the Python programming Force and become a master in the way of the Python programming Jedi, but very few knew that the secret art of the Jedi is embedded in a book named as TheCodingProject…. So, let’s begin the journey of learning the secret art of the Python programming Force and we shall together make the journey towards becoming the Python Jedi…. What is Python? As per Wikipedia “Python is a widely used high-level , general-purpose , interpreted , dynamic programming language .” Python is an open source programming language which was conceived in the late 1980s and its implementation began in December 1989 by Guido van Rossum (more on it here ). For us it’s sufficient to know that Python is : High level language - Python is a high-level programming language because it provides strong “:abstractio...