Session Code CODR-912-BC-002
Module Basic
Teaching Unit Variables and Datatypes
Learning Outcome Concept of variable, rules of naming a
variable, data types: int, float, String;
Relational Operators; writing programs to
apply all the concept
Resources Teacher:
1. Laptop along with audio and video
exchange
2. Notebook and Pen(To note any
development from session)
Student Resources
1. Laptop along with audio and video
exchange
2. Notebook and Pen(To keep note of
important parts in the session)
Duration 50 Mins
Structure Warm-up 2 Mins
Pace-up Activity 5 Mins
Knowledge Transfer 10 Mins
Student Led Activity 20 Mins
Short Quiz 8 Mins
Heads up tip for next class 5 Mins
Copyright © 2020 by Toppr Technologies Pvt. Ltd.
All rights reserved. No part of this document may be distributed, or transmitted in any form or by any means, including photocopying,
recording, or other electronic or mechanical methods, without the prior written permission of the publisher.
1
Step Say Perform
Warm up Hi s tudent name, how are you? Try to make the
(2 Mins) Are you excited for the class? student speak.
Do you remember the last class? Engage with the
student in
conversation.
Interaction In the last class, we installed Python and coded
(5 Mins) in its IDLE.
We used the print function with escape
characters and also learned mathematical
operators.
Do you remember what the modulus operator
does?
Yes, it is used to find the remainder.
Do you remember what the double forward
slash does?
Yes, it is used to find the quotient.
Today we will learn about variables and Teacher Activity 1:
Datatypes. Repl.it
Teacher shares the screen and open Repl.it and maximize the console portion
Copyright © 2020 by Toppr Technologies Pvt. Ltd.
All rights reserved. No part of this document may be distributed, or transmitted in any form or by any means, including photocopying,
recording, or other electronic or mechanical methods, without the prior written permission of the publisher.
2
Knowledge Variables are like containers which can be Give and ask for
Transfer used to store something. examples of
containers in
And that container is actually some part of the their real life.
computer's memory.
Thus, a variable is a unique memory location
Give the analogy
in the computer which holds the value we
of container and
provide it. its content, with
variable and its
Now, if we need the value of a variable for value.
some work, we have to tell the memory
location of the variable.
For that we give a name to the variable. Give the analogy
Example, if I write a=1 of using the same
container to store
Here, a is the variable name and 1 is the different objects.
value of the variable.
Now, if we want to store something else in the
variable we can very well do it
a=5
The value of the variable is changed to 5,now.
The word variable in english means which
can change.
Naming variables We can name the variable almost anything we Show different
like. examples.
E.g.
num=45 Prompt the
n3=98 student to
suggest variable
names
It can be a combination of letters and
numbers, but must start with a letter only.
Apart from letters and numbers we can
also have underscore in the variable name.
Apart from underscore we cannot have any
other special character in variable name not
even space
Copyright © 2020 by Toppr Technologies Pvt. Ltd.
All rights reserved. No part of this document may be distributed, or transmitted in any form or by any means, including photocopying,
recording, or other electronic or mechanical methods, without the prior written permission of the publisher.
3
E.g.
number_3=890
Ok, those are some simple rules to follow Ask the student
while naming a variable, right? to repeat the
rules.
There is one more very important rule to keep
in mind.
We can’t use keywords as variable names.
Keywords are words which have some
special meaning to the computer.
These words are reserved to do some
particular thing only, so using them as
variable names will confuse the computer.
Let’s try to create a variable as: Prompt the
class=9 student to
And let’s print it. answer.
See you will get an error.
Show how python
throws error if we
This is because the word “class” holds special
use class as a
meaning to Python and we can’t use it as a
variable name.
variable.
So class is a keyword.
Data types Ok, now that we know the rules, now, let’s Tell them that in
create some variables. other languages,
b=10 and c=2 we first need to
declare a
The variables b and c are storing numbers and variable, i.e.
that too integers. telling the
So, the d
ata type of these variables is i nt computer what
kind of data, we
are going to store
in it.
Copyright © 2020 by Toppr Technologies Pvt. Ltd.
All rights reserved. No part of this document may be distributed, or transmitted in any form or by any means, including photocopying,
recording, or other electronic or mechanical methods, without the prior written permission of the publisher.
4
Data type o f a variable means the type of data Create different
that it is storing, variables to show
Here, i nt stands for integers. different data
types.
Let’s see what are the different data types we
can have:
int: like you know stands for integer numbers
Remind the kid
Then we have a float that stores the decimal that they have
number. come across the
Do you remember another word for decimal term floating
number?? point in the last
Yes it's a floating point number because of its class.
decimal point.
We can even store text in a variable, Remind the
Just keep in mind that it must be enclosed within student they used
either single or double quotes. single and double
E.g. quotes in the
t=”toppr” print function to
Now, the data type of t is S tring display text.
Great, so let’s revise whatever we learnt up till
now.
Ask the student to share their screen, and ask them to click on Student Activity 1
Now, you have to declare some variables. Student Activity 1:
Try solving these activities. Variables
Guide the student
to complete all
activity.
● Ask the student to stop screen sharing
● Share your screen and open repl.it
We will now do some operations on these Teacher Activity 2:
variables. Operations-on-Va
riables
Like you declared some variables, I have also
assigned some variables of my own.
Copyright © 2020 by Toppr Technologies Pvt. Ltd.
All rights reserved. No part of this document may be distributed, or transmitted in any form or by any means, including photocopying,
recording, or other electronic or mechanical methods, without the prior written permission of the publisher.
5
Run the repl and
call all the
variable in the
console section
You can clear the
console using this
button on top
right corner:
We can use the print function to display the Show examples
value of the variables too. of the same.
So you can remember this as anything written a=90
within quotes in print function is displayed as it print(“a”)
is and for thing not written within quotes,its a
value is displayed (like variables) print(a)
90
Do you remember all the mathematical Show all the
operators we learnt in last class. operations that
can be done on
Let’s try them on variables of data type the variables.
int and float.
We can store the result of an operation in Show with
another variable also. different
examples how a
Use and show the use of all these operators: + ,- ,* variable can store
,/ ,// ,% results of an
operation.
We can even compare variables with operators Show how to
called Relational operators. compare two
Remember Relational operators tell the relation numbers using
between two things. these operators.
Greater than (>) or Less than(<) symbols are The results will be
used as operators two compare two numbers. True or False.
Copyright © 2020 by Toppr Technologies Pvt. Ltd.
All rights reserved. No part of this document may be distributed, or transmitted in any form or by any means, including photocopying,
recording, or other electronic or mechanical methods, without the prior written permission of the publisher.
6
Other relational operators are, Explain each of
● Greater than or equal to: >= them.
● Smaller than or equal to: <=
● Equal to: ==
● Not equal to: !=
Notice the double equal to symbol is used to
compare if two things are equal.
While a single equal to s ymbol is used while
assigning value to a variable, so it is an
assignment operator.
● Stop sharing screen
● Ask the student to share the screen and click on Student Activity 2
Let’s solve these activities one by one. Student Activity 2:
Operation on
Variables
● Help the student through each activity
● Difference between quotient and result of division is using // and / operator
respectively
● Help the student to stop sharing the screen
Revision We learned so much in today’s class, right? Briefly describe
Let’s recall: each of these
● Variables
● Rules of naming Variables
● Keywords
● Data types: int, float, String
● Mathematical operation on variables of
Data type int and float
● Displaying variable using print function
Headup for next In the next class we will build upon this
class knowledge and will learn about different types
of operators and data types and will start a
project too. Student Activity 3:
Quiz
I am sharing a short quiz for your revision.
Practice whatever we have learned uptil now, in
the IDLE.
BID GOODBYE & END CLASS
Resources:
Copyright © 2020 by Toppr Technologies Pvt. Ltd.
All rights reserved. No part of this document may be distributed, or transmitted in any form or by any means, including photocopying,
recording, or other electronic or mechanical methods, without the prior written permission of the publisher.
7
Activity Name Links
Teacher Activity 1 Repl link https://repl.it/@TopprCodr/ZanyMeanKeygens#
main.py
Student Activity 1 Variables https://repl.it/@TopprCodr/Variables
Teacher Activity 2 Operation on variables https://repl.it/@TopprCodr/Operations-on-Varia
bles
Student Activity 2 Operations on https://repl.it/@TopprCodr/Variable-Operation
Variables
Student Activity 3 Quiz https://forms.gle/WDVQw7niYiECnghU6
Copyright © 2020 by Toppr Technologies Pvt. Ltd.
All rights reserved. No part of this document may be distributed, or transmitted in any form or by any means, including photocopying,
recording, or other electronic or mechanical methods, without the prior written permission of the publisher.
8