Grade V, Chapter 5

  

Learn with Hafiza Palwasha


OXFORD (Book 5), KEYBOARD
Computer Science With Application Software (Third Edition).

Solution

Chapter No. 5
KTurtle Loops and Learns!

NEW WORDS
Students should extract new words by themselves from chapter No. 1 and write them on neat copies as vocabulary words. There is no need to memorize these words but students should be able to read and understand these words as I explained and discussed in class.

NEW TERMS AND ABBREVIATIONS
Students should learn these terms and abbreviation. It will be the part of exam.
1.    Constant:
       The unchangeable value is called constant.
2.    Variable:
       The changeable value is called variable. It is like an empty box, it can adjust any value and use that for next operations.
3.    Boolean Values:
       When we have such statements whose values are only represented by 'True', '1', 'Yes' or 'False', '0', 'No' are called Boolean values.
4.    Truth Table:
       It is a table having different possible combinations of variable having values either '0' or '1'. '0' means False and '1' means True.
5.    Controlling Execution:
       As the name indicates that by using these statements we can control the execution of statements. Although program code always execute line by line but with the help of these controlling statements we can control the execution at any line.
6.    If Statements:
       It is a type of controlling statement in which, if the condition for the statement is true then the command will execute, and if the condition for the statement is false then the command will not execute.
7.    If-Else Statements:
       It is a type of controlling statement in which, if the condition for the statement is true then the command will execute, and if the condition for the statement is false then the command will execute the else condition.
8.    Looping Statements:
       It is a type of statement in which the block of code will continuously execute until the condition for statement becomes true.
9.    Repeat Loop:
       It is a type of loop in which the statement will repeat itself till the instructed number.
10.  While Loop:
       It is a type of loop in which the set of statements will continuously execute until the condition for the statement becomes true. So, when the condition for the statement becomes false the execution stops.
11.  For Loop:
       It is a type of loop in which the set of statements will repeatedly execute within the range of values. This range of values and it's interval is defined in the code or by the user.
12.  For Loop with Step:
       It is a type of loop in which the starting number for the range of values in 'for loop' is defined by the user or programmer.
13.  Break Command:
       This command is used to break the loop. Loop statements will continuously execute until the condition satisfied but by using break command we can stop the execution of the loop anytime.
14.  Exit Command:
       This command is used to exit from the program. It finishes the execution of the statements of the program.
15.  Learn Command:
       This command allows you to repeat the set of instructions created by a user or programmer. It even allows us to define the name of these set of instructions and number of times it should execute.


Exercise
Solution

Page No. 67 & 68
Objective Type Questions
Q No. 1: Choose the correct option.
Solution:
a.   The command to get out of the loop.
       ii. break (is correct)
b.   The command to get out of the program.
       ii. exit (is correct)
c.   Which one is not a looping command?
       iv. if (is correct)
d.   The command repeated by giving a number after its name.
       iii. repeat (is correct)
e.   Which one is not a comparison operator?
       i. and (is correct)

Page No. 68
Descriptive Type Questions
Q No. 1: Answer the following.
a. What is a for command? Can you use a variable instead of a number in the for command?
Answer: The for command is a type of loop in which the set of statements will repeatedly execute within the range of values. This range of values and it's interval is defined in the code or by user.
Yes, we can use variable instead of a number in the for command.

b. Give an example of how loops are used in programming. Do you think this is effective?
Answer: Printing table of a number like table of 2 or 3 etc is an example of how loops are used in programming.
Yes, it is effective because it is a type of statement in which the block of code will continuously execute until the condition for the statement becomes true.

c. The Boolean values are very simple. What are the advantages and disadvantages of using these values?
Answer: 

d. On page 57 of your Keyboard Book 5, you learned about the six different 'comparing operators'. This can appear to be quite confusing for some students. Can you give an example to demonstrate the use of comparing operators to help give a better understanding?
Answer: 




e. Differentiate between the REPEAT loop and the WHILE loop. Which do you think is most effective?
Answer: 
I think effectiveness depends on the purpose of implementation. Sometimes REPEAT Loop is more effective compared to WHILE Loop and in some cases WHILE Loop is more effective compared to the REPEAT Loop.

f. When will you use the exit command instead of the break command?
Answer: I will use the exit command when the execution of the code or program has been finished because if I use break command instead of exit it will transfer the control to stop the execution of the statements in the loop.

g. Create a command called 'box' using the Learn command. You can choose the values of your choice?
Answer: Lab work (will be discuss in Computer lab. Students do not have to do this question on neat copies).

Additional Questions
Q: Tell the meaning and explain the following operators:
$a == $b
$a != $b
$a > $b
$a < $b
$a >= $b
$a <= $b
Answer: 

Q: Find the results in True or False for the following statements if $a = 5 and $b = 7
$a == $b
$a != $b
$a > $b
$a < $b
$a >= $b
$a <= $b

Comments

Post a Comment