Your Brain on Move To Intermediate Programming Level : Any Kid Can Code
By: Laxman Singh
Tags: Kids, Python Programming, Kids And Tech, Kids Programming

Your Brain on Move To Intermediate Programming Level : Any Kid Can Code Laxman Singh Follow Nov 1 · 4 min read

I hope my last topic (link is below) would have helped a bit and you would have tried to make 5–10 different figures. And, you will be feeling confident and I am also looking forward to challenging you with new things to add to your programming experience. I will be covering the following items and their usage: variables, conditions, loop.

I hope and assume you have created a different figure and would be facing some problems. Solving problems must be having good time and output in the end making different figures is always achieving something. Let's go ahead with Variable:

What is Variable?

As a name change, anything that can change or has the capability of changing is called variable. In programming terms, program needs to store value and variable helps to achieve that. If you remember maths problem, where we used to write “Let us assume ABC’s age is x years”. This “x” is variable. Similarly, in programming we say x =10 and now if we will print x or use x anywhere it will be treated as 10 or replaced by 10.

I hope I am not sounding difficult. Examples will help you :

x = 10

y = 20

print(x+y)

Here we go, we magically got the value printed as sum of 10+20. And, similarly, it gives multiplication too.

Manipulation with variables

Conditions

Conditions are easy to understand as it is almost similar to english language connector “IF”. Just we have to learn syntax a bit as our friend python language is very much particular about spaces. In other words, condition is something like which test some condition and on the success of that test takes actions. e.g, If it will not rain today, we can go to playground else study. Her test of rain happening is condition and going to playground is action to be taken if it will not rain. If it rains, actions is ?

Below is the syntax:

if (<<condition>>): (colon)

<<whatever you type here will run if condition is successful>>

Example of IF condition syntax with else

Initially you might face issue as after colon, once you press enter you have to give space (4 spaces is best practice to indent). So, anything with 4 spaces inside if will execute if the condition is true. Don’t think too much just follow and try to use it with various options.

Loop

Loop is very important in programming as condition and variable. Loop helps to make your program short and less repetitive (redundant code can be written once and run in loop).

What is Loop? Loop can be termed as a set of commands running together till the condition given in the loop is true. Let us have an real life example: if your mother has said that you are allowed to play till 7pm, then you can play all the games any number of times till the clock says 7 pm. Nice and disheartening example. Let us move to the Syntax: (I am constraining myself to one loop only i.e, while loop. If you understood, i will introduce “for” loop at the time of implementing some task)

Syntax:

while <<condition>>:

<<commands to execute>>

<<counter so that condition will be successful after n number of runs>>

Example of Loop which runs for 5 times

Now, its your turn to play with all these terms. Play with condition, variable and loop. And, try to go to the extent where you might ask question to yourself for multiple if condition and multiple loops.

For practice, try to convert your square and figures developed earlier inside loop and see if you are able to reduce it to minimum. e.g,

x = 0

while x < 4:

jumper.forward(100)

jumper.left(90)

x = x + 1

Few more commands to add which will help to play with turtle:

reset — It will clean the screen

speed — You have to pass 0–10 any number where 0 is the fastest.

Our aim is to reach to develop at least 2–3 games in the coming 2 months. Let us be on target. And, in the mean time, I will work on next items for you: functions and write a program in file to execute. I remember pain to you for typing, once you have flexibility to save programs in file and run, you will save time and will be able to learn much more faster. Relax, practice and I will be back soon!