Difference between revisions of "KTurtle/C3/Programming-Concepts/English"
Line 186: | Line 186: | ||
|| | || | ||
Let me zoom the program text. | Let me zoom the program text. | ||
− | + | || | |
− | Explain the program. | + | |- |
− | Highlight # | + | ||Explain the program. |
− | # sign comments a line written after it. | + | |- |
− | Highlight reset | + | ||Highlight # |
− | reset command sets Turtle to default position. | + | ||# sign comments a line written after it. |
− | Highlight $i and $n | + | |- |
− | $i and $n are variables to store user input. | + | ||Highlight reset |
− | Highlight ask | + | ||reset command sets Turtle to default position. |
− | “ask” command asks for user input to be stored in variables. | + | |- |
− | Highlight fontsize 28 | + | ||Highlight $i and $n |
− | fontsize 28 sets the font size used by print. | + | ||$i and $n are variables to store user input. |
+ | |- | ||
+ | ||Highlight ask | ||
+ | ||“ask” command asks for user input to be stored in variables. | ||
+ | |- | ||
+ | ||Highlight fontsize 28 | ||
+ | ||fontsize 28 sets the font size used by print. | ||
Fontsize takes number as input, set in pixels. | Fontsize takes number as input, set in pixels. | ||
− | Highlight print ($i^$n) | + | |- |
− | print ($i^$n) calculates & prints nth power of a number. | + | ||Highlight print ($i^$n) |
− | Highlight spritehide | + | ||print ($i^$n) calculates & prints nth power of a number. |
− | spritehide hides Turtle from canvas. | + | |- |
− | Run the program code | + | ||Highlight spritehide |
− | Let's run the program. | + | ||spritehide hides Turtle from canvas. |
+ | |- | ||
+ | ||Run the program code | ||
+ | ||Let's run the program. | ||
Let's enter '5' for i, and click OK | Let's enter '5' for i, and click OK | ||
Let's enter '4' for n, and click OK | Let's enter '4' for n, and click OK | ||
5^4=625 is displayed on canvas. | 5^4=625 is displayed on canvas. | ||
− | + | |- | |
Next, let's use inbuilt “sqrt” function in a program to find square root of a number. | Next, let's use inbuilt “sqrt” function in a program to find square root of a number. | ||
#Program finds square root of a positive number | #Program finds square root of a positive number |
Revision as of 18:10, 24 December 2012
Visual Cue | Narration |
---|---|
Slide Number 1 | Hello Everybody.
Welcome to this tutorial on Programming concepts in KTurtle. |
Slide Number 2
Learning Objectives |
In this tutorial, we will learn how to
|
Slide Number 3
System Requirement
|
To record this tutorial, I am using,
Ubuntu Linux OS Version 11.10. 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, |
Before proceeding, we will discuss some basic information about KTurtle. | |
Slide Number 5
Sprite |
"Turtle" displayed on the canvas is called "sprite".
"Sprite" is a small image that moves around the screen. e.g. Cursor is a sprite. |
Slide Number 6
sprite Commands |
"spritehide" command hides Turtle from canvas.
"spriteshow" command shows Turtle if it is hidden. "clear" command cleans all drawings from canvas. |
Slide Number 7
Symbols |
In KTurtle,
"$ " sign is a container of variables. "*"(asterisk) is used for multiplication of two numbers. "^"(caret) raises the power of a number. "#"(hash) sign comments a line written after it. "sqrt" is an inbuilt function to find square root of a number. |
Switch to Kturtle Application
Dash home >>Media Apps>>Under Type >>Education>>KTurtle |
Let's open new KTurtle Application
Click on Dash home >> Media Apps. Under Type, Choose Education and KTurtle. KTurtle application opens. |
Press CTRL+ALT+T >> open the terminal >>type kturtle >>press enter to open | We can also open KTurtle Application from the terminal.
Press CTRL+ALT+T simultaneously to open the terminal. Type KTurtle and press enter, KTurtle Application opens. |
Let me type and explain the program code. | |
Let me zoom the program text, it may possibly be a little blurred. | |
#program to find square of a number
Highlight # |
#program to find square of a number. Press enter
"#" sign comments a line written after it. This means, this line will not be executed while running the program. Press enter. |
reset
Highlight reset |
reset
reset command sets Turtle to default position. Press enter. |
$i= ask "enter any number for i and click OK"
Highlight $i |
$i= ask within double quotes enter any number for i and click OK. "$i" is a variable to store user input. |
Highlight "ask" | “ask” command asks for user input to be stored in variable
press enter |
fontsize 28
Highlight fontsize 28 |
“fontsize” space 28 press enter.
fontsize 28 sets the font size used by print. Fontsize takes number as input, set in pixels. |
print $i*$i
Highlight print $i*$i |
print $i*$i
print $i*$i calculates and prints square of a number. press enter. |
spritehide
Highlight spritehide |
spritehide
spritehide hides Turtle from canvas. |
Run the program code | Let us Run the program now.
Click on Run button on the toolbar to start execution of the code in the editor. It shows a list of execution speeds. Full speed(no highlighting and inspector) Full speed, slow, slower, slowest and step-by-step. |
Enter '15' for i
Square of 15 =225 |
Let me run the code at slow speed.
An "input bar" appears let's enter 15 for i and click OK square of '15' = '225' is displayed on the canvas. |
Let's now learn to find nth power of a number through a program. | I already have program in a text editor. |
#Program evaluates nth power of a number
reset $i= ask "enter number for i and click OK" $n=ask "enter number for n and click OK" fontsize 28 print ($i^$n) spritehide |
Let me copy the code from editor and paste it into KTurtle editor.
|
Let me zoom the program text. |
|
Explain the program. | |
Highlight # | # sign comments a line written after it. |
Highlight reset | reset command sets Turtle to default position. |
Highlight $i and $n | $i and $n are variables to store user input. |
Highlight ask | “ask” command asks for user input to be stored in variables. |
Highlight fontsize 28 | fontsize 28 sets the font size used by print.
Fontsize takes number as input, set in pixels. |
Highlight print ($i^$n) | print ($i^$n) calculates & prints nth power of a number. |
Highlight spritehide | spritehide hides Turtle from canvas. |
Run the program code | Let's run the program.
Let's enter '5' for i, and click OK Let's enter '4' for n, and click OK 5^4=625 is displayed on canvas. |