0% found this document useful (0 votes)
15 views22 pages

Ahw 2312200954 1691568535 1

Uploaded by

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

Ahw 2312200954 1691568535 1

Uploaded by

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

DELHI PUBLIC SCHOOL MARUTI KUNJ GURGAON

CLASS VI
SUBJECT: COMPUTER
TOPIC: INTRODUCTION TO CODING
SECOND TERM ACTIVITY

Chapter 1 : Quiz Time

Question 1 For a given problem, there is always only one way to write a program

Option 1 True
Option 2 False

Question 2 Pin authentication for ATM card transaction is an example of


programming
Option 1 True
Option 2 False

Question 3 Code is a set of instructions that can be executed on a computer to


perform a specific task
Option 1 True
Option 2 False

Question 4 Which among the below are examples of programming in real life?

Option 1 Robots
Option 2 Computer Games
Option 3 Self-drive cars
Option 4 All the above

Question 5 Which among the below is not an example of programming language?

Option 1 Python
Option 2 English
Option 3 JavaScript
Chapter :2 Flowcharts

What is a Flowchart?
A flowchart is a diagrammatic
representation of the step-by-step plan
to be followed for solving a task/problem
statement.
This diagrammatic representation is
made up of shapes like boxes, diamonds,
parallelograms, circles, ellipses
connected by arrows. Each shape acts as
a step in the solution, and the arrows
represent the direction of flow among
the steps.

Symbols used in a flowchart


Objective type questions

1. Select a word from column A and place it in a cell on column B such that itsdefinition
matches in cells of column C

A B C

Writing steps involved to


solve a problem in a
Algorithm
human-understandable
language

Block based coding


Flowchart
platform

Define step by step plan


Pseudo Code to solve a problem
statement

Solution to a problem
Arcade
presented as a diagram

Below is a flowchart to calculate profit and loss. Answer questions 2 to 4 based on the
flowchart.
Question 2 Jyoti owns a toy shop. She bought a toy for Rs 325 and sold it for Rs.
375. Which one from the below is correct?
Option 1 She made a loss of Rs. 50
Option 2 She made a profit of Rs. 50

Question 3 Raju buys a pen for Rs 15, and after some time, he sells it for Rs 10.
Which one from the below is correct?
Option 1 He made a loss of Rs. 5
Option 2 He made a profit of Rs. 5

Question 4 Ram buys a table for Rs 500, he sells it for Rs 550. Which one from
the below is correct?
Option 1 He made a loss of Rs. 50
Option 2 He made a profit of Rs. 50

Question 5 Which of the following is not an advantage of a flowchart?

Option 1 Efficient coding


Option 2 Systematic testing
Option 3 Improper documentation
Option 4 Better communication
Question 6 The following box denotes.

Option 1 Initialization
Option 2 Decision
Option 3 Input / Output
Option 4 Connectors

Question 7 What is a flowchart?

Option 1 A specific programming language


Option 2 A text-based way of designing an algorithm
Option 3 A bullet point list of instructions
Option 4 A diagram that represents a set of instructions

Question 8 What shape represents the start and end of a flowchart?

Option 1 Square
Option 2 Diamond
Option 3 Oval
Option 4 Circle
Chapter : 3 VARIABLES USING BLOCK CODING

WHAT ARE VARIABLES?


In programming, variable is a packet in NAMING VARIABLES
which we can store data. These packets

As we have understood till now, variables are


can be named and referenced and can be used basically like nouns in a programming
to perform various operations. To perform a language. Every variable in a program is
mathematical operation, you can declare two unique. To identify these variables uniquely,
variables and perform the operation on them. user needs to allocate them a unique name.
This name acts as an identifier for that
Scope of a variable refers to the part of the variable. In programming, a user is not
code where the variable can be used. The allowed to use the same name of a variable
scope or accessibility of the variables defined more than once.
in a program depends on where you have
declared it in each program. Any defined Naming variables make it to easier to call
variable cannot be accessed beyond its scope. them while performing operations. The
name of a variable also suggests what
information the variable contains.
You can refer to the example before for
better understanding about variables:

If variable named as "a" is equal to 2 and


variable named as "b" is equal to 2,
performing add operation on "a" and "b" is integer variable and assign it a non-
going to result into an output as "4". integer value, the program returns an
error.
Variables of the integer data type are
only capable of holding single values.
3.1 Data types in variables
These variables are not capable of
holding a long list of values.
Variables are the values that are acted
Floating Point Number Data Type
upon. Every value needs to be assigned
to a specific data type to make the Floating-point numbers are used to
variable more readable by a computer. store decimal values. They hold real
Data type identifies what the type of data numbers with decimal values.
that the declared variable can hold is. Depending on the programming
Thus, it indirectly helps the computer to language, the syntax to declare floating-
understand what operations need to be point variable changes.
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 There is another type of floating-point


• Floating-point number number known as a "double" data type,
• Character which is used to store even bigger
• String values.
• Boolean
Integer Data Type

Integer data type variables store integer


values only. They store whole numbers
which have zero, positive and negative
values but not decimal values. Multiple
programming languages support
different syntax to declare an Integer
variable. If a user tries to create an Character Data Type
Character type variables are used to
store character values. Syntax of
declaring a character variable is specific
to the programming language that you
are using. If a user tries to create a data types for variables as per program
character variable and assign it with a needs and assign variables an
non-character value, the program will appropriate data type.
throw an error. The character data type
Boolean is a subtype of integer data
is the smallest data type in
type. It stores true and false where true
programming.
means non-zero and false means zero.
Any character values can be declared as
a char variable.

Any Boolean variable holding Boolean


value can be declared as Boolean.

String Data Type Note: In some programming languages


like python, there is no command to
To extend the character data type, a user
may have a requirement to store and
perform an operation on a sequence of
characters. In such cases, the String data
type is present to fit the gap. The String
data type stores value in a sequence of
characters i.e. in String format.

declare variables. A variable is created


the moment you first assign a value to it.
If you want to specify the data type of
variable this can be done using casting.

Example: y = str(7)
Any string value can be declared as a
string variable. z = int(7)
a = float(7)

Boolean Data Type y will be saved as ‘7’

There is a subtype of Integer Data Type z will be saved as 7


called "Boolean Data Type", which stores
a will be saved as 7.0
values in Boolean type only i.e. "true" or
"false". Users can choose between the
Let us now apply different data types in
a pseudocode. We will first declare

Integer i = 1234567890
Float f = 1.234
Char c = c
String s = string
Boolean b = true

different types of variables, followed by


assigning them to appropriate values.
Finally, we will use the variables by
outputting their values.

The output from the above pseudocode


will be like below.
Note: The syntax is different for different
data types in other programming
languages.
In python string variables can be numeric expression. The basic operators
declared either by single quotes or for performing arithmetic are the same
double quotes or triple quotes. in many computer languages:
Below are some rules for naming a • Addition
variable in python: • Subtraction
• Multiplication
• A variable name cannot start with
• Division
a number, it must start with an
alphabet or the underscore (_) • Modulus (Remainder)
sign Assignment operators
• Variable name is case sensitive.
Sum and sum are different Assignment operators are used to assign
variables values to variables
• A variable can only contain alpha Different assignment operators are
numeric characters and shown below:
underscore
• “=”: This operator is used to
assign the value on the right to
3.2 Performing Operations on the left variable.
Variables Example: a=50
• “+=”: This operator assigns the
result to the variable on the left
After declaring the data types in
after adding the current value of
programming, now let us move ahead
the variable on left to the value on
and understand what operations we can
the right.
perform on the data types and how do
Example: x += y
we perform these operations:
It can also be written as x = x + y
Arithmetic Operations • “-=”: This operator assigns the
result to the variable on the left
after subtracting the value of the
variable on right from the current
value on the left.
Example: x -= y
It can also be written as x = x - y
• “*=”: This operator assigns the
result to the variable on the left
after multiplying the current
value of the variable on left to the
value on the right.
Example: x *= y
An arithmetic operation combines two or It can also be written as x = x * y
more numeric expressions using the • “/=”: This operator assigns the
Arithmetic Operators to form a resulting result to the variable on the left
after dividing the current value 3.3 Activity: Addition
of the variable on left from the operation using block
value on the right.
Example: x /= y
coding
It can also be written as x = x / y
Increment operator An addition arithmetic operation is used
to add the values stored in two variables.
Increment operator adds one to the Like the way we add values in
value. mathematics, we can store values in
different variables and perform an
Example: A=8
additional operation. The addition of
B=A++ these variables is displayed as an output
of the program.
The output of B will be 9 (A+1)
For example, performing add operation
A++ has the same meaning as A=A+1 on a variable "a" holding value "3" and a
Decrement operator variable "b" holding value "4" will result
in an output "7". To understand this
Decrement operator subtracts one from arithmetic operation better, let us
the value. understand how to implement it
Example: A=8 practically in programming. For this, we
are going to take example of platform
B=A-- https://arcade.makecode.com/. Let us
refer to the steps below understand
The output of B will be 7 (A-1)
more in details.
A-- has the same meaning as A=A-1
Subtraction Division
Subtraction arithmetic operation is used Division arithmetic operation is used to
to subtract the values stored in one divide the value stored in one variable by
variable from another variable. Like the the value stored in another variable. Like
way we subtract values in mathematics, the way we divide values in
we can store values in different variables mathematics, we can store values in
and perform subtraction operations. different variables and perform division
Subtraction of these variables is operations. Division of these variables is
displayed as an output of the program. displayed as an output of the program.

For example, performing subtraction For example, performing division


operation on a variable "a" holding value operation on a variable "a" holding value
"10" and a variable "b" holding value "8" "2" and a variable "b" holding value "2"
will result in an output "2". will result in an output "1".
Multiplication Modulus (Remainder)

Multiplication arithmetic operation is Modulus operator (%) calculates the


used to multiply the values stored in two remainder when two variables are
variables. Like the way we multiply divided. Please note that this operation
values in mathematics, we can store can only be performed on integer and
values in different variables and perform float variables in Python.
multiplication operations. Multiplication
For example, performing modulus
of these variables is displayed as an
operation on a variable "a" holding value
output of the program.
"9" and variable "b" holding value "3" will
For example, performing multiply result in an output "0" as there is no
operation on a variable "a" holding value remainder in this operation.
"2" and a variable "b" holding value "2"
will result in an output "4"
Chapter 3 : Quiz time
Objective Type Questions

Question 1 An integer data type can hold decimal values.


Option 1 True
Option 2 False

Question 2 Variables must be defined with a name and a data type before they
can be used
Option 1 True
Option 2 False

Question 3 Which of the following is not a valid variable name in python?

Option 1 _test
Option 2 11test
Option 3 Test13
Option 4 Test_2

Question 4 Fill in the blanks to declare sum equal to a + b (int _ = a b)

Option 1 Sum,+
Option 2 Var,-
Option 3 Bool,+
Option 4 Add,+

Question 5 Which of the following data type is used to store decimal values?

Option 1 Integer
Option 2 Float
Option 3 Boolean
Option 4 String

Question 6 How many times should a data type be mentioned for a variable

Option 1 Everywhere the variable is used


Option 2 When entering variable’s value
Option 3 When printing a variable’s value
Option 4 Only once; When declaring the variable
Question 7 Which of the following symbol is used to multiply variables?

Option 1 *
Option 2 +
Option 3 x
Option 4 %

Question 8 What is the alternative of y=y+9

Option 1 y=x+9
Option 2 y+=9
Option 3 y-=9
Option 4 x=+9

Question 9 Y++ has the same meaning as

Option 1 Y=Y+1
Option 2 X=+2
Option 3 y-=6
Option 4 X=x-5

Question 10 Which of the following symbol is used to find the remainder?

Option 1 *
Option 2 +
Option 3 x
Option 4 %

You might also like