1 00:00:01 --> 00:00:02 Hello Everybody. 2 00:00:03 --> 00:00:09 Welcome to this tutorial on Control Execution in KTurtle 3 00:00:10 --> 00:00:12 In this tutorial, we will learn 4 00:00:13 --> 00:00:14 'while' loop and 5 00:00:15 --> 00:00:16 'for' loop 6 00:00:17 --> 00:00:31 To record this tutorial I am using,Ubuntu Linux OS Version 12.04 KTurtle version 0.8.1 beta. 7 00:00:32 --> 00:00:37 We assume that you have basic working knowledge of Kturtle. 8 00:00:38 --> 00:00:44 If not, for relevant tutorials, please visit our website. http://spoken-tutorial.org 9 00:00:45 --> 00:00:47 Let's open a new KTurtle Application. 10 00:00:48 --> 00:00:49 Click on Dash home. 11 00:00:50 --> 00:00:52 In the Search bar, type KTurtle. 12 00:00:53 --> 00:00:58 Click on the option.KTurtle Application opens. 13 00:00:59 --> 00:01:04 Let me first explain about what is control execution. 14 00:01:05 --> 00:01:09 Control execution is controlling the flow of a program. 15 00:01:10 --> 00:01:15 Different conditions are used to control program execution. 16 00:01:16 --> 00:01:24 Loop is a block of code executed repeatedly till a certain condition is satisfied. 17 00:01:25 --> 00:01:29 Eg. “while” loop and “for” loop 18 00:01:30 --> 00:01:33 Let's begin the tutorial with “while” loop 19 00:01:34 --> 00:01:41 In the “while” loop, the code inside the loop repeats till boolean evaluates to 'false'. 20 00:01:42 --> 00:01:55 Let me explain the structure of “while” loop. while loop condition { do something with loop increment variable } 21 00:01:56 --> 00:01:58 I already have the code in a text editor. 22 00:01:59 --> 00:02:06 Let me copy the program from text editor and paste it into KTurtle editor 23 00:02:07 --> 00:02:12 Please pause the tutorial here and type the program into your KTurtle editor. 24 00:02:13 --> 00:02:17 Resume the tutorial after typing the program 25 00:02:18 --> 00:02:24 Let me zoom into the program text it may possibly be a little blurred. 26 00:02:25 --> 00:02:26 Let me explain the code. 27 00:02:27 --> 00:02:31 # sign comments a line written after it. 28 00:02:32 --> 00:02:37 It means, this line will not be executed while running the program. 29 00:02:38 --> 00:02:42 reset command sets “Turtle” to its default position. 30 00:02:43 --> 00:02:51 $x=0 initializes the value of variable x to zero. 31 00:02:52 --> 00:03:03 Message in a program is given within double quotes after the keyword message " " “message” command takes “string” as input. 32 00:03:04 --> 00:03:10 It shows a pop-up dialog box containing text from the string. 33 00:03:11 --> 00:03:16 while $x<30 checks the “while” condition. 34 00:03:17 --> 00:03:26 $x=$x+3 increments the value of variable $x by 3 35 00:03:27 --> 00:03:34 fontsize 15 sets the font size used by print command. 36 00:03:35 --> 00:03:41 Fontsize takes number as input, set in pixels. 37 00:03:42 --> 00:03:51 forward 20 commands “Turtle” to move 20 steps forward on the canvas. 38 00:03:52 --> 00:04:00 print $x displays the value of variable x on the canvas. 39 00:04:01 --> 00:04:04 Let me click on the “Run” button to run the program. 40 00:04:05 --> 00:04:10 A message dialog box pops up.Let me click OK. 41 00:04:11 --> 00:04:16 Multiples of 3 from 3 to 30 are displayed on the canvas. 42 00:04:17 --> 00:04:21 “Turtle” moves 20 steps forward on the canvas. 43 00:04:22 --> 00:04:25 Let's next work with “for” loop 44 00:04:26 --> 00:04:28 “for” loop is a counting loop. 45 00:04:29 --> 00:04:33 Every time the code inside “for” loop is executed, 46 00:04:34 --> 00:04:40 variable value is incremented, till it reaches the end value. 47 00:04:41 --> 00:04:45 Let me explain the structure of “for” loop. 48 00:04:46 --> 00:04:54 for variable = start number to end number { Statement} 49 00:04:55 --> 00:04:58 Let me clear the current program. 50 00:04:59 --> 00:05:04 Let me typeclearcommand and run to clean the canvas. 51 00:05:05 --> 00:05:13 Let me copy the program from text editor and paste it into KTurtle editor 52 00:05:14 --> 00:05:19 Please pause the tutorial here and type the program into your KTurtle editor. 53 00:05:20 --> 00:05:24 Resume the tutorial after typing the program. 54 00:05:25 --> 00:05:31 Let me zoom into the program text it may possibly be a little blurred. 55 00:05:32 --> 00:05:33 Let me explain the program. 56 00:05:34 --> 00:05:38 # sign comments a line written after it. 57 00:05:39 --> 00:05:43 reset command sets “Turtle” to its default position. 58 00:05:44 --> 00:05:51 $r=0 initializes the value of variable r to zero. 59 00:05:52 --> 00:06:00 for $x= 1 to 15 checks “for” condition from 1 to 15. 60 00:06:01 --> 00:06:11 $r=$x*($x+1)/2 calculates the value of variable r. 61 00:06:12 --> 00:06:18 fontsize 18 sets the font size used by print command. 62 00:06:19 --> 00:06:25 print $r displays the value of variable r on the canvas 63 00:06:26 --> 00:06:33 forward 15 commands Turtleto moves 15 steps forward on the canvas. 64 00:06:34 --> 00:06:47 go 10,250 commands Turtle to go 10 pixels from left of canvas and 250 pixels from top of canvas. 65 00:06:48 --> 00:06:53 “Turtle” displays all print commands without any time gap. 66 00:06:54 --> 00:07:03 “Wait 2” command makes Turtle to “wait” for 2 seconds before executing next command. 67 00:07:04 --> 00:07:12 “print” command displays the “string” within double quotes and also displays variable $r. 68 00:07:13 --> 00:07:16 Let me click on the “ Run” button to run the program. 69 00:07:17 --> 00:07:26 A series of sum of first 15 natural numbers and sum of first 15 natural numbers is displayed on the canvas. 70 00:07:27 --> 00:07:31 Turtle moves 15 steps forward on the canvas. 71 00:07:32 --> 00:07:36 With this we come to the end of this tutorial. 72 00:07:37 --> 00:07:39 Let us summarize. 73 00:07:40 --> 00:07:43 In this tutorial we have learned to use, 74 00:07:44 --> 00:07:46 “while”' loop and “for” loop 75 00:07:47 --> 00:07:53 As an assignment I would like you to write programs to evaluate 76 00:07:54 --> 00:07:57 Multiples of 2 using “while” loop 77 00:07:58 --> 00:08:02 Multiplication table of a number using “for” loop 78 00:08:03 --> 00:08:07 Watch the video available at this URLhttp://spoken-tutorial.org/What is a Spoken Tutorial 79 00:08:08 --> 00:08:11 It summarises the Spoken Tutorial project 80 00:08:12 --> 00:08:16 If you do not have good bandwidth, you can download and watch it 81 00:08:17 --> 00:08:19 The Spoken Tutorial Project Team : 82 00:08:20 --> 00:08:22 Conducts workshops using spoken tutorials 83 00:08:23 --> 00:08:26 Gives certificates to those who pass an online test 84 00:08:27 --> 00:08:35 For more details, please write to contact@spoken-tutorial.org 85 00:08:36 --> 00:08:40 Spoken Tutorial Project is a part of the Talk to a Teacher project 86 00:08:41 --> 00:08:47 It is supported by the National Mission on Education through ICT, MHRD, Government of India 87 00:08:48 --> 00:08:53 More information on this Mission is available at this link http://spoken-tutorial.org/NMEICT-Intro ] 88 00:08:54 --> 00:08:59 This is Madhuri Ganpathi from IIT Bombay signing off Thank you for joining.