Professional Documents
Culture Documents
Operators Result
$a == $b False
$a != $b True
$a > $b False
$a < $b True
$a >= $b False
$a <= $b True
e. The REPEAT loop is repeated as many times as the given number whereas the WHILE loop is repeated
till the Boolean value is true. Once the Boolean value becomes false, the execution of the program
stops.
f. I will use the Exit command when I want to finish executing the program, as opposed to the Break
command which will only go on to stop the current loop and transfer control to the statement
following the loop.
g A sample command is given below.
learn box $x {
repeat 36 {
forward $x
turnleft 10 } }
For example,
$a = ask (“Enter your age”)
if $a >= 18 {
message “You are eligible to vote”
}
else {
message “You are not eligible to vote”
}
1
TEACHER’S RESOURCE 5
APPLICATION-BASED QUESTIONS
iii.
c. i. ii. iii.
IN THE LAB
1. reset
$a = ask ( “Enter a number” )
if $a < 5 {message “The number is less than 5”}
if $a > 5 {message “The number is greater than 5”}
if $a == 5 {message “The number is equal to 5”}
exit
1
5 TEACHER’S RESOURCE
exit
2. a. reset b. reset
$a = 1 for $a = 1 to 10 step 2{
while $a <= 10 { print $a
print $a forward 10 }
forward 10
$a = $a + 2 }
3. a. reset b. reset
$a = ask (“Enter a number”) $a = ask (“Enter a number”)
$i = 1 for $i = 1 to 10 {
print $a * $i
forward 10 }
forward 10
$i = $i + 1
}
4. Create a command square using the learn command :
learn square $length {
repeat 4 { fw $length tr 90 }
}
a. Drawing a square of size 50 points: square 50
b. Drawing a square of side 90 points: square 90
GROUP PROJECT
Ask the children to make different shapes with KTurtle. They can combine the shapes to make a new school
logo.
Triangle (3 sides): repeat 3{fw 100 tr 120}
Square (4 sides): repeat 4{fw 100 tr 90}
Pentagon (5 sides): repeat 5{fw 100 tr 72}
Hexagon (6 sides): repeat 6{fw 100 tr 60}
Septagon (7 sides): repeat 7{fw 80 tr 51}
Octagon (8 sides): repeat 8{fw 70 tr 45}
A full circle is drawn with 360 degrees and a semicircle with 180 degrees.
A circle can be drawn using the repeat command, i.e. repeat 360 times.