Innings2
Powered by Innings 2

Glossary

Select one of the keywords on the left…

Learn Python > So what is programming?

So what is programming?

The computer is a very powerful multi purpose machine which can be used to do a lot of things. But it cannot do the things on its own. It needs to be told what to do.

And we use programming languages to tell it what to do.

So basically a program is a sequence of instructions which tells a computer what to do. And just like we only understand when someone tells us in a language we know, computers do the actions only when they are told in a language they know.

Let us now look at programming through a simple example.

Let’s say I give you 5 cards. Each card has one number on it. Let’s say the numbers are 5,1,3,8,4. Find the largest number in the 5 cards.

What is it?

We all know it’s .

But how did you find it? In your mind you very quickly did some calculations. You compared the numbers and came up with a solution.

Now let’s make this interesting. Get a friend. They will only do the actions that you tell them to do. The job for you is this. Can you tell them step by step what actions they should do to find the largest number in the cards?

They will not think on their own. A stack of cards are in front of them. After they finish following your steps, they should be left with only the largest card in their hand. Obviously you cannot say like, go through cards and find largest card.

Take your time. Think. I will tell what I would tell below, but you have to think first.

Did you get it?

I would tell the following. You can be my friend and follow along. Select yes after you do each step.

1.Pick the first card.

2.Pick the next card.

3.If the new card is bigger then keep that in your hand and drop the older card. Basically keep the card with the larger number and drop the card with the smaller number.

4.Do steps 2 and 3 until you run out of cards.

5.The card in your hand is the largest card.

Find the Maximum Number

Follow these steps to find the largest number in the cards. Click on the start button at the end to get started:

Click 'Start' to begin the exercise
VS
Discard Pile

You have just written your first program. In fact, this sequence of steps is called an algorithm.

But since computers can’t understand English, we have to rewrite the above program in a language they understand, like Python. And this is what you will be learning.