0% found this document useful (0 votes)
58 views16 pages

7STD Chapter 1 Coding Book V1

The document outlines a lesson for Class 7 students on the concept of variables in programming, using a scenario where two friends, Aarav and Apoorva, create a program to calculate their assignment marks and determine which appreciation badge they will receive. It explains the use of variables, data types, and provides a step-by-step guide to writing a program using Microsoft MakeCode Arcade. Additionally, it includes quizzes and assignments to reinforce the learning objectives.

Uploaded by

Deepa Gayathri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views16 pages

7STD Chapter 1 Coding Book V1

The document outlines a lesson for Class 7 students on the concept of variables in programming, using a scenario where two friends, Aarav and Apoorva, create a program to calculate their assignment marks and determine which appreciation badge they will receive. It explains the use of variables, data types, and provides a step-by-step guide to writing a program using Microsoft MakeCode Arcade. Additionally, it includes quizzes and assignments to reinforce the learning objectives.

Uploaded by

Deepa Gayathri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 16

Class 7 Chapter 1: Variables In Real Life

Learning Objectives:

At the end of this exercise, the students will learn to:

• Create variables that represent different types of data and manipulate their
values.
• Perform arithmetic operations on their values.

Aarav and Apoorva are two friends studying in Class 7. One morning their class
teacher Ms. Jennifer had an announcement for the class.

Ms. Jennifer: Good Morning Students! Hope you are


working hard for the upcoming assignment.

Students: Yes Ma’am! (In chorus)

Ms. Jennifer: I am excited to say that these two


appreciation badges are for you. But there is a condition!
(displaying the badges)

Students: Ma’am, can you please let us know about it.

Ms. Jennifer: The badge with the message “I met a Goal” is for all the students
who get marks 75 and above in their assignment task.

Students: Hurray! Hurray!

Ms. Jennifer: And all other students who receive less than 75 marks will receive
the badge with the message “I don’t Give up”.

Aarav to Apoorva: Apoorva! (murmuring)We should perform our best and look
forward to get “I met a Goal” badge.
Apoorva to Aarav: Yes Aarav! We will get one.
The assignment was complete and the marks for each subject was given to the
students. Aarav and Apoorva were thrilled to know the badge they were going to
receive from Ms. Jennifer.

Aarav: I couldn’t hold on to the excitement of receiving my badge.


Apoorva: Yes Buddy! But we need to wait for the result.
Aarav: Instead of waiting for the announcement shall we create our own program
based on what we learnt in Class 6 Coding project to add values.
Apoorva: Wow! that's a good idea. I remember! Using Addition program we can
add marks. But how can we check whether we crossed the 75 marks or not?
Aarav: Can we discuss with the DIYA Robot.
Apoorva: That's a good idea. Through this program we can help Ms. Jennifer in
finding the badges the students

What are we waiting for? Let’s go right away and meet our dear friend DIYA
Robot

At DIYA labs: Apoorva and Aarav visit nearby DIYA Robotics lab and meet
DIYA Robot.

DIYA: Hey Aarav and Apoorva! Good to see you here. And may I know the
reason for your visit.

Apoorva and Apoorva: Yes! DIYA, we have an idea to develop the program. And
we need your help to build it.

DIYA: oh! That’s interesting.

Idea

What is a Model?
A model which gives the step-by-step procedures to find a desired output.
Every product is not built in one step. Designing a program also requires a model.
Let us know what are the different sections/steps in a model.

Here is a flowchart that shows how a software can be built


Let us dive into each section.

DIYA Robot: Aarav! Let me hear your idea and help you both in building it.

Aarav: We intend to develop a program to add the marks received in all the
subjects and check whether the total obtained is above 75 or not.

DIYA Robot: Good, let us write the program on the platform Microsoft
Makecode Arcade. Microsoft MakeCode is a free online learn-to-code platform
where anyone can build games, code devices, and mod Minecraft!

Plan
Now we know about IDEA, let us know the second part which is PLAN

DIYA Robot: How many subjects do you wish to add?


Aarav: With 5 numbers.
DIYA Robot: then?
Apoorva: We need to check the total marks with 75%.
Aarav: If it's more than 75%, then Print “Good work” and you get “I met a Goal”
badge. If the total is less than 75%, then Print “Work harder” and you get “I don’t
Give up” badge.
DIYA Robot: I got it. Let’s begin with the program.
Program
Before we program, we should explore various blocks in Arcade
In Arcade, “On start” block enables you to run the program

Variables: Variables in programming are values that


change based on the conditions and information passed to
them. We need three variables in this case because we're
dealing with two numbers and need to save the result.

Set Variable Block: This block enables you to assign


values to variables, develop creative flows, and pass
relevant information about the chatter's conversation to
your agents.

This block enables you to perform basic mathematical


operations like addition, subtraction, multiplication, and
division.
Splash: It displays a title or result or text on the screen.
You can splash a title at the beginning of your program or
later in the game. When you press a key or button on the
output screen, the splash text disappears.

If else: If a value is true, do the first block of statements.


Otherwise, do the second block of statements

Let’s Start the Program


Now we know the clocks required for our program, let us start write a program to
perform addition

Open the URL


https://arcade.makecode.com on
your computer browser.

Step 1: Click the New Project and


name it. For instance
DIYA_Basic Arithmetic

A new screen pops out.This is called Editor. Refer to the figure on the right side,
an output screen is displayed on the left side of the editor and the middle list
represents the different blocks and the rest of the editor is the coding area.

Step 2: Click on the “Variables” in the list.

Under “Variables”, you can see "Make a


Variable" block

Step 3: Click on the “Make a Variable”

A text box is popped out to name a new variable.


Name the 1st variable as a “language 1“

Step 4: Name the variable and Click “Ok”

Similarly, create five more variables and name them as “language 2”, “Maths”, “Science”,
“Social”, “Total”

Note:Repeat Steps ‘2’,’3’,’4’ twice to create more variables

Step 5: Click & drag the “set to” block and


select “language 1” from the drop down and
set the value to 60

Repeat Step 5 for the other variables also, set


“language 2” to 75; “Maths” to 80;
“Science” to 68;
“Social” to 88

Step 6: Under "Math." block, select the


highlighted block which is addition operation

Step 7: Now, combine 4 addition blocks


together by placing one above another as
shown

Step 8: Now, replace the 5 zeros with the 5


subject variables
Step 9: Click & drag the “set to” block and
select “total” from the drop down and drag
the additional operator block and place it in
the value space

Step 10: Go to the “Game”, select the


“splash” block. Drag and drop it under the
“set total to” block

Step 10: Set the value as “Total is” and click


the + symbol and place the variable “Total”
in it

Step 12: Go to the “Logic”, select the “If


else” block. Drag and drop it under the
“splash” block

Step 13: Go to the “Logic”, select the “<”


block. Drag and drop it inside the “if else”
block. From “Variables” , select “Total” and
drop it in the left white space and type “350”
in the left white space

Step 14: Go to the “Game”, select the


“Splash” block. Drag and drop it under the
“If ” block. And fill it up with “Need to
concentrate”
Step 15: Go to the “Game”, select the
“Splash” block. Drag and drop it under the
“else ” block. And fill it up with “Good job
keep rocking”

OUTPUT

Code Decode

language_1 = 60
language2 = 75
Maths = 80 The values are assigned
Science = 68
Social = 88

Total=language_1 +
Total is Found
(language2 + (Maths +
(Science + Social)))

Pint function
game.splash("Total is", Total)

if Total < 350:


game.splash("Need to
Condition statement
concentrate")
else:
game.splash("Good job
keep rocking")

FLOW CHART

START

Set

Set

Set

Set

Set

Calculate

TRUE FALS
Display If E Display
Tot

STOP
KEY CONCEPT

Variables: At homes we have cupboards to keep their books, clothes, stationery


etc.,. Variables are a lot like cupboards: variables are places in which computers
keep things. Computers need containers in which to keep numbers, text, and other
information so that later they can make decisions. The code tells the computer
when to look in these cupboards and what to look for.

“Hey, computer… get my science book, because it is fifth hour!”

Here are some examples of things computers might store in variables.

Variables
Variables are used to store data that will be referenced and used throughout the
program. They also enable us to label data with descriptive names, allowing both
the reader and ourselves to better understand our programs. Variable names
should not begin with a number. Here are three steps that you should remember

● Make variables with descriptive names.


● Store your values in those three variables.
● Perform the addition operation with the stored value.

Data type:

Data type is an important concept in programming.


Variables can store various types of data, and different types can perform various
functions.
Python includes the following data types by default in these categories:
● Text Type: str
● Numeric Types: int, float, complex
● Sequence Types: list, tuple, range
● Mapping Type: dict
● Set Types: set, frozenset
● Boolean Type: bool
● Binary Types: bytes, bytearray, memoryview
Variables are containers for storing data values.

Data type Example Explanation

Strings "Hello!", "23.34" Text - anything between


" " becomes string
Integers 5364 Whole numbers
Floats 3.1415 Decimal Numbers
Booleans True, False Truth values that represent Yes/No

Lists [1,2,3,4,5] A collection of data,


sits between [ ]
Tuples (1,2,3,4,5) A collection of data,
sits between ( )
Dictionaries {"a":1, "b":2, "c":3} A collection of data,
sits between { }

Example: Let’s consider you are asked to fill up a form of personal


details.
For example let's take a few of the details asked are i) Name and ii) Age.
While filling the form, you cannot use numbers to fill the name column
and alphabets for the age column. The other way, you can fill the name
column with the alphabets and the age column with the numbers. This is
the similar way of grouping the data types.

[CARTOON ASKING NAME AND AGE]

DID YOU KNOW?


The first alarm clock only rings at 4 a.m

The first American alarm clock was created in 1787 by Levi Hutchins in
Concord, New Hampshire. This device he made only for himself
however, and it only rang at 4 am, in order to wake him for his job.[11]
The French inventor Antoine Redier was the first to patent an adjustable
mechanical alarm clock, in 1847.

ASSIGNMENT TASK
TASK 1: Using the same programming concept find the total marks of 2
students.
TASK 2: Try to build a code to find the average of 2 students with each 4
subjects.

Summary

QUIZ
1. What is the use of the below given block?

Answer:
______________________________________________________

______________________________________________________

2. game.splash("Total is", Total)


What does the above syntax display?
a) The value of marks scored in Science
b) The value of Marks scored in Language 1 and Language 2
c) The total marks obtained by the student
d) All of the above

3. Select the suitable data type for the following :


TRUE

a) float
b) int
c) complex
d) bool

4. Variable names should not begin with a ___________.


TR FAL
DisplUE If SEDispl

5. STOP
The above flow chart represents what ?
a) Data Type
b) Variables
c) If-Else Logic
d) Math Operation
6. Variables are containers for _________ data values.
a) Delete
b) Store
c) Open
d) All the above
7. Match the following:

DATA TYPE EXAMPLE


1. FLOAT 77
2. BOOLEAN 3.543
3. INTEGER True

8. What is the python code equivalent for the below code block?

a)game.splash("Good job keep rocking")


b)print.splash(“Good job keep rocking”)
c)display.game(“Good Job Keep Rocking”)
d)game.print(“Good job keep rocking”)
9. The “If-Else” block is found under which option?
a) Math
b) Logic
c) Game
d) Sprite

10. Which line of the code calculates the total and how?
Answer: Line number: _______
Explanation: ________________________________________
_________________________________________________________

REAL-TIME EXAMPLE:
● The concept used in the program is similarly used in schools, colleges and
even in professional organizations to monitor the performance of the
employee/student using their target, marks, grades ect.,

Rate your Understanding


Tick the emoji that best reflects how you feel about today’s lesson
Image showing kid

I’m so lost I don’t really get it I’m starting to get it I got this
I could teach it

If you have rated yourself with one of the first three emojis , check with your
mentor for any clarifications and get cleared with the concept.

All the Best


If you have rated yourself with one of the last two emojis
Congratulations !!!!!
You have successfully completed 13% of this course.Get ready for more
adventures

Something Exciting -Coming next

Image showing a pizza and a kid with mouth watering

Get ready for this adventure in the next Module

You might also like