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

From Script | Spoken-Tutorial
Jump to: navigation, search
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
Title of the tutorial: Grammar-of-TurtleScript
 +
 +
Author: ITfC Bangaluru
 +
 +
Key words: Grammar of Turtle script, if-else condition, Comments, Commands, Numbers, Strings, Variables, Boolean values, strings and video tutorial.
 +
 
{|border =1
 
{|border =1
 
!Visual Cue
 
!Visual Cue
 
!Narration
 
!Narration
 
|-
 
|-
||Slide Number 1
+
||'''Slide Number 1'''
||
+
  
Hello everybody.
+
'''Title slide'''
 +
||Hello everybody.
  
Welcome to this tutorial on Grammar of TurtleScript in KTurtle.  
+
Welcome to this tutorial on '''Grammar of TurtleScript''' in '''KTurtle'''.  
 
|-
 
|-
||Slide Number 2  
+
||'''Slide Number 2'''
Learning Objectives  
+
 
||In this tutorial, we will learn
+
'''Learning Objectives'''
Grammar of Turtle script  and
+
||In this tutorial, we will learn about
'if'-'else' condition
+
 
 +
* Grammar of Turtle script  and
 +
 
 +
* 'if'-'else' condition
 
|-
 
|-
||Slide Number 3  
+
||'''Slide Number 3'''
System Requirement  
+
 
 +
'''System Requirement'''
 
||To record this tutorial I am using,  
 
||To record this tutorial I am using,  
 +
 
Ubuntu Linux OS version. 12.04.  
 
Ubuntu Linux OS version. 12.04.  
 +
 
KTurtle version. 0.8.1 beta.  
 
KTurtle version. 0.8.1 beta.  
 
|-
 
|-
 
||Slide Number 4  
 
||Slide Number 4  
Pre-requisites  
+
 
 +
'''Pre-requisites'''
 
||We assume that you have basic working knowledge of KTurtle  
 
||We assume that you have basic working knowledge of KTurtle  
 +
 
If not,  
 
If not,  
 +
 
for relevant tutorials, please visit our website.  
 
for relevant tutorials, please visit our website.  
http://spoken-tutorial.org  
+
 
 +
'''http://spoken-tutorial.org'''
 
|-
 
|-
||Switch to KTurtle Application
+
||Switch to '''KTurtle''' Application  
Dash home >>In the Search bar type KTurtle Click on the KTurtle icon.
+
||Let's open a new KTurtle Application.
+
  
Click on Dash home.   
+
'''Dash home''' >>In the Search bar
In the Search bar, type KTurtle.  
+
 
Click on the KTurtle icon.  
+
type '''KTurtle''' click on the '''KTurtle''' icon.
 +
||Let's open a new '''KTurtle''' Application.
 +
 
 +
Click on '''Dash home'''.   
 +
 
 +
In the Search bar, type '''KTurtle.'''
 +
 
 +
Click on the '''KTurtle''' icon.  
 
|-
 
|-
||Press CTRL+ALT+T  >> open the terminal >>type kTurtle >>press enter to open
+
||Press '''CTRL+ALT+T''' >> open the '''Terminal'''
||We  can also open  KTurtle Application from the terminal.
+
  
Press CTRL+ALT+T simultaneously to open the terminal.
+
>>type kTurtle >>press enter to open
 +
||We  can also open  KTurtle  using '''Terminal.'''
 +
 
 +
Press '''CTRL+ALT+T''' simultaneously to open the '''Terminal'''.
 
   
 
   
Type KTurtle  and press enter KTurtle. Application opens
+
Type '''KTurtle''' and press enter   to open the '''KTurtle''' Application.
 
|-
 
|-
||Turtle Script
+
||Slide Number 5
||First I will explain about TurtleScript
+
 
TurtleScript is a programming language  
+
Turtle Script
It has different types of words and symbols used for various purposes  
+
||Let's first look at '''TurtleScript'''
It instructs Turtle what to do
+
 
 +
* '''TurtleScript''' is a programming language  
 +
 
 +
* It has different types of '''words and symbols''' used for '''various purposes'''
 +
 
 +
* It '''instructs''' Turtle what to do
 
|-
 
|-
||Grammar of TurtleScript
+
||'''Slide Number 6'''
||Grammar of TurtleScript in KTurtle includes-  
+
 
Comments
+
'''Grammar of TurtleScript'''
Commands
+
||'''Grammar of TurtleScript''' in ''' KTurtle''' includes-  
Numbers
+
 
Strings
+
* Comments
Variables and
+
 
Boolean values
+
* Commands
 +
 
 +
* Numbers
 +
 
 +
* Strings
 +
 
 +
* Variables and
 +
 
 +
* Boolean values
 
|-
 
|-
||Numbers
+
||'''Slide Number 7'''
 +
 
 +
'''Numbers'''
 
||Now we will see where to store numbers
 
||Now we will see where to store numbers
Numbers  can be stored in
+
 
Mathematical operators
+
'''Numbers''' can be stored in
Comparison operators and
+
 
Variables
+
* Mathematical operators
|-Zoom text
+
 
I will zoom the program text for clear view.
+
* Comparison operators and
 +
 
 +
* Variables
 
|-
 
|-
||Switch to KTurtle window
+
||'''Zoom text'''
 +
||I will zoom the program text for clear view.
 +
|-
 +
||'''Switch to KTurtle window'''
 
||First  let's look at variables.  
 
||First  let's look at variables.  
Variables are words that start with a ‘$’, for example $a.
+
 
In the editor they are highlighted with purple.  
+
Variables are words that start with ‘$’ sign, for example $a.
 +
 
 +
In the editor they are highlighted in '''purple''' color.  
  
 
Using the assignment, equal to (=), a variable is given its content.  
 
Using the assignment, equal to (=), a variable is given its content.  
  
Variables can contain  numbers $a=100
+
Variables can contain  numbers '''$a=100'''.
strings $a=hello or  
+
 
boolean values that is true or false $a=true
+
strings '''$a=hello''' or  
 +
 
 +
boolean values that is true or false '''$a=true'''
 +
 
 +
Variable keeps the content until program finishes execution or until it is reassigned to something else.
  
Variable keeps the content until program finishes  execution or until it is reassigned to something else.
 
You can use variables, once assigned, just as if they are their content.
 
 
|-
 
|-
 
||
 
||
||For example, consider the code typed in the editor.
+
||For example, consider the code.
  
$a = 2004  
+
'''$a = 2004'''
$b = 25  
+
 
 +
'''$b = 25'''
 +
 
 +
'''print $a + $b'''
 
|-
 
|-
 
||
 
||
||print $a + $b
+
||Variable 'a' is assigned a  value ''' 2004.'''
  
Variable 'a' is assigned a value 2004.
+
Variable 'b' is assigned a value '''25'''
  
Variable 'b' is assigned a value 25
+
'''print''' command, commands Turtle to write something on the canvas.
  
print command commands Turtle to write something on the canvas.  
+
'''print'''  command, takes numbers and strings as input.  
  
print  command takes numbers and strings as input.
+
'''print $a + $b''' commands '''Turtle''' to add two values and display them on the canvas.
 
+
print $a + $b  commands Turtle to add two values and display them on the canvas.
+
 
|-
 
|-
 
||Run the code
 
||Run the code
||Let's Run the code slow speed.
+
||Let's Run the code in '''slow''' speed.
Value 2029 is displayed on the canvas
+
 
 +
Value '''2029''' is displayed on the canvas
 
|-
 
|-
||Mathematical operators
+
||'''Slide Number 8'''
 +
 
 +
'''Mathematical operators'''
 
||Let us next see the Mathematical  Operators.
 
||Let us next see the Mathematical  Operators.
 +
 
Mathematical operators include,
 
Mathematical operators include,
+ (Addition)  
+
 
- (Subtraction)  
+
* '''+''' (Addition)  
* (Multiplcation)  
+
 
/ (Division)
+
* '''-''' (Subtraction)  
 +
 
 +
* '''*''' (Multiplcation)  
 +
 
 +
* '''/''' (Division)
 +
|-
 +
||Clear code
 +
|| I will clear the current code from editor and type '''clear''' command and '''RUN''' to clean the canvas
 
|-
 
|-
 
||
 
||
 
||I already have a program in a text editor.  
 
||I already have a program in a text editor.  
|-
 
||
 
reset
 
canvassize 200,200
 
$add = 1 + 1
 
$subtract = 20 – 5
 
$multiply = 15 * 2
 
$divide = 30 /30
 
go 10,10
 
print $add
 
go 50,50
 
print $subtract
 
go 100,100
 
print $multiply
 
go 175,175
 
print $divide
 
go 0,0
 
||I will copy the code from text editor and paste it into KTurtle editor.
 
 
Pause the tutorial and type the program into KTurtle editor.
 
 
Resume the tutorial after typing the program
 
 
|-
 
|-
 
||
 
||
 
||I will Explain the code now
 
||I will Explain the code now
 
|-
 
|-
||Highlight reset
+
||Highlight''' reset'''
||“reset” command sets Turtle to its default position
+
||'''“reset”''' command sets Turtle to its '''default''' position
 
|-
 
|-
||Highlight canvassize 200,200  
+
||Highlight '''canvassize 200,200'''
  
||canvassize 200,200 fix the width and height of the canvas to 200 pixels each.  
+
||'''canvassize 200,200''' fixes the width and height of the canvas to 200 pixels each.  
 
|-
 
|-
||Highlight $add = 1 + 1
+
||Highlight '''$add = 1 + 1'''
|| value 1+1 is assigned to the variable $add,  
+
|| value '''1+1''' is assigned to the variable''' $add,'''
 
|-
 
|-
||Highlight $subtract = 20 – 5
+
||Highlight''' $subtract = 20 – 5'''
||20-5 is assigned to variable $subtract,  
+
||Value '''20-5''' is assigned to variable '''$subtract''',  
 
|-
 
|-
||Highlight $multiply = 15 * 2
+
||Highlight''' $multiply = 15 * 2'''
||value 15 * 2 will be assigned to the variable multiply.  
+
||value '''15 * 2''' is be assigned to the variable '''$multiply.'''
 
|-
 
|-
 
||Highlight $divide = 30 /30
 
||Highlight $divide = 30 /30
||30/30 is assigned to the variable Divide.  
+
||'''30/30''' is assigned to the variable '''$divide.'''
 
|-
 
|-
||Highlight go 10,10
+
||Highlight '''go 10,10'''
||go 10,10 commands to turtle to go 10 pixels left of canvas and 10 pixels from top of canvas
+
||'''go 10,10''' commands to '''Turtle''' to go 10 pixels left of canvas and 10 pixels from top of canvas
 +
|-
 +
||Highlight '''print''' commands
 +
||'''print''' command displays the varible on the canvas
 +
|-
 +
||
 +
'''reset'''
 +
 
 +
'''canvassize 200,200'''
 +
 
 +
'''$add = 1 + 1'''
 +
 
 +
'''$subtract = 20 – 5'''
 +
 
 +
'''$multiply = 15 * 2'''
 +
 
 +
'''$divide = 30 /30'''
 +
 
 +
'''go 10,10'''
 +
 
 +
'''print $add'''
 +
 
 +
'''go 50,50'''
 +
 
 +
'''print $subtract'''
 +
 
 +
'''go 100,100
 +
'''
 +
'''print $multiply'''
 +
 
 +
'''go 175,175'''
 +
 
 +
'''print $divide'''
 +
 
 +
'''go 0,0'''
 +
||I will copy the code from text editor and paste it into '''KTurtle''' editor.
 +
 
 +
Pause the tutorial and type the program into''' KTurtle''' editor.
 +
 
 +
Resume the tutorial after typing the program
 
|-
 
|-
 
||Run code
 
||Run code
 +
 
Point to the values
 
Point to the values
||Let us now run this code in slow speed
+
||Let us click on '''Run''' button to run the program
Command which is getting executed is highlighted in the editor.
+
 
Turtle displays the values on the canvas at the specified positions.  
+
Command which is getting executed is highlighted on the editor.
 +
 
 +
'''Turtle''' displays the values on the canvas at the specified positions.  
 
|-
 
|-
 
||
 
||
||Let us consider a simple example for using the comparison operator .
+
||Let us consider a simple example for using '''comparison operator''' .
 +
 
 
Type the commands being shown on the screen.
 
Type the commands being shown on the screen.
 +
|-
 +
||Clear code
 +
|| I will clear the current code from editor and type '''clear''' command and '''RUN''' to clean the canvas
 
|-
 
|-
 
|| zoom  text
 
|| zoom  text
||I will  zoom the text to have clear view
+
||I will  zoom the progrm text to have clear view
 
|-
 
|-
 
||Switch to Kturtle Window
 
||Switch to Kturtle Window
||$answer = 10 > 3
+
||Let's type
print $answer
+
  
Here 10 is compared to 3 with the ’greater than’ operator.
+
'''$answer = 10 > 3'''
  
The result of this comparison, the boolean value true is stored in the variable $answer and the value true is displayed.
+
'''print $answer'''
 +
 
 +
Here 10 is compared to 3 with the ’'''greater than'''’ operator.
 +
 
 +
The result of this comparison, the '''boolean value true''' is stored in the  
 +
 
 +
variable '''$answer''' and the value '''true''' is displayed on the canvas.
 
|-
 
|-
 
||Run the code
 
||Run the code
||Let's run this code  
+
||Let's run the code now
Turtle has displayed Boolean value true on the canvas.
+
 
 +
'''Turtle''' displays '''Boolean value true''' on the canvas.
 
|-
 
|-
||Strings
+
||'''Slide Number 9'''
 +
 
 +
'''Strings'''
 
||Now lets see how Strings work in this application –
 
||Now lets see how Strings work in this application –
Strings can be put in variables like numbers  
+
 
Strings cannot be used in mathematical or comparison operators  
+
* Strings can be put in variables like numbers  
Strings are highlighted in red color  
+
 
KTurtle identifies a line in double quote as a string
+
* Strings cannot be used in mathematical or comparison operators  
 +
 
 +
* Strings are highlighted in red color  
 +
 
 +
*KTurtle identifies a line in double quotes as a string
 
|-
 
|-
 
||clear code
 
||clear code
||I will clear the current code from editor.
+
||I will clear the current code from editor.type '''clear''' command and '''Run''' to clean the canvas
|-
+
||Example of string
+
||For example:I am typing the print command followed by a string, “Hello”.
+
We See that the string is highlighted in Red color.
+
|-
+
||Run code
+
||When I run this piece of code, the turtle displays the string on the canvas.
+
 
|-
 
|-
 
||Boolean Values  
 
||Boolean Values  
||Next I will explain about Boolean values.
+
||Now I will explain about Boolean values.
There are only two boolean values: true and false.  
+
 
 +
There are only two '''boolean''' values: '''true''' and '''false.'''
 
|-
 
|-
 
||
 
||
 
||For example  Let's type the code  
 
||For example  Let's type the code  
`if-else' Condition
 
$answer = 7<5
 
print $answer
 
  
Boolean value false is displayed on the canvas.
+
'''$answer = 7<5'''
Boolean value false is assigned to variable $answer  because 7 is larger than 5
+
 
 +
'''print $answer'''
 +
 
 +
'''Boolean value false''' is assigned to variable''' $answer''' because 7 is greater than 5
 +
|-
 +
||Run code
 +
||Let's Run the code now
 +
 
 +
'''Turtle''' diplays '''Boolean''' value '''false''' on the canvas.
 
|-
 
|-
 
||“if-else” conditon.
 
||“if-else” conditon.
 
||Let's next learn about “if-else” conditon.
 
||Let's next learn about “if-else” conditon.
  
‘if’ condition is executed only if the  
+
‘if’ condition is executed only if the '''boolean''' value evaluates ‘true’  
boolean value evaluates ‘true’  
+
 
 
‘else’ condition is executed only if the ‘if’  
 
‘else’ condition is executed only if the ‘if’  
 
condition is ‘false’ .
 
condition is ‘false’ .
 +
|-
 +
||clear code
 +
||I will clear the current code from editor.type '''clear''' command and '''Run''' to clean the canvas
 
|-
 
|-
 
||
 
||
||I already have a program in a text editor.  
+
||I already have a code in a text file.
 
|-
 
|-
||reset
+
||Highlight the code
$x=4
+
||This code compares  numbers 4 , 5 and 6 and  displays the results accordingly on the canvas.
if $x>5 {
+
|-
print $x
+
||'''reset'''
print “is greater than five”
+
 
}
+
'''$x=4'''
else {
+
 
print $x  
+
'''if $x>5 {'''
print “is smaller than six”
+
 
 +
'''print $x'''
 +
 
 +
'''print “is greater than five”'''
 +
 
 +
'''}'''
 +
 
 +
'''else {'''
 +
 
 +
'''print $x'''
 +
 
 +
'''print “is smaller than six”'''
 +
 
 
}
 
}
go 0,0
 
|| I will copy the code from text editor and paste it into KTurtle editor.
 
  
Pause the tutorial and type the program into KTurtle editor.
+
'''go 0,0'''
 +
||I will copy the code from text editor and paste it into '''KTurtle''' editor.
 +
 
 +
Pause the tutorial and type the program into '''KTurtle''' editor.
  
 
Resume the tutorial after typing the program
 
Resume the tutorial after typing the program
 
|-
 
|-
||
+
 
||This code compares  numbers 4 , 5 and 6 and  displays the results accordingly.
+
|-
+
 
||Run code
 
||Run code
||Let me now run this code.
+
||Let's Run the code now
Turtle has compared the variables 4 and 5.
+
 
and displayed the  result 4 is smaller than 6 on the canvas .  
+
the '''Turtle''' has compared the values 4 and 5.
 +
 
 +
and has displayed the  result 4 is smaller than 6 on the canvas .  
 
|-
 
|-
 
||
 
||
 
||With this we come to the end of this tutorial.
 
||With this we come to the end of this tutorial.
 +
 
Let's summarize.
 
Let's summarize.
 
|-
 
|-
Slide Number  
+
||'''Slide Number 10'''
 +
'''Summary'''
 +
||In this tutorial, we have learnt about
  
Summary
+
* Grammar of Turtle script  and
||In this tutorial,  we have learnt about
+
 
Grammar of Turtle script  and
+
* ‘if-else’ condition  
‘if-else’ condition  
+
 
|-
 
|-
||Assignment
+
||'''Slide Number 11'''
 +
 
 +
'''Assignment'''
 
||Now to the assignment part.
 
||Now to the assignment part.
Solve an equation using
+
 
if - else condition
+
'''Solve an equation using'''
Mathematical  and comparision  operators
+
 
Display the results using  “print” and “go” commands.  
+
* if - else condition
 +
 
 +
* Mathematical  and comparision  operators
 +
 
 +
* Display the results using  “print” and “go” commands.  
 
|-
 
|-
||Assignment
+
||'''Slide Number 12'''
 +
 
 +
'''Assignment'''
 
||
 
||
 
To solve the assignment
 
To solve the assignment
Choose any four random numbers
+
 
Multiply two sets of random numbers
+
* Choose any four random numbers
ompare the results using the comparison operators
+
 
Display the results  
+
* Multiply two sets of random numbers
Display greater result at center of the canvas  
+
 
you can choose any equation which you like.  
+
* Compare the results using the comparison operators
 +
 
 +
* Display the results  
 +
 
 +
* Display greater result at center of the canvas  
 +
 
 +
* You can choose any equation which you like.  
 
|-
 
|-
||Slide number 11
+
||'''Slide number 13'''
Acknowledgement  
+
 
||Watch the video available at  
+
'''Acknowledgement'''
http://spoken-tutorial.org/What is a Spoken Tutorial
+
||Watch the video available at this URL
 +
 
 +
'''http://spoken-tutorial.org/What is a Spoken Tutorial'''
 +
 
 
It summarises the Spoken Tutorial project
 
It summarises the Spoken Tutorial project
 +
 
If you do not have good bandwidth, you can download and watch it  
 
If you do not have good bandwidth, you can download and watch it  
 +
 
|-
 
|-
||Slide Number 12
+
||'''Slide Number 14'''
 
||The Spoken Tutorial Project Team :  
 
||The Spoken Tutorial Project Team :  
 +
 
Conducts workshops using spoken tutorials
 
Conducts workshops using spoken tutorials
 +
 
Gives certificates to those who pass an online test  
 
Gives certificates to those who pass an online test  
 +
 
For more details, please write to  
 
For more details, please write to  
contact@spoken-tutorial.org  
+
 
 +
'''contact@spoken-tutorial.org'''
 
|-
 
|-
||Slide number 13
+
||'''Slide number 15'''
 
||Spoken Tutorial Project is a part of the Talk to a Teacher project  
 
||Spoken Tutorial Project is a part of the Talk to a Teacher project  
 +
 
It is supported by the National Mission on Education through ICT, MHRD, Government of India
 
It is supported by the National Mission on Education through ICT, MHRD, Government of India
More information on this Mission is available at http://spoken-tutorial.org/NMEICT-Intro ]
 
  
Script is contributed by ITfC Bangaluru.
+
More information on this Mission is available at this link
This is Madhuri Ganpathi from IIT Bombay  signing off Thank you for joining.
+
 
 +
'''http://spoken-tutorial.org/NMEICT-Intro ]'''
 +
 
 +
The Script is contributed by '''ITfC Bangaluru.'''
 +
 
 +
This is Madhuri Ganpathi from '''IIT Bombay''' signing off Thank you for joining.
 
|-
 
|-

Latest revision as of 15:38, 18 December 2013

Title of the tutorial: Grammar-of-TurtleScript

Author: ITfC Bangaluru

Key words: Grammar of Turtle script, if-else condition, Comments, Commands, Numbers, Strings, Variables, Boolean values, strings and video tutorial.

Visual Cue Narration
Slide Number 1

Title slide

Hello everybody.

Welcome to this tutorial on Grammar of TurtleScript in KTurtle.

Slide Number 2

Learning Objectives

In this tutorial, we will learn about
  • Grammar of Turtle script and
  • 'if'-'else' condition
Slide Number 3

System Requirement

To record this tutorial I am using,

Ubuntu Linux OS version. 12.04.

KTurtle version. 0.8.1 beta.

Slide Number 4

Pre-requisites

We assume that you have basic working knowledge of KTurtle

If not,

for relevant tutorials, please visit our website.

http://spoken-tutorial.org

Switch to KTurtle Application

Dash home >>In the Search bar

type KTurtle click on the KTurtle icon.

Let's open a new KTurtle Application.

Click on Dash home.

In the Search bar, type KTurtle.

Click on the KTurtle icon.

Press CTRL+ALT+T >> open the Terminal

>>type kTurtle >>press enter to open

We can also open KTurtle using Terminal.

Press CTRL+ALT+T simultaneously to open the Terminal.

Type KTurtle and press enter to open the KTurtle Application.

Slide Number 5

Turtle Script

Let's first look at TurtleScript
  • TurtleScript is a programming language
  • It has different types of words and symbols used for various purposes
  • It instructs Turtle what to do
Slide Number 6

Grammar of TurtleScript

Grammar of TurtleScript in KTurtle includes-
  • Comments
  • Commands
  • Numbers
  • Strings
  • Variables and
  • Boolean values
Slide Number 7

Numbers

Now we will see where to store numbers

Numbers can be stored in

  • Mathematical operators
  • Comparison operators and
  • Variables
Zoom text I will zoom the program text for clear view.
Switch to KTurtle window First let's look at variables.

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

In the editor they are highlighted in purple color.

Using the assignment, equal to (=), a variable is given its content.

Variables can contain numbers $a=100.

strings $a=hello or

boolean values that is true or false $a=true

Variable keeps the content until program finishes execution or until it is reassigned to something else.

For example, consider the code.

$a = 2004

$b = 25

print $a + $b

Variable 'a' is assigned a value 2004.

Variable 'b' is assigned a value 25

print command, commands Turtle to write something on the canvas.

print command, takes numbers and strings as input.

print $a + $b commands Turtle to add two values and display them on the canvas.

Run the code Let's Run the code in slow speed.

Value 2029 is displayed on the canvas

Slide Number 8

Mathematical operators

Let us next see the Mathematical Operators.

Mathematical operators include,

  • + (Addition)
  • - (Subtraction)
  • * (Multiplcation)
  • / (Division)
Clear code I will clear the current code from editor and type clear command and RUN to clean the canvas
I already have a program in a text editor.
I will Explain the code now
Highlight reset “reset” command sets Turtle to its default position
Highlight canvassize 200,200 canvassize 200,200 fixes the width and height of the canvas to 200 pixels each.
Highlight $add = 1 + 1 value 1+1 is assigned to the variable $add,
Highlight $subtract = 20 – 5 Value 20-5 is assigned to variable $subtract,
Highlight $multiply = 15 * 2 value 15 * 2 is be assigned to the variable $multiply.
Highlight $divide = 30 /30 30/30 is assigned to the variable $divide.
Highlight go 10,10 go 10,10 commands to Turtle to go 10 pixels left of canvas and 10 pixels from top of canvas
Highlight print commands print command displays the varible on the canvas

reset

canvassize 200,200

$add = 1 + 1

$subtract = 20 – 5

$multiply = 15 * 2

$divide = 30 /30

go 10,10

print $add

go 50,50

print $subtract

go 100,100 print $multiply

go 175,175

print $divide

go 0,0

I will copy the code from text editor and paste it into KTurtle editor.

Pause the tutorial and type the program into KTurtle editor.

Resume the tutorial after typing the program

Run code

Point to the values

Let us click on Run button to run the program

Command which is getting executed is highlighted on the editor.

Turtle displays the values on the canvas at the specified positions.

Let us consider a simple example for using comparison operator .

Type the commands being shown on the screen.

Clear code I will clear the current code from editor and type clear command and RUN to clean the canvas
zoom text I will zoom the progrm text to have clear view
Switch to Kturtle Window Let's type

$answer = 10 > 3

print $answer

Here 10 is compared to 3 with the ’greater than’ operator.

The result of this comparison, the boolean value true is stored in the

variable $answer and the value true is displayed on the canvas.

Run the code Let's run the code now

Turtle displays Boolean value true on the canvas.

Slide Number 9

Strings

Now lets see how Strings work in this application –
  • Strings can be put in variables like numbers
  • Strings cannot be used in mathematical or comparison operators
  • Strings are highlighted in red color
  • KTurtle identifies a line in double quotes as a string
clear code I will clear the current code from editor.type clear command and Run to clean the canvas
Boolean Values Now I will explain about Boolean values.

There are only two boolean values: true and false.

For example Let's type the code

$answer = 7<5

print $answer

Boolean value false is assigned to variable $answer because 7 is greater than 5

Run code Let's Run the code now

Turtle diplays Boolean value false on the canvas.

“if-else” conditon. Let's next learn about “if-else” conditon.

‘if’ condition is executed only if the boolean value evaluates ‘true’

‘else’ condition is executed only if the ‘if’ condition is ‘false’ .

clear code I will clear the current code from editor.type clear command and Run to clean the canvas
I already have a code in a text file.
Highlight the code This code compares numbers 4 , 5 and 6 and displays the results accordingly on the canvas.
reset

$x=4

if $x>5 {

print $x

print “is greater than five”

}

else {

print $x

print “is smaller than six”

}

go 0,0

I will copy the code from text editor and paste it into KTurtle editor.

Pause the tutorial and type the program into KTurtle editor.

Resume the tutorial after typing the program

Run code Let's Run the code now

the Turtle has compared the values 4 and 5.

and has displayed the result 4 is smaller than 6 on the canvas .

With this we come to the end of this tutorial.

Let's summarize.

Slide Number 10

Summary

In this tutorial, we have learnt about
  • Grammar of Turtle script and
  • ‘if-else’ condition
Slide Number 11

Assignment

Now to the assignment part.

Solve an equation using

  • if - else condition
  • Mathematical and comparision operators
  • Display the results using “print” and “go” commands.
Slide Number 12

Assignment

To solve the assignment

  • Choose any four random numbers
  • Multiply two sets of random numbers
  • Compare the results using the comparison operators
  • Display the results
  • Display greater result at center of the canvas
  • You can choose any equation which you like.
Slide number 13

Acknowledgement

Watch the video available at this URL

http://spoken-tutorial.org/What is a Spoken Tutorial

It summarises the Spoken Tutorial project

If you do not have good bandwidth, you can download and watch it

Slide Number 14 The Spoken Tutorial Project Team :

Conducts workshops using spoken tutorials

Gives certificates to those who pass an online test

For more details, please write to

contact@spoken-tutorial.org

Slide number 15 Spoken Tutorial Project is a part of the Talk to a Teacher project

It is supported by the National Mission on Education through ICT, MHRD, Government of India

More information on this Mission is available at this link

http://spoken-tutorial.org/NMEICT-Intro ]

The Script is contributed by ITfC Bangaluru.

This is Madhuri Ganpathi from IIT Bombay signing off Thank you for joining.

Contributors and Content Editors

Madhurig