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:
 +
{|border =1
 +
!Visual Cue
 +
!Narration
 +
|-
 +
||00.01
 +
||Hello everybody.
  
 +
|-
 +
||00.02
 +
||Welcome to this tutorial on '''Grammar of TurtleScript''' in '''KTurtle'''.
 +
|-
 +
||00.08
 +
||In this tutorial, we will learn about
  
  {| Border =1
+
|-
 +
||00.11
 +
|| Grammar of Turtle script and  'if'-'else' condition
 +
|-
 +
||00.16
 +
||To record this tutorial I am using,  Ubuntu Linux OS version. 12.04.  KTurtle version. 0.8.1 beta.
 +
|-
 +
|| 00.29
 +
||We assume that you have basic working knowledge of KTurtle
  
  |'' Time''
+
|-
 +
||00.35
 +
||If not, for relevant tutorials, please visit our website. '''http://spoken-tutorial.org'''
 +
|-
 +
||00.40
 +
||Let's open a new '''KTurtle''' Application.
  
|'''Narration'''
+
|-
 +
||00.43
 +
||Click on '''Dash home'''
  
 +
|-
 +
||00.45
 +
||In the Search bar, type '''KTurtle.'''
  
|-
+
|-
 +
||00.49
 +
||Click on the '''KTurtle''' icon.
 +
|-
 +
||00.52
 +
||We  can also open  KTurtle  using '''Terminal.'''
  
| 00.02
+
|-
 +
||00.56
 +
||Press '''CTRL+ALT+T''' simultaneously to open the '''Terminal'''.
 +
 +
|-
 +
||01.01
 +
||Type '''KTurtle'''  and press enter  to open the '''KTurtle''' Application.
 +
|-
 +
||01.08
 +
||Let's first look at '''TurtleScript'''
  
|Hello Everybody. Welcome to the KTurtle tutorial
+
|-
 +
||01.11
 +
|| '''TurtleScript''' is a programming language
  
 +
|-
 +
||01.15
 +
||It has different types of '''words and symbols''' used for '''various purposes'''
  
 +
|-
 +
||01.21
 +
|| It '''instructs''' Turtle what to do
 +
|-
 +
||01.25
 +
||'''Grammar of TurtleScript''' in ''' KTurtle''' includes-
  
 +
|-
 +
||01.30
 +
|| Comments
  
|-
+
|-
 +
||01.31
 +
|| Commands
  
| 00.05
+
|-
 +
||01.32
 +
|| Numbers
  
|If this is the first time you are using KTurtle, please see the
+
|-
“Introduction to KTurtle” tutorial on the spoken tutorial website.
+
||01.33
 +
|| Strings
  
 
|-
 
|-
 +
||01.34
 +
|| Variables and
  
|00.12
+
|-
 +
||01.36
 +
|| Boolean values
 +
|-
 +
||01.38
 +
||Now we will see where to store numbers
  
|To get started with KTurtle, I am using the Linux operating system ubuntu Version 11.04 and KTurtle version 0.8.1 beta.
+
|-
 +
||01.42
 +
||'''Numbers'''  can be stored in
  
 +
|-
 +
||01.44
 +
|| Mathematical operators
  
 
|-
 
|-
| 00.21
+
||01.46
|This tutorial will help you understand further, the '''Grammar of
+
||Comparison operators and
TurtleScript'''.
+
  
 +
|-
 +
||01.49
 +
||Variables
 +
|-
 +
||01.50
 +
||I will zoom the program text for clear view.
 +
|-
 +
||01.54
 +
||First  let's look at variables.
  
|-
+
|-
 +
||01.57
 +
||Variables are words that start with  ‘$’ sign, for example $a.
  
| 00.26
+
|-
 +
|| 02.04
 +
||In the editor they are highlighted in '''purple''' color.  
  
|If you have already installed KTurtle,
+
|-
 +
||02.09
 +
||Using the assignment, equal to (=), a variable is given its content.
  
 +
|-
 +
||02.14
 +
||Variables can contain  numbers '''$a=100'''.
  
 
|-
 
|-
 +
||02.20
 +
||strings '''$a=hello''' or
  
| 00.28
+
|-
 +
||02.25
 +
||boolean values that is true or false '''$a=true'''
  
|go to the Ubuntu Menu Item '''Applications >''' '''Education''' and click on the '''KTurtle''' Application.
+
|-
 +
||02.32
 +
||Variable keeps the content until program finishes execution or until it is reassigned to something else.  
  
 +
|-
 +
||02.41
 +
||For example, consider the code.
  
 
|-
 
|-
 +
||02.44
 +
||Let us type,'''$a = 2004'''
  
| 00.34
+
|-
 +
||02.50
 +
||'''$b = 25'''
  
|Another way to open KTurtle is by going to '''Applications > Accessories menu and click on Terminal'''
+
|-
 +
||02.55
 +
||'''print $a + $b'''
 +
|-
 +
||03.01
 +
||Variable 'a' is assigned a  value ''' 2004.'''
  
 +
|-
 +
||03.06
 +
||Variable 'b' is assigned a value '''25'''
  
|-
+
|-
 +
||03.10
 +
||'''print''' command, commands Turtle to write something on the canvas.
  
| 00.39
+
|-
 +
|| 03.15
 +
||'''print'''  command, takes numbers and strings as input.  
  
|At the prompt type the name of the application that is “'''kturtle'''and hit 'Enter'.
+
|-
 +
||03.19
 +
||'''print $a + $b''' commands '''Turtle''' to add two values and display them on the canvas.
 +
|-
 +
|| 03.29
 +
||Let's Run the code in '''slow''' speed.
  
 +
|-
 +
||03.34
 +
||Value '''2029''' is displayed on the canvas
 +
|-
 +
||03.40
 +
||Let us next see the Mathematical  Operators.
  
|-
+
|-
 +
||03.44
 +
||Mathematical operators include,
  
| 00.46
+
* '''+''' (Addition)
  
|This will open the application.
+
* '''-''' (Subtraction)
  
 +
* '''*''' (Multiplcation)  and
  
|-
+
* '''/''' (Division)
 +
|-
 +
||03.53
 +
|| I will clear the current code from editor and type '''clear''' command and '''RUN''' to clean the canvas
 +
|-
 +
||04.01
 +
||I already have a program in a text editor.
 +
|-
 +
||04.05
 +
||I will Explain the code now
 +
|-
 +
||04.08
 +
||'''“reset”''' command sets Turtle to its '''default''' position
 +
|-
 +
||04.12
 +
||'''canvassize 200,200''' fixes the width and height of the canvas to 200 pixels each.
 +
|-
 +
||04.22
 +
|| value '''1+1''' is assigned to the variable''' $add,'''
 +
|-
 +
||04.26
 +
||Value '''20-5''' is assigned to variable '''$subtract''',
 +
|-
 +
||04.31
 +
||value '''15 * 2''' is be assigned to the variable '''$multiply.'''
 +
|-
 +
||04.36
 +
||'''30/30''' is assigned to the variable '''$divide.'''
 +
|-
 +
||04.40
 +
||'''go 10,10''' commands to '''Turtle''' to go 10 pixels left of canvas and 10 pixels from top of canvas
 +
|-
 +
||04.52
 +
||'''print''' command displays the varible on the canvas
 +
|-
 +
||04.56
 +
||I will copy the code from text editor and paste it into '''KTurtle''' editor.
  
|00.51
+
|-
 +
||05.03
 +
||Pause the tutorial and type the program into''' KTurtle''' editor.
  
|In this tutorial, we will learn, the grammar of turtle script which
+
|-
  includes,
+
||05.08
 +
||Resume the tutorial after typing the program
 +
|-
 +
||05.13
 +
||Let us click on '''Run''' button to run the program
  
 +
|-
 +
||05.17
 +
||Command which is getting executed is highlighted on the editor.
  
 
|-
 
|-
 +
||05.22
 +
||'''Turtle''' displays the values on the canvas at the specified positions.
 +
|-
 +
||05.34
 +
||Let us consider a simple example for using  '''comparison operator''' .
  
| 00.55
 
  
|commands and comments
+
|-
 +
|| 05.41
 +
|| I will clear the current code from editor and type '''clear''' command and '''RUN''' to clean the canvas
 +
|-
 +
|| 05.49
 +
||I will  zoom the progrm text to have clear view
 +
|-
 +
|| 05.53
 +
||Let's type
  
 +
|-
 +
||05.55
 +
||'''$answer = 10 > 3'''
  
|-
+
|-
 +
||06.03
 +
||'''print $answer'''
  
| 00.56
+
|-
 +
||06.09
 +
||Here 10 is compared to 3 with the ’'''greater than'''’ operator.
  
|numbers, variables and strings
+
|-
 +
||06.14
 +
||The result of this comparison, the '''boolean value true''' is stored in the
  
 +
|-
 +
||06.19
 +
||variable '''$answer''' and the value '''true''' is displayed on the canvas.
 +
|-
 +
|| 06.27
 +
||Let's run the code now
  
|-
+
|-
 +
||06.29
 +
||'''Turtle''' displays '''Boolean value true''' on the canvas.
 +
|-
 +
||06.34
 +
||Now lets see how Strings work in this application –
  
| 00.58
+
|-
 +
||06.39
 +
||Strings can be put in variables like numbers
  
|mathematical and comparison operators
+
|-
 +
||06.43
 +
||Strings cannot be used in mathematical or comparison operators  
  
 
|-
 
|-
 +
||06.49
 +
||Strings are highlighted in red color
  
| 01.00
+
|-
 +
||06.53
 +
||KTurtle identifies a line in double quotes as a string
 +
|-
 +
|| 07.00
 +
||I will clear the current code from editor.type '''clear''' command and '''Run''' to clean the canvas
 +
|-
 +
||  07.08
 +
||Now  I will explain about Boolean values.
  
|and the boolean values
+
|-
 +
||07.11
 +
||There are only two '''boolean''' values: '''true''' and '''false.'''
 +
|-
 +
||07.16
 +
||For example  Let's type the code
  
 +
|-
 +
||07.20
 +
||'''$answer = 7<5'''
  
|-
+
|-
 +
||07.28
 +
||'''print $answer'''
  
|01.02
+
|-
|And the '''if '''and '''else '''conditions
+
||07.34
 +
||'''Boolean value false''' is assigned to variable''' $answer''' because 7 is greater than 5
 +
|-
 +
|| 07.43
 +
||Let's Run the code now
  
 +
|-
 +
||07.47
 +
||'''Turtle''' diplays '''Boolean''' value '''false''' on the canvas.
 +
|-
 +
|| 07.51
 +
||Let's next learn about “if-else” conditon.
  
 
|-
 
|-
 +
||07.56
 +
||‘if’ condition is executed only if the '''boolean''' value evaluates ‘true’
  
  | 01.05
+
|-
 +
||08.03
 +
||‘else’ condition is executed only if the ‘if’ condition is ‘false’ .
 +
|-
 +
|| 08.09
 +
||I will clear the current code from editor.type '''clear''' command and '''Run''' to clean the canvas
 +
|-
 +
||08.17
 +
||I already have a code in a text file.
 +
|-
 +
|| 08.21
 +
||This code compares numbers 4 , 5 and 6 and  displays the results accordingly on the canvas.
 +
|-
 +
||08.30
 +
||I will copy the code from text editor and paste it into '''KTurtle''' editor.
  
| The '''TurtleScript '''is a programming language and has different types of words and symbols.
+
|-
 +
||08.36
 +
||Pause the tutorial and type the program into your '''KTurtle''' editor.
  
 +
|-
 +
||08.42
 +
||Resume the tutorial after typing the program
 +
|-
 +
|| 08.46
 +
||Let's Run the code now
  
|-
+
|-
 +
||08.49
 +
||the '''Turtle''' has compared the values 4 and 5.
  
  | 01.10
+
|-
 +
||08.53
 +
||and has displayed the result 4 is smaller than 6 on the canvas .
 +
|-
 +
||09.00
 +
||With this we come to the end of this tutorial.
  
|They are used for different purposes.
+
|-
 +
||09.05
 +
||Let's summarize.
 +
|-
 +
||09.07
 +
||In this tutorial, we have learnt about
  
 +
|-
 +
||09.11
 +
||Grammar of Turtle script  and
  
|-
+
|-
| 01.12
+
||09.14
 +
|| ‘if-else’ condition
 +
|-
 +
||09.17
 +
||Now to the assignment part.
  
|And it instructs KTurtle to do something.
+
|-
 +
||09.19
 +
||'''Solve an equation using'''
  
 +
|-
 +
||09.22
 +
||if - else condition
  
|-
+
|-
 +
||09.24
 +
|| Mathematical  and comparision  operators
  
| 01.15
+
|-
|The grammar of TurtleScript can include '''comments and commands, numbers and strings .'''
+
||09.27
 +
|| Display the results using  “print” and “go” commands.  
 +
|-
 +
||09.33
 +
||To solve the assignment
  
 +
|-
 +
||09.35
 +
||Choose any four random numbers
  
 
|-
 
|-
 +
||09.38
 +
|| Multiply two sets of random numbers
  
| 01.24
+
|-
 
+
||09.42
|Numbers can be stored in ''mathematical operators ''in ''comparison
+
|| Compare the results using the comparison operators
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
+
a'''variable'''.
+
 
+
 
+
|-
+
 
+
|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
+
 
+
|And'''print $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.
+
 
+
 
+
 
+
  
 
|-
 
|-
 
+
||09.46
|02.47
+
|| Display both the results
 
+
|'''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,200'''which 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
+
||09.49
 
+
|| Display greater result at the center of the canvas
  |'''go 100,100'''
+
 
+
 
+
  
 
|-
 
|-
 
+
||09.54
| 04.25
+
|| You can choose any equation which you like.  
 
+
|-
|'''print $divide'''
+
||09.59
 
+
||Watch the video available at this URL '''http://spoken-tutorial.org/What is a Spoken Tutorial'''
 
+
|-
+
 
+
| 04.30
+
 
+
|'''go 0,0'''
+
 
+
 
+
|-
+
 
+
|04.34
+
 
+
| And'''print $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
+
 
+
|And'''print $answer'''
+
 
+
|-
+
 
+
| 06.02
+
 
+
|Here 10 is compared with 3 the ’'''greater than'''’ operator.
+
 
+
 
+
 
+
  
 
|-
 
|-
 
+
||10.03
| 06.08
+
||It summarises the Spoken Tutorial project
 
+
|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 –
+
 
+
  
 
|-
 
|-
 
+
||10.06
| 06.27
+
||If you do not have good bandwidth, you can download and watch it  
|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.
+
  
 
|-
 
|-
 
+
|| 10.12
|07.03
+
||The Spoken Tutorial Project Team :
 
+
| '''Boolean Values'''
+
 
+
 
+
 
+
  
 
|-
 
|-
 
+
||10.14
| 07.04
+
||Conducts workshops using spoken tutorials
 
+
|There are only two boolean values: ''true ''and ''false''.
+
 
+
 
+
 
+
  
 
|-
 
|-
| 07.07
+
||10.18
 
+
||Gives certificates to those who pass an online test
|For example –I am typing the example for using the boolean value in
+
kturtle.
+
 
+
 
+
 
+
|-
+
 
+
| 07.14
+
|'''$answer = 10 > 3'''
+
 
+
  
 
|-
 
|-
 
+
||10.22
| 07.20
+
||For more details, please write to '''contact@spoken-tutorial.org'''  
 
+
|-
|'''print $answer'''
+
|| 10.30
 
+
||Spoken Tutorial Project is a part of the Talk to a Teacher project
|-
+
 
+
| 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'.
+
 
+
  
 
|-
 
|-
 
+
||10.35
| 07.44
+
||It is supported by the National Mission on Education through ICT, MHRD, Government of India
 
+
|The code between the brackets after ''else ''is only executed if the ''if''condition is false.
+
 
+
 
+
 
+
|-
+
 
+
| 07.50
+
 
+
|For example –
+
 
+
  
 
|-
 
|-
| 07.53
+
||1043
 
+
||More information on this Mission is available at this link '''http://spoken-tutorial.org/NMEICT-Intro ]'''  
|'''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 '''print'''and '''go '''command.
+
  
 
|-
 
|-
 
+
||10.48
| 08.28
+
||The Script is contributed by '''ITfC Bangaluru.'''
 
+
|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
+
||10.52
 
+
||This is Madhuri Ganpathi from '''IIT Bombay''' signing off Thank you for joining.
|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.
+
 
+
 
+
|}
+

Latest revision as of 17:01, 1 April 2013

Visual Cue Narration
00.01 Hello everybody.
00.02 Welcome to this tutorial on Grammar of TurtleScript in KTurtle.
00.08 In this tutorial, we will learn about
00.11 Grammar of Turtle script and 'if'-'else' condition
00.16 To record this tutorial I am using, Ubuntu Linux OS version. 12.04. KTurtle version. 0.8.1 beta.
00.29 We assume that you have basic working knowledge of KTurtle
00.35 If not, for relevant tutorials, please visit our website. http://spoken-tutorial.org
00.40 Let's open a new KTurtle Application.
00.43 Click on Dash home.
00.45 In the Search bar, type KTurtle.
00.49 Click on the KTurtle icon.
00.52 We can also open KTurtle using Terminal.
00.56 Press CTRL+ALT+T simultaneously to open the Terminal.
01.01 Type KTurtle and press enter to open the KTurtle Application.
01.08 Let's first look at TurtleScript
01.11 TurtleScript is a programming language
01.15 It has different types of words and symbols used for various purposes
01.21 It instructs Turtle what to do
01.25 Grammar of TurtleScript in KTurtle includes-
01.30 Comments
01.31 Commands
01.32 Numbers
01.33 Strings
01.34 Variables and
01.36 Boolean values
01.38 Now we will see where to store numbers
01.42 Numbers can be stored in
01.44 Mathematical operators
01.46 Comparison operators and
01.49 Variables
01.50 I will zoom the program text for clear view.
01.54 First let's look at variables.
01.57 Variables are words that start with ‘$’ sign, for example $a.
02.04 In the editor they are highlighted in purple color.
02.09 Using the assignment, equal to (=), a variable is given its content.
02.14 Variables can contain numbers $a=100.
02.20 strings $a=hello or
02.25 boolean values that is true or false $a=true
02.32 Variable keeps the content until program finishes execution or until it is reassigned to something else.
02.41 For example, consider the code.
02.44 Let us type,$a = 2004
02.50 $b = 25
02.55 print $a + $b
03.01 Variable 'a' is assigned a value 2004.
03.06 Variable 'b' is assigned a value 25
03.10 print command, commands Turtle to write something on the canvas.
03.15 print command, takes numbers and strings as input.
03.19 print $a + $b commands Turtle to add two values and display them on the canvas.
03.29 Let's Run the code in slow speed.
03.34 Value 2029 is displayed on the canvas
03.40 Let us next see the Mathematical Operators.
03.44 Mathematical operators include,
  • + (Addition)
  • - (Subtraction)
  • * (Multiplcation) and
  • / (Division)
03.53 I will clear the current code from editor and type clear command and RUN to clean the canvas
04.01 I already have a program in a text editor.
04.05 I will Explain the code now
04.08 “reset” command sets Turtle to its default position
04.12 canvassize 200,200 fixes the width and height of the canvas to 200 pixels each.
04.22 value 1+1 is assigned to the variable $add,
04.26 Value 20-5 is assigned to variable $subtract,
04.31 value 15 * 2 is be assigned to the variable $multiply.
04.36 30/30 is assigned to the variable $divide.
04.40 go 10,10 commands to Turtle to go 10 pixels left of canvas and 10 pixels from top of canvas
04.52 print command displays the varible on the canvas
04.56 I will copy the code from text editor and paste it into KTurtle editor.
05.03 Pause the tutorial and type the program into KTurtle editor.
05.08 Resume the tutorial after typing the program
05.13 Let us click on Run button to run the program
05.17 Command which is getting executed is highlighted on the editor.
05.22 Turtle displays the values on the canvas at the specified positions.
05.34 Let us consider a simple example for using comparison operator .


05.41 I will clear the current code from editor and type clear command and RUN to clean the canvas
05.49 I will zoom the progrm text to have clear view
05.53 Let's type
05.55 $answer = 10 > 3
06.03 print $answer
06.09 Here 10 is compared to 3 with the ’greater than’ operator.
06.14 The result of this comparison, the boolean value true is stored in the
06.19 variable $answer and the value true is displayed on the canvas.
06.27 Let's run the code now
06.29 Turtle displays Boolean value true on the canvas.
06.34 Now lets see how Strings work in this application –
06.39 Strings can be put in variables like numbers
06.43 Strings cannot be used in mathematical or comparison operators
06.49 Strings are highlighted in red color
06.53 KTurtle identifies a line in double quotes as a string
07.00 I will clear the current code from editor.type clear command and Run to clean the canvas
07.08 Now I will explain about Boolean values.
07.11 There are only two boolean values: true and false.
07.16 For example Let's type the code
07.20 $answer = 7<5
07.28 print $answer
07.34 Boolean value false is assigned to variable $answer because 7 is greater than 5
07.43 Let's Run the code now
07.47 Turtle diplays Boolean value false on the canvas.
07.51 Let's next learn about “if-else” conditon.
07.56 ‘if’ condition is executed only if the boolean value evaluates ‘true’
08.03 ‘else’ condition is executed only if the ‘if’ condition is ‘false’ .
08.09 I will clear the current code from editor.type clear command and Run to clean the canvas
08.17 I already have a code in a text file.
08.21 This code compares numbers 4 , 5 and 6 and displays the results accordingly on the canvas.
08.30 I will copy the code from text editor and paste it into KTurtle editor.
08.36 Pause the tutorial and type the program into your KTurtle editor.
08.42 Resume the tutorial after typing the program
08.46 Let's Run the code now
08.49 the Turtle has compared the values 4 and 5.
08.53 and has displayed the result 4 is smaller than 6 on the canvas .
09.00 With this we come to the end of this tutorial.
09.05 Let's summarize.
09.07 In this tutorial, we have learnt about
09.11 Grammar of Turtle script and
09.14 ‘if-else’ condition
09.17 Now to the assignment part.
09.19 Solve an equation using
09.22 if - else condition
09.24 Mathematical and comparision operators
09.27 Display the results using “print” and “go” commands.
09.33 To solve the assignment
09.35 Choose any four random numbers
09.38 Multiply two sets of random numbers
09.42 Compare the results using the comparison operators
09.46 Display both the results
09.49 Display greater result at the center of the canvas
09.54 You can choose any equation which you like.
09.59 Watch the video available at this URL http://spoken-tutorial.org/What is a Spoken Tutorial
10.03 It summarises the Spoken Tutorial project
10.06 If you do not have good bandwidth, you can download and watch it
10.12 The Spoken Tutorial Project Team :
10.14 Conducts workshops using spoken tutorials
10.18 Gives certificates to those who pass an online test
10.22 For more details, please write to contact@spoken-tutorial.org
10.30 Spoken Tutorial Project is a part of the Talk to a Teacher project
10.35 It is supported by the National Mission on Education through ICT, MHRD, Government of India
1043 More information on this Mission is available at this link http://spoken-tutorial.org/NMEICT-Intro ]
10.48 The Script is contributed by ITfC Bangaluru.
10.52 This is Madhuri Ganpathi from IIT Bombay signing off Thank you for joining.

Contributors and Content Editors

Madhurig, Sneha