Difference between revisions of "KTurtle/C3/Grammar-of-TurtleScript-Part-II/English-timed"
From Script | Spoken-Tutorial
Line 1: | Line 1: | ||
− | |||
{| Border =1 | {| Border =1 | ||
Line 30: | Line 29: | ||
|00.11 | |00.11 | ||
|which will help you understand the installation and interface of the | |which will help you understand the installation and interface of the | ||
− | + | application and some of the basic commands to move the turtle. | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
Line 42: | Line 36: | ||
| 00.18 | | 00.18 | ||
− | | | Also view the tutorial Grammar of Turtle Script-Part I, | + | | |Also view the tutorial Grammar of Turtle Script-Part I, |
Line 49: | Line 43: | ||
| 00.22 | | 00.22 | ||
− | + | ||to understand few more commands that are used in the Kturtle environment. | |
− | + | ||
> | > | ||
Line 65: | Line 58: | ||
| 00.31 | | 00.31 | ||
− | + | ||This tutorial will introduce some more commands to be used in the KTurtle | |
environment. | environment. | ||
Line 149: | Line 142: | ||
| 01.40 | | 01.40 | ||
− | || Now let us learn the commands involved to draw a square using the 'command '''learn ''. | + | ||Now let us learn the commands involved to draw a square using the 'command '''learn ''. |
Line 156: | Line 149: | ||
| 01.46 | | 01.46 | ||
− | || We will name this set of commands to draw a square as '''square'''. | + | ||We will name this set of commands to draw a square as '''square'''. |
Line 195: | Line 188: | ||
| 02.36 | | 02.36 | ||
− | || One important point to be noted here is, | + | ||One important point to be noted here is, |
|- | |- | ||
Line 201: | Line 194: | ||
| 02.39 | | 02.39 | ||
− | || when you run this piece of code, It does not return no output. | + | ||when you run this piece of code, It does not return no output. |
Line 209: | Line 202: | ||
| 02.45 | | 02.45 | ||
− | || The command '''learn '''is just ''''learning' '''the other command | + | ||The command '''learn '''is just ''''learning' '''the other command |
'''square '''to be used later. | '''square '''to be used later. | ||
Line 218: | Line 211: | ||
| 02.51 | | 02.51 | ||
− | || The '''square''' command can now be used like a normal command in the rest of the code. | + | ||The '''square''' command can now be used like a normal command in the rest of the code. |
Line 226: | Line 219: | ||
| 02.57 | | 02.57 | ||
− | || Let me add few more lines of code here. | + | ||Let me add few more lines of code here. |
Line 242: | Line 235: | ||
| 03.09 | | 03.09 | ||
− | || Let me select '''Run '''from the toolbar to run this piece of code from the editor. | + | ||Let me select '''Run '''from the toolbar to run this piece of code from the editor. |
Line 254: | Line 247: | ||
| 03.18 | | 03.18 | ||
− | || The command '''square '''can now be used anywhere and any number of times in the program . | + | ||The command '''square '''can now be used anywhere and any number of times in the program . |
Line 277: | Line 270: | ||
| 03.34 | | 03.34 | ||
− | || '''random '''is a command that takes input and gives output. | + | ||'''random '''is a command that takes input and gives output. |
Line 329: | Line 322: | ||
| 04.29 | | 04.29 | ||
− | || Here, the command '''random 1,20 '''selects a random number which is equal or greater than '''1 '''and equal or lesser than '''20,''' | + | ||Here, the command '''random 1,20 '''selects a random number which is equal or greater than '''1 '''and equal or lesser than '''20,''' |
Line 344: | Line 337: | ||
| 04.44 | | 04.44 | ||
− | || When you run this piece of code, a circle with a radius of size, which is in between '''1 '''and '''20 '''is drawn on the canvas. | + | ||When you run this piece of code, a circle with a radius of size, which is in between '''1 '''and '''20 '''is drawn on the canvas. |
Line 359: | Line 352: | ||
| 05.06 | | 05.06 | ||
− | || Every time you execute this code, a circle with a different radius is drawn. | + | ||Every time you execute this code, a circle with a different radius is drawn. |
Line 366: | Line 359: | ||
|05.13 | |05.13 | ||
− | | Let us now use both the '''learn '''and '''random '''commands in an | + | |Let us now use both the '''learn '''and '''random '''commands in an |
example. | example. | ||
Line 374: | Line 367: | ||
| 05.24 | | 05.24 | ||
− | || Here, i have with me few line of code that demonstrates the use of both the '''learn '''and the '''random '''command. | + | ||Here, i have with me few line of code that demonstrates the use of both the '''learn '''and the '''random '''command. |
Line 381: | Line 374: | ||
| 05.31 | | 05.31 | ||
− | || i am going to copy the entire code on to my clipboard and paste it in my editor in the Kturtle application. | + | ||i am going to copy the entire code on to my clipboard and paste it in my editor in the Kturtle application. |
Line 388: | Line 381: | ||
| 05.46 | | 05.46 | ||
− | + | | Let us see what each line means here. | |
Line 396: | Line 389: | ||
| 05.50 | | 05.50 | ||
− | || | + | ||canvassize 300,300' sets the width and height of the canvas to 300 |
pixels each. | pixels each. | ||
Line 405: | Line 398: | ||
| 05.58 | | 05.58 | ||
− | || '''$R''', '''$G''', and '''$B '''are three variables to which I am | + | ||'''$R''', '''$G''', and '''$B '''are three variables to which I am |
assigning random values between 0 and 255. | assigning random values between 0 and 255. | ||
Line 421: | Line 414: | ||
| 06.11 | | 06.11 | ||
− | || the '''Red-Green-Blue '''combination is replaced by the values assigned to the variables '''R, G, and B '''in the previous step. | + | ||the '''Red-Green-Blue '''combination is replaced by the values assigned to the variables '''R, G, and B '''in the previous step. |
Line 428: | Line 421: | ||
| 06.20 | | 06.20 | ||
− | || The canvas color is now set randomly when this command is executed. | + | ||The canvas color is now set randomly when this command is executed. |
Line 436: | Line 429: | ||
| 06.27 | | 06.27 | ||
− | || '''$red, $blue, $green '''are another set of variables | + | ||'''$red, $blue, $green '''are another set of variables |
Line 443: | Line 436: | ||
|06.33 | |06.33 | ||
− | || to which values between 0 and 255 are assigned randomly. | + | ||to which values between 0 and 255 are assigned randomly. |
Line 451: | Line 444: | ||
| 06.38 | | 06.38 | ||
− | || Again in the command ''''pencolor $red,$blue,$green'''' the | + | ||Again in the command ''''pencolor $red,$blue,$green'''' the |
'''Red-Green-Blue '''combination values are replaced by the variables | '''Red-Green-Blue '''combination values are replaced by the variables | ||
Line 460: | Line 453: | ||
| 06.48 | | 06.48 | ||
− | || '''$red, $green '''and '''$blue '''to which random values are assigned in the previous step. | + | ||'''$red, $green '''and '''$blue '''to which random values are assigned in the previous step. |
Line 468: | Line 461: | ||
| 06.53 | | 06.53 | ||
− | || The color of the pen is also set randomly when the command is executed. | + | ||The color of the pen is also set randomly when the command is executed. |
Line 476: | Line 469: | ||
| 06.57 | | 06.57 | ||
− | || 'penwidth 2' sets the width of the pen to 2 pixels. | + | ||'penwidth 2' sets the width of the pen to 2 pixels. |
Line 483: | Line 476: | ||
| 07.02 | | 07.02 | ||
− | || I have next entered the code to '''learn''' to draw a circle. | + | ||I have next entered the code to '''learn''' to draw a circle. |
Line 503: | Line 496: | ||
| 07.16 | | 07.16 | ||
− | || followed by the '''circle '''commands draws circles with the specified sizes. | + | ||followed by the '''circle '''commands draws circles with the specified sizes. |
Line 511: | Line 504: | ||
|07.23 | |07.23 | ||
− | || For example the command '''circle 5 '''draws a circle of size 5 | + | ||For example the command '''circle 5 '''draws a circle of size 5 |
Line 519: | Line 512: | ||
| 07.28 | | 07.28 | ||
− | || If the co-ordinates X and Y specified in the '''go '''commands. | + | ||If the co-ordinates X and Y specified in the '''go '''commands. |
Revision as of 12:18, 10 January 2013
Visual Cue | Narration
|
00.01 | Hi everyone,
|
00.02 | Welcome to the tutorial on Grammar of Turtle Script-Part II. |
00.06 | If this is the first time you are using KTurtle, please view the
tutorial introduction to KTurtle
|
00.11 | which will help you understand the installation and interface of the
application and some of the basic commands to move the turtle.
|
00.18 | Also view the tutorial Grammar of Turtle Script-Part I,
|
00.22 | to understand few more commands that are used in the Kturtle environment.
> |
00.26 | These tutorials can be viewed on the spoken tutorial website |
00.31 | This tutorial will introduce some more commands to be used in the KTurtle
environment.
|
00.36 | We will learn the
|
00.37 | learn command
|
00.39 | And the random command
|
00.40 | For this demonstration, I am using the Linux Operating System Ubuntu
v11.04, and Kturtle v0.8.1 beta.
|
00.51 | Let us first look at the learn command.
|
00.54 | learn is special as it is used to create your own commands. |
00.58 | The commands you create can take input and return output.
|
01.02 | Let us take a look at how a new command is created. |
01.06 | I will launch the Kturtle application
|
01.11 | And Let us enter the following lines of code in the editor to draw a
square:
|
01.33 | here the number 10 specfies the length of the side of the square.
|
01.40 | Now let us learn the commands involved to draw a square using the 'command 'learn .
|
01.46 | We will name this set of commands to draw a square as square.
|
01.53 | The command learn is followed by the name of the command to be learnt,
|
01.58 | in this case it is square.
|
02.01 | So i will enter the command learn before square
|
02.24 | so here the new command that we have defined is called square. |
02.30 | square takes one input argument, i.e $x to set the size of the square.
|
02.36 | One important point to be noted here is, |
02.39 | when you run this piece of code, It does not return no output.
|
02.45 | The command learn is just 'learning' the other command
square to be used later.
|
02.51 | The square command can now be used like a normal command in the rest of the code.
|
02.57 | Let me add few more lines of code here.
|
Type the following code in your editor:
| |
03.09 | Let me select Run from the toolbar to run this piece of code from the editor.
|
03.15 | The turtle now draws the square on the canvas.
|
03.18 | The command square can now be used anywhere and any number of times in the program .
|
03.27 | Also Note that this command can be used only within the scope of this program.
|
03.30 | Let us next look at the 'random' Command.'
|
03.34 | random is a command that takes input and gives output.
|
03.38 | The syntax for this command is random X,Y
|
03.42 | where X and Y are two inputs. |
03.44 | X sets the minimum output and Y sets the maximum.
|
03.49 | The output is a randomly chosen number between X and Y.
|
03.54 | Let us put the random command to use in the application.
|
03.59 | In my editor, I will enter a few lines of code to draw a circle.
|
04.29 | Here, the command random 1,20 selects a random number which is equal or greater than 1 and equal or lesser than 20,
|
04.41 | and assigns it to the variable x.
|
04.44 | When you run this piece of code, a circle with a radius of size, which is in between 1 and 20 is drawn on the canvas.
|
04.53 | Let us execute this code a few times, and you can see that a circle with a different size is generated each time.
|
05.06 | Every time you execute this code, a circle with a different radius is drawn.
|
05.13 | Let us now use both the learn and random commands in an
example.
|
05.24 | Here, i have with me few line of code that demonstrates the use of both the learn and the random command.
|
05.31 | i am going to copy the entire code on to my clipboard and paste it in my editor in the Kturtle application.
|
05.46 | Let us see what each line means here.
|
05.50 | canvassize 300,300' sets the width and height of the canvas to 300
pixels each.
|
05.58 | $R, $G, and $B are three variables to which I am
assigning random values between 0 and 255.
|
06.07 | In the command 'canvascolor $R,$G,$B' ,
|
06.11 | the Red-Green-Blue combination is replaced by the values assigned to the variables R, G, and B in the previous step.
|
06.20 | The canvas color is now set randomly when this command is executed.
|
06.27 | $red, $blue, $green are another set of variables
|
06.33 | to which values between 0 and 255 are assigned randomly.
|
06.38 | Again in the command 'pencolor $red,$blue,$green' the
Red-Green-Blue combination values are replaced by the variables
|
06.48 | $red, $green and $blue to which random values are assigned in the previous step.
|
06.53 | The color of the pen is also set randomly when the command is executed.
|
06.57 | 'penwidth 2' sets the width of the pen to 2 pixels.
|
07.02 | I have next entered the code to learn to draw a circle.
|
07.08 | Here $x represents the size of the circle.
|
07.12 | The next set of commands i.e the go commands |
07.16 | followed by the circle commands draws circles with the specified sizes.
|
07.23 | For example the command circle 5 draws a circle of size 5
|
07.28 | If the co-ordinates X and Y specified in the go commands.
|
07.33 | For each circle, I have specified different positions on the canvas.
|
07.39 | Let us execute this code now.
|
07.42 | I am going to run this execution at full speed.
|
07.46 | But you can select any of the speeds mentioned in the Run option.
|
07.52 | I will run this code few more times, so that you can see the difference in the randomly set values of pen color and canvas color.
|
08.06 | When I execute the code one more time, note the change in the color in the pen and the canvas.
|
08.19 | You can exceute this code how many ever times you want and you can note the change in the randomly set values.
|
08.31 | As an assignment for you to solve,
|
08.33 | using the learn command,
|
08.35 | draw a pentagon, a square, a rectangle, a hexagon on the four corners of your canvas
|
08.43 | and a circle at the centre of the canvas.
|
08.47 | Using the random command create various colors and customize the shapes and also the canvas.
|
08.55 | I have created my own customized canvas for the geometric shapes,
|
09.00 | and your assignment should look some thinglike this.
|
09.03 | Let me run the piece of code in the application.
|
09.09 | You can see the geometric shapes and the color of the canvas changing each time.
|
09.17 | I would like to acknowledge the spoken tutorial project |
09.20 | which is part of the talk to a teacher project.
|
09.23 | Supported by the National Mission on Education through ICT, MHRD
Government of India.
|
09.28 | For more information please visit the link shown on the screen.
|
09.33 | The video on the link shown summaries the spoken tutorial project.
|
09.37 | If you do not have good bandwidth, you can download and watch it. |
09.41 | We also give certificate for those who pass an online test. please
contact us contact@spoken-tutorial.org for more details . |
09.48 | Thank You.This is Sindhu signing off. Enjoy playing with KTurtle!
|