Difference between revisions of "KTurtle/C3/Question-Glues/English"

From Script | Spoken-Tutorial
Jump to: navigation, search
 
(9 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
Title of the tutorial: Question-Glues
 +
 +
Author: Madhuri Ganapathi
 +
 +
Key words:  Question glues, 'and', 'not', 'or', if-else, message, Video tutorial
 +
 +
 
{|border =1
 
{|border =1
 
!Visual Cue
 
!Visual Cue
Line 4: Line 11:
 
|-
 
|-
 
||Slide Number 1
 
||Slide Number 1
||
+
||Hello and
  
Hello everybody.
+
Welcome to the spoken tutorial on '''Question Glues''' in '''KTurtle'''.
||Welcome to this tutorial on '''Question Glues''' in '''KTurtle'''.
+
 
|-
 
|-
 
||Slide  Number 2
 
||Slide  Number 2
Line 57: Line 63:
 
In the '''Search bar''' type KTurtle
 
In the '''Search bar''' type KTurtle
 
||Let's open a new''' KTurtle''' Application.
 
||Let's open a new''' KTurtle''' Application.
Click on  '''Dash  home'''. The '''Search bar''' appears.
+
Click on  '''Dash  home'''.  
  
 
In the Search bar, type KTurtle.
 
In the Search bar, type KTurtle.
  
Click on the KTurtle option.
+
Click on the option.
 
|-
 
|-
 
||
 
||
||Let's begin the tutorial with the glue word and.
+
||Let's begin the tutorial with the glue word '''and'''.
 
|-
 
|-
 
||
 
||
Line 73: Line 79:
 
'''reset'''  
 
'''reset'''  
  
'''message"Triangle's Inequality: In a triangle, sum of the lengths of any two sides is greater than the third side "'''  
+
'''message"Triangle's Inequality: In a triangle,'''
 +
 
 +
'''sum of the lengths of any two sides is greater than the third side "'''  
  
 
'''$a =ask"enter length of side AB and click OK"'''  
 
'''$a =ask"enter length of side AB and click OK"'''  
Line 82: Line 90:
  
 
'''#if condition below checks if sum of lengths of any two sides is greater than third side'''  
 
'''#if condition below checks if sum of lengths of any two sides is greater than third side'''  
 +
 
''' if(($a+$b>$c) and ($b+$c>$a) and ($c+$a>$b)){'''  
 
''' if(($a+$b>$c) and ($b+$c>$a) and ($c+$a>$b)){'''  
  
Line 100: Line 109:
 
''' print" Not a scalene triangle" ''' }  
 
''' print" Not a scalene triangle" ''' }  
 
}  
 
}  
 +
 
'''else'''{  
 
'''else'''{  
  
Line 111: Line 121:
  
  
Resume the tutorial after typing the program.
+
Resume the tutorial after typing the program.
 
|-
 
|-
 
||Zoom text
 
||Zoom text
 
||Let me zoom into the program text.  
 
||Let me zoom into the program text.  
 +
 
It may possibly be a little blurred.
 
It may possibly be a little blurred.
 
|-
 
|-
Line 123: Line 134:
 
||'''reset''' command sets '''Turtle''' to its''' default''' position.
 
||'''reset''' command sets '''Turtle''' to its''' default''' position.
 
|-
 
|-
||Highlight '''message"In a triangle sum of the lengths any two sides is greater than third side "'''  
+
||Highlight '''message"In a triangle'''
||Message in a program is given within double quotes after the keyword  '''message " " '''  
+
''' sum of the lengths any two sides is greater than third side "'''  
 +
||Message in a program is given within double quotes after the keyword  '''message " " '''.
  
 
'''“message”''' command takes '''“string”''' as input.  
 
'''“message”''' command takes '''“string”''' as input.  
Line 147: Line 159:
 
    
 
    
 
||'''if(($a !=$b) and ($b != $c) and ($c != $a))'''{  
 
||'''if(($a !=$b) and ($b != $c) and ($c != $a))'''{  
 +
checks the "if" condition
 
when ''''if'''' condition above is true, control moves into '''nested if''' block.
 
when ''''if'''' condition above is true, control moves into '''nested if''' block.
  
Line 155: Line 168:
 
|-
 
|-
 
||Highlight '''go 10,100'''  
 
||Highlight '''go 10,100'''  
||'''go 10,100''' commands  Turtle to go to 10 pixels from left of canvas and 100 pixels from top of canvas.
+
||'''go 10,100''' commands  Turtle to go 10 pixels from left of canvas and 100 pixels from top of canvas.
 
|-
 
|-
 
||Highlight '''print "A scalene triangle"'''
 
||Highlight '''print "A scalene triangle"'''
||'''print''' command displays the string after checking the if condition.
+
||'''print''' command displays the string after checking the '''if''' condition.
 
|-
 
|-
 
||'''else''' {  
 
||'''else''' {  
||'''else''' command checks '''else''' condition, when if condition in the block is false
+
||'''else''' command checks '''else''' condition, when '''if''' condition in the block is false
 
|-
 
|-
 
||Highlight '''print" Not a scalene triangle"'''  
 
||Highlight '''print" Not a scalene triangle"'''  
Line 172: Line 185:
 
||Highlight '''print"Does not satisfy triangle's inequality "'''
 
||Highlight '''print"Does not satisfy triangle's inequality "'''
 
||'''print''' command displays the string after checking the else condition.
 
||'''print''' command displays the string after checking the else condition.
 +
|-
 +
||
 +
||I will the code to check all the conditions.
 
|-
 
|-
 
||'''Run the program
 
||'''Run the program
Line 181: Line 197:
 
|-
 
|-
 
||'''Point to the result'''
 
||'''Point to the result'''
||Enter 5 for 'length of side AB' and click OK
+
||Let's enter 5 for 'length of AB' and click OK
  
enter 8 for 'length of side BC' and click OK
+
8 for 'length of BC' and click OK
  
enter 9 for 'length of side AC' and click OK
+
9 for 'length of AC' and click OK
  
 
'''“A scalene triangle” is displayed on the canvas.'''
 
'''“A scalene triangle” is displayed on the canvas.'''
 
|-
 
|-
 
||'''Run the program'''
 
||'''Run the program'''
||Let me run the code again
+
||Let's run again
 
|-
 
|-
 
||'''Point to the dialog box.'''
 
||'''Point to the dialog box.'''
Line 198: Line 214:
 
|-
 
|-
 
||'''Point to the result'''
 
||'''Point to the result'''
||Enter 5 for 'AB' and click OK
+
|| Let's enter 5 for length of'AB' and click OK
  
6 for 'BC' and click OK
+
6 for length of 'BC' and click OK
  
6 for 'AC' and click OK
+
6 for length of 'AC' and click OK
  
'''“Triangle is not a scalene triangle”''' is displayed on the canvas.
+
'''“Not a scalene triangle”''' is displayed on the canvas.
 
|-
 
|-
 
||'''Run the program'''
 
||'''Run the program'''
||Let's run the code again.
+
||Let's run again to check default condition.
 
|-
 
|-
 +
 
||'''Point to the result'''
 
||'''Point to the result'''
||Enter 1 for 'AB' and click OK
 
  
1 for 'BC' and click OK
+
||Meesgae dialog box pops up. Let me click Ok
 +
Let's enter 1 for length of 'AB' and click OK
  
2 for 'AC' and click OK
+
1 for length of 'BC' and click OK
 +
 
 +
2 for length of 'AC' and click OK
  
 
'''" Does not satisfy triangle's inequality "''' is displayed on canvas.
 
'''" Does not satisfy triangle's inequality "''' is displayed on canvas.
 
|-
 
|-
 
||
 
||
||Next let's work with the glue word '''not.'''  
+
||Let's now clear the program. Let me type '''clear''' command and run '''clear''' command, cleans the canvas
 +
|-
 +
||
 +
||Next let's work with '''not''' condition.
 
|-
 
|-
 
||'''#program checks triangle is equilateral or not'''
 
||'''#program checks triangle is equilateral or not'''
Line 235: Line 257:
 
'''print "Triangle is not equilateral"'''  
 
'''print "Triangle is not equilateral"'''  
 
}  
 
}  
 +
 
'''else'''  
 
'''else'''  
 +
 
{  
 
{  
 
'''print "Triangle is equilateral"'''  
 
'''print "Triangle is equilateral"'''  
Line 242: Line 266:
  
 
'''repeat 3{turnright 120 forward 100}}'''
 
'''repeat 3{turnright 120 forward 100}}'''
||Let me copy the code from the text editor and paste it into KTurtle editor.  
+
||Let me copy the program from the text editor and paste it into the KTurtle editor.  
  
  
Line 251: Line 275:
 
Resume the tutorial after typing  the program.
 
Resume the tutorial after typing  the program.
 
|-
 
|-
Zoom text
+
||Zoom text
 
||Let me zoom into the program text and explain the program
 
||Let me zoom into the program text and explain the program
 
|-
 
|-
 
||Highlight '''reset'''
 
||Highlight '''reset'''
||'''reset''' command sets '''Turtle''' to its '''default''' position.
+
||'''reset''' command sets '''Turtle''' to'''default''' position.
 
|-
 
|-
 
||Highlight '''$a, $b''' and '''$c'''
 
||Highlight '''$a, $b''' and '''$c'''
Line 262: Line 286:
 
||Highlight  '''if not (($a==$b) and ($b==$c) and ($c==$a))'''{
 
||Highlight  '''if not (($a==$b) and ($b==$c) and ($c==$a))'''{
 
||'''if not (($a==$b) and ($b==$c) and ($c==$a))'''{
 
||'''if not (($a==$b) and ($b==$c) and ($c==$a))'''{
 +
checks the '''if not''' condition
  
 
'''not''' is a special question glue-word. It inverses the logical state of its operand.  
 
'''not''' is a special question glue-word. It inverses the logical state of its operand.  
Line 282: Line 307:
 
|-
 
|-
 
||Highlight '''repeat 3{turnright 120 forward 100}'''
 
||Highlight '''repeat 3{turnright 120 forward 100}'''
||'''repeat 3{turnright 120 forward 100}''' command draws an equilateral triangle on the canvas
+
||'''repeat 3{turnright 120 forward 100}''' commands Turtle to draws an equilateral triangle on the canvas
 +
|-
 +
||Run the program
 +
||Let me run the program to check all the conditions
 +
 
 
|-
 
|-
 
||'''Run the program'''
 
||'''Run the program'''
||Press F5 key run the code.
+
||Press F5 key to run the code.
  
Enter  6 for AB and click OK  
+
Enter  6 for length of AB and click OK  
  
5 BC for and click OK
+
5 BC for length of and click OK
  
7 for AC and click OK
+
7 for AC length of and click OK
  
 
'''“Triangle is not equilateral”''' is displayed on the canvas.  
 
'''“Triangle is not equilateral”''' is displayed on the canvas.  
 
|-
 
|-
 
||'''Run the program'''
 
||'''Run the program'''
||Press F5 key to run the code.
+
||Let's run again
  
Enter 4 for AB and click OK
+
Enter 5 for length of AB and click OK
  
4 for BC and click OK
+
5 for BC length of and click OK
  
4 for AC and click OK
+
5 for AC length of and click OK
  
'''“Triangle is equilateral”''' is displayed on the canvas.
+
'''“Triangle is equilateral”''' is displayed on the canvas. An equilateral triangle is drawn on the canvas.
 
|-
 
|-
 
||
 
||
Line 330: Line 359:
  
 
'''Syntax of if or condition'''
 
'''Syntax of if or condition'''
||if ((condition)or(condition)or(condition)){   
+
 
 +
if ((condition)or(condition)or(condition)){   
  
 
//do something
 
//do something

Latest revision as of 15:54, 18 December 2013

Title of the tutorial: Question-Glues

Author: Madhuri Ganapathi

Key words: Question glues, 'and', 'not', 'or', if-else, message, Video tutorial


Visual Cue Narration
Slide Number 1 Hello and

Welcome to the spoken tutorial on Question Glues in KTurtle.

Slide Number 2

Learning Objectives

In this tutorial, we will learn the following question glues
  • and
  • not
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 and

“if-else” statement in KTurtle

If not,

for relevant tutorials, please visit our website.

http://spoken-tutorial.org

Before proceeding, let me explain about question glue words.
Slide Number 5

Question Glues

Question glue words enable us to glue small questions into one big question.

“and”, “or” and “not” are some glue-words.

Glue-words are used together with if-else conditions.

Switch to KTurtle Application

Dash home >>Search bar appears>>

In the Search bar type KTurtle

Let's open a new KTurtle Application.

Click on Dash home.

In the Search bar, type KTurtle.

Click on the option.

Let's begin the tutorial with the glue word and.
I already have a program in a text editor.
#program to check triangle is scalene or not

reset

message"Triangle's Inequality: In a triangle,

sum of the lengths of any two sides is greater than the third side "

$a =ask"enter length of side AB and click OK"

$b =ask"enter length of side BC and click OK"

$c=ask"enter length of side AC and click OK"

#if condition below checks if sum of lengths of any two sides is greater than third side

if(($a+$b>$c) and ($b+$c>$a) and ($c+$a>$b)){

#if condition below checks sides of triangle are not equal

if(($a !=$b) and ($b != $c) and ($c != $a)) {

fontsize 18 

go 10,100 
 

print "A scalene triangle"

 } 

else {

go 10,100

print" Not a scalene triangle" } }

else{

go 10,100

print"Does not satisfy triangle's inequality " }

Let me copy the code from the text editor and paste it into KTurtle editor.

Please pause the tutorial here and type the program into your KTurtle editor.


Resume the tutorial after typing the program.

Zoom text Let me zoom into the program text.

It may possibly be a little blurred.

Let's look the code.
Highlight reset reset command sets Turtle to its default position.
Highlight message"In a triangle

sum of the lengths any two sides is greater than third side "

Message in a program is given within double quotes after the keyword message " " .

“message” command takes “string” as input.

It shows a pop-up dialog box containing text from the string and also generates a beep for non null strings.

Highlight $a, $b and $c $a, $b and $c are variables that store user input.
Highlight ask" " “ask” command prompts for user input to be stored in variables.
Highlight if(($a+$b>$c) and ($b+$c>$a) and ($c+$a>$b) if(($a+$b>$c) and ($b+$c>$a) and ($c+$a>$b),

checks the “if” condition.

When the two questions glued with “and” are true, result is true.

Highlight if(($a !=$b) and ($b != $c) and ($c != $a)) { if(($a !=$b) and ($b != $c) and ($c != $a)){

checks the "if" condition when 'if' condition above is true, control moves into nested if block.

It checks whether sides of triangle are unequal.

Highlight fontsize 18 fontsize 18 sets the font size used by print command.
Highlight go 10,100 go 10,100 commands Turtle to go 10 pixels from left of canvas and 100 pixels from top of canvas.
Highlight print "A scalene triangle" print command displays the string after checking the if condition.
else { else command checks else condition, when if condition in the block is false
Highlight print" Not a scalene triangle" print command displays the string after checking the else condition.
Highlight else else command checks the final condition.

else is checked only when above conditions are false.

Highlight print"Does not satisfy triangle's inequality " print command displays the string after checking the else condition.
I will the code to check all the conditions.
Run the program Let's click on the Run button to run the code.
Point to the dialog box. A message dialog box pops up.

Let me click OK.

Point to the result Let's enter 5 for 'length of AB' and click OK
8 for 'length of BC' and click OK
9 for 'length of AC' and click OK

“A scalene triangle” is displayed on the canvas.

Run the program Let's run again
Point to the dialog box. A message dialog box pops up again.

Let me click OK.

Point to the result Let's enter 5 for length of'AB' and click OK

6 for length of 'BC' and click OK

6 for length of 'AC' and click OK

“Not a scalene triangle” is displayed on the canvas.

Run the program Let's run again to check default condition.
Point to the result Meesgae dialog box pops up. Let me click Ok

Let's enter 1 for length of 'AB' and click OK

1 for length of 'BC' and click OK

2 for length of 'AC' and click OK

" Does not satisfy triangle's inequality " is displayed on canvas.

Let's now clear the program. Let me type clear command and run clear command, cleans the canvas
Next let's work with not condition.
#program checks triangle is equilateral or not

reset

$a=ask"enter length of AB and click OK"

$b=ask"enter length of BC and click OK"

$c=ask"enter length of AC and click OK"

if not(($a==$b)and($b==$c)and($c==$a)){

print "Triangle is not equilateral" }

else

{ print "Triangle is equilateral"

go 100,100

repeat 3{turnright 120 forward 100}}

Let me copy the program from the text editor and paste it into the KTurtle editor.


Please pause the tutorial here and type the program into your KTurtle editor.


Resume the tutorial after typing the program.

Zoom text Let me zoom into the program text and explain the program
Highlight reset reset command sets Turtle todefault position.
Highlight $a, $b and $c $a, $b and $c are variables that store user input.
Highlight if not (($a==$b) and ($b==$c) and ($c==$a)){ if not (($a==$b) and ($b==$c) and ($c==$a)){

checks the if not condition

not is a special question glue-word. It inverses the logical state of its operand.

e.g. If the given condition is true, not makes it false.

And when the condition is false the output will be true.

Highlight print "Triangle is not equilateral" print command displays the string after checking the if not condition.
Highlight else else command is executed when if condition is false.
Highlight print "Triangle is equilateral" print command displays the string after checking the else condition.
Highlight go 100,100 go 100,100 commands Turtle to go 100 pixels from left of canvas and 100 pixels from top of canvas
Highlight repeat 3{turnright 120 forward 100} repeat 3{turnright 120 forward 100} commands Turtle to draws an equilateral triangle on the canvas
Run the program Let me run the program to check all the conditions
Run the program Press F5 key to run the code.

Enter 6 for length of AB and click OK

5 BC for length of and click OK

7 for AC length of and click OK

“Triangle is not equilateral” is displayed on the canvas.

Run the program Let's run again

Enter 5 for length of AB and click OK

5 for BC length of and click OK

5 for AC length of and click OK

“Triangle is equilateral” is displayed on the canvas. An equilateral triangle is drawn on the canvas.

With this we come to the end of this tutorial.

Let's summarize.

Slide Number 6

Summary

In this tutorial we have learnt, the question glues
  • and
  • not
Slide Number 7

Assignment

As an assignment, I would like you to write program to determine

Angle concept for a right angled triangle using question glue “or”

Slide Number 8

Syntax of if or condition

if ((condition)or(condition)or(condition)){

//do something }

else {

//do something }

Structure of if or condition is:

if within brackets condition or within brackets condition or within brackets condition.

Within curly brackets do something.

else within curly brackets do something.

Slide number 8

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 9 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 10 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 ]

This is Madhuri Ganpathi from IIT Bombay signing off.

Thank you for joining

Contributors and Content Editors

Madhurig