Grade 6-8 Dec
Grade 6-8 Dec
GARDE 6-8
ABOUT SUPER AI POLARIS
CLASS PLAN -TERM 2
NOVEMBER
The lights cycle through green, yellow, and red at regular intervals to control road intersections’
traffic flow.
The traffic signals work in sync to prevent accidents and help to avoid congestion on the roads.
HOW DOES TRAFFIC SIGNAL WORK? -
BEHIND THE SCENES
Few lines of code running in the background drive the traffic lights. The code
changes the traffic signals to show different colors at regular intervals.
Data type identifies the type of data that the declared variable can hold is. Thus, it indirectly helps
the computer to understand what operations need to be performed on those variables.
The declaration of a variable in a program contains two components – the name of the variable and
its type.
Let us now understand what are the common data types that we can use in programming:
Integer
Floating-point number
Character
String
Boolean
NAMING RULES
As we have understood till now, variables in a programming language are basically like nouns. Every
variable in a program is unique. To identify these variables uniquely, the user needs to allocate them
a unique name. This name acts as an identifier for that variable. In programming, a user is not
allowed to use the same name of a variable more than once.
Naming variables make it easier to call them while performing operations. The name of a variable
also suggests what information the variable contains.
Below are some rules for naming a variable:
A variable name cannot start with a number, it must start with an alphabet or the underscore (_)
sign
A variable name is case-sensitive. Sum and sum are different variables
A variable can only contain alphanumeric characters and underscore
NAMING RULES
As we have understood till now, variables in a programming language are basically like nouns. Every
variable in a program is unique. To identify these variables uniquely, the user needs to allocate them
a unique name. This name acts as an identifier for that variable. In programming, a user is not
allowed to use the same name of a variable more than once.
Naming variables make it easier to call them while performing operations. The name of a variable
also suggests what information the variable contains.
Below are some rules for naming a variable:
A variable name cannot start with a number, it must start with an alphabet or the underscore (_)
sign
A variable name is case-sensitive. Sum and sum are different variables
A variable can only contain alphanumeric characters and underscore
VARIABLES IN PICTOBLOX
Let’s see how you can create a variable in PictoBlox. Follow the steps below:
1. Open the Variables palette.
2. Select Make a Variable.
3. The set () to () block will set the specified variable to the given value be it a string or number.
ACTIVITY: TRACKING A SPRITE’S
POSITION USING VARIABLES
1. Create two variables X and Y. We’ll use them for Tobi X
and Y positions respectively
2. Change the background to Xy- Grid to visualize the
position.
3. Add the when flag clicked block to start the script.
4. Next, set the X and Y positions as 0 by setting the X and
Y variables as 0 using the set () to () block.
5. Now, add a forever block below the when flag clicked
block.
6. Then, from the Motion palette, add a go to x:() y:() block
and drag and drop the X and Y variable blocks inside it
as shown. This will set Tobi’s position to the current
value of X and Y.
ACTIVITY: TRACKING A SPRITE’S
POSITION USING VARIABLES
1. To move left, we will change X by -10 whenever the left
key is pressed. Add a when () key pressed block from
the Events palette and change X by -10 by using a
change () by () block.
2. To move right, we will change X by 10 whenever the
right key is pressed. Repeat the above step and select
the right arrow key from the drop-down of the hat block
and change X by 10 in the change () by () block.
3. To move up, we will change Y by 10 whenever the up
key is pressed.
4. For down, we will change Y by -10 whenever the down
key is pressed
SESSION 5 :
ARITHMETIC OPERATORS
SESSION 6:
CONDITIONAL STATEMENTS
RELATIONAL OPERATORS
RELATIONAL OPERATORS
IF BLOCK
IF THE ELSE
LOGICAL OPERATORS - AND
IF (HOMEWORK COMPLETED) AND(TIME IS PAST 8 PM)
THEN
GO TO BED
ELSE
DO NOT GO TO BED
END
LOGICAL OPERATORS- OR
LOGICAL OPERATORS-NOT
SESSION 7:
NESTEDCONDITIONAL
STATEMENTS
ACTIVITY: THE REMAINDER PROBLEM
SESSION 8:
LOOPS
INTRODUCTION TO LOOPS
INTRODUCTION TO LOOPS
WHILE LOOPS
WHILE LOOPS
SESSION 9:
FOR LOOPS