CBSE Coding Class 6 Solution – Control and Conditionals
CBSE Coding Class 6 Solution Student Handbook Chapter 4 Control and Conditionals all Questions and Answers Solution by Coding Teacher. Net Ex. Here provided all Coding Solution for Class 6.
Questions
1.)Today is Tuesday, and the time is 4 PM. Is the library open now?
Answer : No
Reason: According to above flowchart, Library is open on monday .
2.) Today is Monday and the time being 10.30 AM. Is the library open now?
Answer : Yes
Reason: Library is open on monday between 10 am to 12 pm.
3.) Today is Friday, and the time is 12 PM. Is the library open now?
Answer : No
Reason: Library is closed on friday.
4.) Today is Wednesday, and the time is 10.30 AM. Is the library Open now?
Answer : No
Reason: Library is open on wednesday between 3 pm to 5 pm only.
5.) Today is Wednesday and the time is 3.30 PM. Is the library open now?
Answer : Yes
Reason: Library is open on Wednesday between 3 pm to 5 pm.
Objective Type Questions
Using the below pseudocode answer the following questions (Question 1-4):
IF (Day == Saturday OR Day == Sunday
IF (Time >= 12 AM AND Time <=8 PM))
THEN
Holiday
ELSE
School Day
ELSE
School Day
END
1.) Today is Monday and the time being 11.30 AM. Is today a school day?
Answer : True
Reason: School is open from Monday to Friday.
2.) Today is Saturday and the time being 1.30 AM. Is today a Holiday?
Answer : True
Reason: On saturday the school is open between 12 am to 8 pm.
3.) Today is Wednesday and the time is 5.30 AM. Is today a school day?
Answer : True
Reason: School is open on Wednesday.
4.) Today is Sunday and the time being 09.30 PM. Is today a Holiday?
Answer : False
Reason: school is closed after 8pm on sunday,So today is holiday.
5.) Logical operators can be used to make decisions in our code
Answer : True
Answer: We can use logical operators for decision making.
6.) Which operator is used if the statement evaluates true only if both the expressions are true
Answer : AND
Reason: If all the conditions are true, the AND operator returns TRUE.
7.) Which operator is used if the statement evaluates true only if only one of the expressions is true
Answer : OR
Reason: The OR operator is used to determine if either one of two or more conditions is TRUE.
8.) Which of the following operator is used to reverse or negate a condition
Answer : Not
Reason: We use the NOT operator to reverse or negate a condition. If the condition is true, NOT will return false and vice-versa.
9.) Your father’s age is 35. In which category will he fall?
Answer : Adult
Reason: Your Father’s age is above 19 So he’s an adult.
10.) Your sister’s age is 19. In which category will she fall?
Answer : Teenager
Reason: Age between 13 to 19 are called teenagers.
Short Answer Questions
1.) What are the different types of logical operators? Explain with examples.
Answer : The three most important logical operators are AND, OR and NOT.
1.) AND operator is used to determine if two or more conditions are true. If all the conditions are true, the AND operator returns TRUE.
AND operator is denoted by “&&” symbol.
Example – you should go to bed only after you have completed your homework and the time is past 8 PM.
2.) The OR operator is used to determine if either one of two or more conditions is TRUE. If any of the condition is true, the OR operator returns TRUE. OR operator is denoted by “||” symbol.
Example – We should carry an umbrella when either it is sunny, or it is raining. Otherwise, we should not carry it.
3.) We use the NOT operator to reverse or negate a condition. If the condition is true, NOT will return false and vice-versa. In some programming languages NOT operator is denoted by “!” symbol.
Example – you can go to play only if it is not raining, otherwise, you must stay indoors.
2.) Explain with example on how to combine different logical operators.
Answer : we can combine different logical operators to create a complex expression.
Example –
IF (Day == Monday AND (Time >= 10 AM AND Time <=12 PM)) OR
(Day == Wednesday AND (Time >= 3 PM AND Time <= 5 PM))
THEN
Library Open
ELSE
Library Closed
END
3.) Write the pseudocode using logical operators to decide if today is a school day or not.
Monday-Friday: School day;
Sunday: Holiday;
1st and 3rd Saturday: Holiday;
2nd and 4th Saturday: School day)
Answer:
IF (Day == Monday OR Tuesday OR Wednesday OR Thursday OR Friday 2ndSaturday or 4thSaturday)
THEN
Today is school Day
ELSE
Today is Holiday
END
Higher Order Thinking Skills (HOTS)
1.) Create an if-else block with a NOT condition and set two different background colors on the controller.
Answer :
Input your height
IFNOT (height >23)
THEN
Set background image to red
ELSE
Set background image to violet
END
2.) Create an if-else block with an OR condition and set two different background images on the controller.
Answer :
Input your height
IF (height > 20) OR (height < 5):
THEN
Set background image to purple
ELSE
Set background image to green
3.) Create a nested if-else block to check if a number is divisible by 3 or 5 or both.
Answer :