Difference between revisions of "KTurtle/C2/Grammar-of-TurtleScript-Part-I/English-timed"

From Script | Spoken-Tutorial
Jump to: navigation, search
Line 1: Line 1:
 
  
  
Line 26: Line 25:
 
  “Introduction to KTurtle” tutorial on the spoken tutorial website.
 
  “Introduction to KTurtle” tutorial on the spoken tutorial website.
  
|-
+
|-
  
|00.12
+
|00.12
  
| To get started with KTurtle, I am using the Linux operating system ubuntu
+
|To get started with KTurtle, I am using the Linux operating system ubuntu Version 11.04 and KTurtle version 0.8.1 beta.
Version 11.04 and KTurtle version 0.8.1 beta.
+
  
  
|-
+
|-
 
+
| 00.21
| 00.21
+
|This tutorial will help you understand further, the '''Grammar of
 
+
|This tutorial will help you understand further, the '''Grammar of
+
 
  TurtleScript'''.
 
  TurtleScript'''.
  
Line 46: Line 42:
 
  | 00.26
 
  | 00.26
  
  | If you have already installed KTurtle,
+
  |If you have already installed KTurtle,
  
  
|-
+
|-
  
 
| 00.28
 
| 00.28
  
|go to the Ubuntu Menu Item '''Applications >''' '''Education''' and click
+
|go to the Ubuntu Menu Item '''Applications >''' '''Education''' and click on the '''KTurtle''' Application.
on the '''KTurtle''' Application.
+
  
  
|-
+
|-
  
 
| 00.34
 
| 00.34
  
  |Another way to open KTurtle is by going to '''Applications > Accessories
+
  |Another way to open KTurtle is by going to '''Applications > Accessories menu and click on Terminal'''
menu and click on Terminal'''
+
  
  
Line 69: Line 63:
 
  | 00.39
 
  | 00.39
  
  | At the prompt type the name of the application that is “'''kturtle'''” and
+
  |At the prompt type the name of the application that is “'''kturtle'''” and hit 'Enter'.
hit 'Enter'.
+
  
  
Line 84: Line 77:
 
  |00.51
 
  |00.51
  
  | In this tutorial, we will learn, the grammar of turtle script which
+
  |In this tutorial, we will learn, the grammar of turtle script which
 
  includes,
 
  includes,
  
Line 92: Line 85:
 
| 00.55
 
| 00.55
  
| commands and comments
+
|commands and comments
  
  
Line 99: Line 92:
 
| 00.56
 
| 00.56
  
  | numbers, variables and strings
+
  |numbers, variables and strings
  
  
Line 125: Line 118:
 
  | 01.05
 
  | 01.05
  
| The '''TurtleScript '''is a programming language and has different types
+
| The '''TurtleScript '''is a programming language and has different types of words and symbols.
of words and symbols.
+
  
  
Line 145: Line 137:
  
 
| 01.15
 
| 01.15
|The grammar of TurtleScript can include '''comments and commands, numbers
+
|The grammar of TurtleScript can include '''comments and commands, numbers and strings .'''
and strings .'''
+
  
  
Line 168: Line 159:
 
  | 01.33
 
  | 01.33
  
  |let us  First have a look at variables, then we look at assigning values to
+
  |let us  First have a look at variables, then we look at assigning values to these variables.
these variables.
+
  
 
  |-
 
  |-
Line 211: Line 201:
 
  | 02.05
 
  | 02.05
  
  |It will keep that content until the program finishes the execution or until
+
  |It will keep that content until the program finishes the execution or until the variable is reassigned to something else.
the variable is reassigned to something else.
+
  
  
Line 257: Line 246:
 
  | 02.42
 
  | 02.42
  
  |The '''print''' command is used to command the turtle to print something on
+
  |The '''print''' command is used to command the turtle to print something on the canvas.
the canvas.
+
  
  
  
  
|-
+
|-
  
| 02.47
+
|02.47
  
 
  |'''print '''takes numbers and strings as input.
 
  |'''print '''takes numbers and strings as input.
Line 275: Line 263:
 
  | 02.51
 
  | 02.51
  
  |'''print $a + $b '''will add the two values and the turtle prints the value
+
  |'''print $a + $b '''will add the two values and the turtle prints the value 2024.
2024.
+
  
  
Line 283: Line 270:
 
  |02.57
 
  |02.57
  
  |I am now running the command , you can see that turtle has printed the
+
  |I am now running the command , you can see that turtle has printed the final result.
final result.
+
  
 
  |-
 
  |-
Line 318: Line 304:
  
 
| 03.23
 
| 03.23
  |'''canvassize 200,200'''which resizes the canvas to 200 pixels of width and
+
  |'''canvassize 200,200'''which resizes the canvas to 200 pixels of width and height each.
height each.
+
  
  
Line 361: Line 346:
  
 
  |-
 
  |-
> | 04.12
+
| 04.12
  
 
  |'''go 50,50'''
 
  |'''go 50,50'''
Line 415: Line 400:
 
| 04.49
 
| 04.49
  
  | The canvas size 200,200 fix the width and height of the canvas to 200
+
  | The canvas size 200,200 fix the width and height of the canvas to 200 pixels each.
pixels each.
+
 
  |-
 
  |-
 
  |04.55
 
  |04.55
Line 426: Line 410:
 
  | 04.58
 
  | 04.58
  
  | The 20-5 is assigned to variable subtract,
+
  |The 20-5 is assigned to variable subtract,
  
 
  |-
 
  |-
Line 438: Line 422:
 
  | 05.06
 
  | 05.06
  
  | 30/30 is assigned to the variable ''Divide.
+
  |30/30 is assigned to the variable ''Divide.
  
  
Line 445: Line 429:
 
  | 05.10
 
  | 05.10
  
  | We will not print the variables ,the result which is assigned to them and
+
  | We will not print the variables ,the result which is assigned to them and the turtle moves in the canvas.
the turtle moves in the canvas.
+
  
 
  |-
 
  |-
Line 460: Line 443:
 
  | 05.34
 
  | 05.34
  
  | You can see that the values have been printed on the canvas now.
+
  |You can see that the values have been printed on the canvas now.
  
  
 
  |-
 
  |-
  
  | 05.39
+
  |05.39
  
 
  | Let us consider a simple example for using the comparison operator .Type the commands being shown on the screen
 
  | Let us consider a simple example for using the comparison operator .Type the commands being shown on the screen
Line 472: Line 455:
 
  |-
 
  |-
  
  | 05.46
+
  |05.46
  
 
  |'''$answer = 10 > 3'''
 
  |'''$answer = 10 > 3'''
Line 493: Line 476:
 
|-
 
|-
  
| 06.08
+
| 06.08
  
  |The result of this comparison, the boolean value true will be stored in the
+
  |The result of this comparison, the boolean value true will be stored in the variable '''$answer, '''and the value '''true '''is printed.
variable '''$answer, '''and the value '''true '''is printed.
+
  
 
  |-
 
  |-
  
 
| 06.15
 
| 06.15
  | Let me know Run this piece of code,you can see that the turtle has printed
+
  | Let me know Run this piece of code,you can see that the turtle has printed the value true on the canvas.
the value true on the canvas.
+
  
  
Line 508: Line 489:
  
 
| 06.24
 
| 06.24
  | lets see how Strings work in this application –
+
  |lets see how Strings work in this application –
  
  
 
|-
 
|-
  
| 06.27
+
| 06.27
 
|Strings can be put in variables, just like numbers.
 
|Strings can be put in variables, just like numbers.
  
Line 521: Line 502:
 
  | 06.31
 
  | 06.31
  
  |Strings cannot be used in mathematical operators or comparison operators
+
  |Strings cannot be used in mathematical operators or comparison operators and Strings are highlighted with red.
and Strings are highlighted with red.
+
  
 
  |-
 
  |-
Line 528: Line 508:
 
  | 06.38
 
  | 06.38
  
  |Strings start and end with the '''''''' mark, by these marks KTurtle knows
+
  |Strings start and end with the '''''''' mark, by these marks KTurtle knows  that it is a string.
  that it is a string.
+
  
  
Line 536: Line 515:
 
  | 06.45
 
  | 06.45
  
|For example:I am typing the print command followed by a string,See that
+
|For example:I am typing the print command followed by a string,See that the string is highlighted in Red color.
the string is highlighted in Red color.
+
  
  
Line 588: Line 566:
 
  | 07.25
 
  | 07.25
  
  |The turtle choose the value true,the boolean value true is assigned the
+
  |The turtle choose the value true,the boolean value true is assigned the variable ''$answer ''is set to ''true ''because 10 is larger than 3.
variable ''$answer ''is set to ''true ''because 10 is larger than 3.
+
  
  
Line 603: Line 580:
 
  | 07.38
 
  | 07.38
  
  |the code that is placed between the brackets will be executed only ''if
+
  |the code that is placed between the brackets will be executed only ''if ''the ''boolean value ''evaluates 'true'.
''the ''boolean value ''evaluates 'true'.
+
  
  
Line 611: Line 587:
 
  | 07.44
 
  | 07.44
  
  |The code between the brackets after ''else ''is only executed if the ''if
+
  |The code between the brackets after ''else ''is only executed if the ''if''condition is false.
''condition is false.
+
  
  
Line 634: Line 609:
 
  | 07.55
 
  | 07.55
  
  |'''$x = 4 '''I now have a sample piece of code on my editor here , which
+
  |'''$x = 4 '''I now have a sample piece of code on my editor here , which compares the numbers 4 and 5 and prints the results accordingly.
compares the numbers 4 and 5 and prints the results accordingly.
+
  
  
Line 642: Line 616:
 
  | 08.03
 
  | 08.03
  
  |Let me now run this code. The turtle has compared the variables 4 and 5 and
+
  |Let me now run this code. The turtle has compared the variables 4 and 5 and its printing the result 4 is smaller than 6 .
its printing the result 4 is smaller than 6 .
+
  
  
Line 659: Line 632:
  
 
  |Using the '''if '''and '''else '''conditions, the '''mathematical
 
  |Using the '''if '''and '''else '''conditions, the '''mathematical
  operators''', solve an equation and print the results using the '''print
+
  operators''', solve an equation and print the results using the '''print'''and '''go '''command.
'''and '''go '''command.
+
  
 
|-
 
|-
Line 666: Line 638:
 
  | 08.28
 
  | 08.28
  
  |That is you can choose any four random numbers multiply the two sets of
+
  |That is you can choose any four random numbers multiply the two sets of random numbers, compare the results using the comparison operators and print both the results and print that greater result at center of the canvas you can choose any equation which you like.
random numbers, compare the results using the comparison operators and print
+
both the results and print that greater result at center of the canvas you
+
can choose any equation which you like.
+
  
 
  |-
 
  |-
Line 686: Line 655:
 
|08.50
 
|08.50
  
  |It is supported by the National Mission on Education through ICT, MHRD
+
  |It is supported by the National Mission on Education through ICT, MHRD government of India.
government of India.
+
  
  
Line 693: Line 661:
 
  | 08.56
 
  | 08.56
  
  | you can see more information about this on the link shown on the screen.
+
  |you can see more information about this on the link shown on the screen.
  
  
Line 700: Line 668:
 
  |08.59
 
  |08.59
  
  | Thank you this is Sindhu signing off. Enjoy exploring KTurtle.
+
  |Thank you this is Sindhu signing off. Enjoy exploring KTurtle.
  
  

Revision as of 11:06, 10 January 2013


Time Narration


00.02 Hello Everybody. Welcome to the KTurtle tutorial



00.05 If this is the first time you are using KTurtle, please see the
“Introduction to KTurtle” tutorial on the spoken tutorial website.
00.12 To get started with KTurtle, I am using the Linux operating system ubuntu Version 11.04 and KTurtle version 0.8.1 beta.


00.21 This tutorial will help you understand further, the Grammar of
TurtleScript.


00.26 If you have already installed KTurtle,


00.28 go to the Ubuntu Menu Item Applications > Education and click on the KTurtle Application.


00.34 Another way to open KTurtle is by going to Applications > Accessories menu and click on Terminal


00.39 At the prompt type the name of the application that is “kturtle” and hit 'Enter'.


00.46 This will open the application.


00.51 In this tutorial, we will learn, the grammar of turtle script which
includes,


00.55 commands and comments


00.56 numbers, variables and strings


00.58 mathematical and comparison operators
01.00 and the boolean values


01.02 And the if and else conditions


01.05 The TurtleScript is a programming language and has different types of words and symbols.


01.10 They are used for different purposes.


01.12 And it instructs KTurtle to do something.


01.15 The grammar of TurtleScript can include comments and commands, numbers and strings .


01.24 Numbers can be stored in mathematical operators in comparison

operators.


01.28 They can also be stored in variables.


01.33 let us First have a look at variables, then we look at assigning values to these variables.
01.38 In the editor of a Kturtle script ,let us open example for
avariable.


01.43 Variables are words that start with a symbol ‘$’, for example $a.


01.48 In the editor they are highlighted with the purple color.


01.52 Using the assignment, equal to a variable is given its content.


01.56 Variables can contain any number, string or boolean values (true/false).


02.05 It will keep that content until the program finishes the execution or until the variable is reassigned to something else.


02.11 You can use variables, once assigned, just as if they are their content.


02.16 For example, consider the code being typed in the editor now.


02.20 '$a = 2004 '$b = 25


02.27 Andprint $a + $b


02.33 First the value 2004 is assigned to the variable $a .
02.37 The next the value 2005,25'is assigned to variable '$b .



02.42 The print command is used to command the turtle to print something on the canvas.



02.47 print takes numbers and strings as input.


02.51 print $a + $b will add the two values and the turtle prints the value 2024.


02.57 I am now running the command , you can see that turtle has printed the final result.
03.05 Let us next see the Mathematical and the Comparison Operators.


03.08 The basic mathematical operators here are +, - , * , /


03.16 In the editor of a Kturtle let us type the following example –


03.20 reset


03.23 canvassize 200,200which resizes the canvas to 200 pixels of width and height each.


03.32 $add = 1 + 1


03.40 $subtract = 20 - 5


03.52 $multiply = 15 * 2


03.59 $divide = 30 /30


04.05 go 10,10


04.09 print $add
04.12 go 50,50


04.15 print $subtract


04.20 go 100,100


04.25 print $divide


04.30 go 0,0


04.34 Andprint $multiply


04.41 go 175,175


04.49 The canvas size 200,200 fix the width and height of the canvas to 200 pixels each.
04.55 The value 1+1 is assigned to the variable $+,
04.58 The 20-5 is assigned to variable subtract,
05.02 The value 15 * 2 will be assigned to the variable multiply.
05.06 30/30 is assigned to the variable Divide.


05.10 We will not print the variables ,the result which is assigned to them and the turtle moves in the canvas.
05.16 Let us now run this code.The command which is getting executed is

highlighted in the editor and the turtle is printing the results.


05.34 You can see that the values have been printed on the canvas now.


05.39 Let us consider a simple example for using the comparison operator .Type the commands being shown on the screen


05.46 $answer = 10 > 3
05.51 Andprint $answer
06.02 Here 10 is compared with 3 the ’greater than’ operator.



06.08 The result of this comparison, the boolean value true will be stored in the variable $answer, and the value true is printed.
06.15 Let me know Run this piece of code,you can see that the turtle has printed the value true on the canvas.


06.24 lets see how Strings work in this application –


06.27 Strings can be put in variables, just like numbers.


06.31 Strings cannot be used in mathematical operators or comparison operators and Strings are highlighted with red.
06.38 Strings start and end with the ''' mark, by these marks KTurtle knows that it is a string.


06.45 For example:I am typing the print command followed by a string,See that the string is highlighted in Red color.


06.56 When I run this piece of code, the turtle prints the chain on the canvas.
07.03 Boolean Values



07.04 There are only two boolean values: true and false.



07.07 For example –I am typing the example for using the boolean value in
kturtle.


07.14 $answer = 10 > 3


07.20 print $answer
07.25 The turtle choose the value true,the boolean value true is assigned the variable $answer is set to true because 10 is larger than 3.


07.36 Executing 'if' and 'else'conditions.


07.38 the code that is placed between the brackets will be executed only if the boolean value evaluates 'true'.


07.44 The code between the brackets after else is only executed if the ifcondition is false.


07.50 For example –


07.53 reset


07.55 $x = 4 I now have a sample piece of code on my editor here , which compares the numbers 4 and 5 and prints the results accordingly.


08.03 Let me now run this code. The turtle has compared the variables 4 and 5 and its printing the result 4 is smaller than 6 .


08.18 Now to the Assignment part.



08.20 Using the if and else conditions, the mathematical
operators, solve an equation and print the results using the printand go command.
08.28 That is you can choose any four random numbers multiply the two sets of random numbers, compare the results using the comparison operators and print both the results and print that greater result at center of the canvas you can choose any equation which you like.
08.45 I would like to acknowledge the spoken tutorial project
08.48 which is part of the talk to a teacher project.


08.50 It is supported by the National Mission on Education through ICT, MHRD government of India.


08.56 you can see more information about this on the link shown on the screen.


08.59 Thank you this is Sindhu signing off. Enjoy exploring KTurtle.



-- Thanks and regards Madhuri Ganpathi

Contributors and Content Editors

Madhurig, Sneha