CBSE Coding Class 6 Solution Student Handbook Chapter 5 Loops Using Block Coding

CBSE Coding Class 6 Solution – Loops Using Block Coding

CBSE Coding Class 6 Solution Student Handbook Chapter 5 Loops Using Block Coding all Questions and Answers Solution by Coding Teacher. Net Ex. Here provided all Coding Solution for Class 6.

1.) The if statement is used to execute some code if a statement true.

Answer : True

Reason: The if statement is used to check if the condition is true.

2.) An else statement should always be after an if statement which executes when the code is false.

Answer : True

Reason: Else statement is used to check if the condition is False.

3.) A while loop statement repeatedly executes a statement as long as the condition remains true.

Answer : True

Reason: The While loop can execute a set of commands till the condition is true While Loops are also called conditional loops.

4.) Without a statement that eventually evaluates the while loop condition to false, the loop will continue indefinitely.

Answer : True

Reason: while loop will run untill the specific conditions are met.

5.) A for loop executes for a specific number of times.

Answer : True

Reason: For loop is needed for iterating over a sequence. A for loop executes for a specific number of times.

6.) A continue statement is used to skip all the remaining statements in the loop and moves the control back to the top of the loop.

Answer : True

Reason: In continue statement , the control skips the execution of remaining statements inside the loop for the current iteration and jumps to the beginning of the loop for the next iteration

7.) When a break statement is encountered inside a loop, the loop is immediately terminated, and the program execution moves on to the next statement in the loop.

Answer : True

Reason: Break statement is required when you want to break out of a loop early when a condition is met.

8.) Doing something over and over again or repeating code is called as

Answer : loop

Reason: Loops provide the facility to execute a block of code repetitively, based on a condition.

9.) Which is the correct operator for equality testing?

Answer : ==

Reason: == is used to compare left and right side of a condition.

10.) What is the output of the below pseudocode?

count = 0;

sum = 0;

while (count < 5)

{

sum = sum + count;

count = count + 1;

}

print sum;

Answer : 5

Reason: while loop runs untill value of count is more then 5 and it will

keep adding in the sum variable, therefore sum=5.

11.) Which letter won’t print while running the below pseudocode?

for letter in “coding”:

if letter == “i”:

break

print(letter)

print(“End”)

Answer : ‘n’

Reason: The control skips the lines after the break statement and

executes the first statement outside the loop

12) Which letter won’t print while running the below pseudocode?

for letter in “coding”:

if letter == “i”:

continue

print(letter)

print(“End”)

Answer : ‘i’

Reason: As soon as the continue statement is encountered, the lines

below the continue statement are skipped.

Short Answer Questions

1.) Define loops and nested loops in programming

Answer : A loop is an algorithm which executes a block of code multiple  times till the time a specified condition is met. And When there is a loop inside another loop, it is called a nested loop.

2.) What is an exit criterion?

Answer : Exit criteria is defined as a condition that must be met before completing a specific task. It is a set of conditions that must exist before you can declare a program to be complete.

3.) How do we increment loops?

Answer : Execution of loops is based on iterations. To run a block of code in a loop, one needs to set a condition and set its number of iterations. Each time the condition is true, and the block of code executes once, it is counted to be one iteration. Before moving to the next iteration, one needs to increase the count of iteration to two. This is called as incrementing a loop.

Example – If you need to print numbers 0 to 4, you will execute a block of code with Print statement in five iterations. With each passing iteration, you will increment the count by one.

4.) What is a break statement?

Answer : The break statement modifies the normal flow of execution while it terminates the existing loop and continues execution of the statement following that loop. Break statement is required as sometimes you want to break out of a loop early when a condition is met.

5.) What is a continue statement?

Answer : Whenever a program comes across a continue statement, the control skips the execution of remaining statements inside the loop for the current iteration and jumps to the beginning of the loop for the next iteration. If the loop’s condition is still true, it enters the loop again, else the control will be moved to the statement immediately after the loop. This is somewhat similar to break statement and is used when we want to force the next iteration and skip some lines of code within the loop.

Higher Order Thinking Skills (HOTS)

Now that you know the concept of Nested Loops. Using Arcade Make Code platform create an example for nested loops.

Answer:

Applied Project

Write a program using loops that ask the user to enter an even number. If the number entered does not display an appropriate message and asks them to enter a number again. Do not stop until an even number is entered. Print a congratulatory message at end.

Answer :

while True:

a=int (input(“Enter an even number : “))

if a%2!=0:

print (“Entered number is not even!”)

else:

print (“Congratulations! Entered number is Even”)

break

Updated: March 2, 2022 — 6:52 pm

Leave a Reply

Your email address will not be published. Required fields are marked *