Class 6 - Coding, AI & Robotics Course
-
Coding
Session 1: Introduction to Coding3 Topics -
Session 2: Backdrop, Costume, and Animation3 Topics|1 Quiz
-
Session 3: Basics of Algorithm and Flowchart3 Topics|1 Quiz
-
Session 4: Basics of Pseudocode3 Topics|1 Quiz
-
Session 5: Getting Started with Quarky3 Topics|1 Quiz
-
Session 6: Variables: The Multitaskers4 Topics|1 Quiz
-
Session 7: Arithmetic Operators4 Topics|1 Quiz
-
Session 8: Conditional Statements3 Topics|1 Quiz
-
Session 9: Logical Operators4 Topics|1 Quiz
-
Session 10: Nested Conditional Statements2 Topics|1 Quiz
-
Session 11: Loops3 Topics|1 Quiz
-
Session 12: Touch Based Piano2 Topics
-
Session 13: Criterial in Loops5 Topics|1 Quiz
-
Session 14: Catch the Fruit Game - Part 12 Topics
-
Session 15: Catch the Fruit Game - Part 22 Topics|1 Quiz
-
Artificial IntelligenceSection 16: Introduction to Artificial Intelligence3 Topics|1 Quiz
-
Session 17: Basics of Face Detection2 Topics|1 Quiz
-
Session 18: Face Expression Detection2 Topics|1 Quiz
-
Session 19: Mimic Face with Quarky1 Topic
-
Session 20: Face Filter - Part 12 Topics
-
Session 21: Face Filter - Part 22 Topics
-
RoboticsSession 22: Basics of Robotics2 Topics|1 Quiz
-
Session 23: Wirelessly Controlled Robot2 Topics
-
Session 24: Introduction to Sensors3 Topics|1 Quiz
-
Session 25: Introduction to Actuators3 Topics|1 Quiz
-
Session 26: Face Tracking with Robot2 Topics
-
Session 27: Obstacle Avoidance Robot - Part 13 Topics
-
Session 28: Obstacle Avoidance Robot - Part 22 Topics|1 Quiz
-
Session 29: Edge Detector Robot - Part 13 Topics
-
Session 30: Edge Detector Robot - Part 22 Topics|1 Quiz
-
Capstone ProjectCapstone Project
AND Operator
AND operator is used to determining if two or more conditions are true. If all the conditions are true, the AND operator returns TRUE. If any one of the conditions fail, the AND operator returns FALSE.
In some programming languages AND operator is denoted by the “&&” symbol.
Real-Life Example
You should go to bed only after you have completed your homework and the time is past 8 PM.
Here, if we want to derive the logical operation from this scenario, we have the following conditions:
- Condition 1: Have you completed homework?
- Condition 2: Is the time past 8 PM?
And the decision we are deriving is: Decision: Should you go to bed?
Pseudocode
Based on this we can write the below pseudo-code:
IF (Homework completed) AND(Time is past 8 PM) THEN Go to bed ELSE Do not go to bed END
Truth Table
Let us now try to see the different combinations possible with the above pseudo-code.
[table id=1 /]
AND Block in PictoBlox
The () and () Block is an Operators Block and a Boolean Block.
The block joins two boolean blocks so they both have to be true to return true. If they are both true, the block returns true; if only one is true or none are true, it returns false.
Activity: AND with Quarky
Let’s use this block with Quarky.
We are making a code that basically detects whether both the buttons of Quarky are pressed or not. If both buttons are pressed then the display of Quarky will show green, otherwise red.
Quarky Button Inputs
is button () pressed ? block from the Sensors palette provides the state of the selected.
If the button is pressed, then it shows True, and if the button is not pressed, then it shows False.
Lets Code
Follow the steps below to make the script:
- Go to the Sensors palette and add a is button () pressed ? block into the scripting area. The button, L, is set as the default option.
- Go to the Sensors palette and add a is button () pressed ? block into the scripting area. change the button to, R, is set as the default option.
- Add () and () block, from operator palette. Inside the block add both the is button () pressed ? blocks.
- Go to the Control palette and drop an if else block into the scripting area. Drop the () and () block in the white space of the if else block.
- Go to the Display palette and drop the display matrix as () block inside the if branch and make all LEDs green. Repeat to add display matrix as () block inside the else branch and make all LEDs red.
- Add a forever block around the entire script.
- To add the finishing touch, add a when flag clicked block from the Events palette above the forever block.
- Finally, click the green flag to run the script.
Assignment
Before you move on to the next lesson, a small assignment awaits you!
You must upload the PictoBlox program you created in this activity to the website. Submitting the assignment is a must in order to receive the certificate after completing the course.
Follow the steps below to upload your assignment:
- Click on Browse.
- Search and Select your saved Project file(.sb3) and Click Open.
- Click on Upload to submit the assignment.
Good luck!