0% found this document useful (0 votes)
270 views

CMS Class VII Additional Booklet

The document introduces the BASIC programming language and the BASIC-256 application. It discusses that BASIC-256 allows writing, running and debugging BASIC programs. It describes the interface of BASIC-256 which includes a title bar, menu bar, toolbar and areas for writing programs, text output and graphics output. It also explains the print statement in BASIC-256 which is used to display text on the screen.

Uploaded by

Crafting Villa
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
270 views

CMS Class VII Additional Booklet

The document introduces the BASIC programming language and the BASIC-256 application. It discusses that BASIC-256 allows writing, running and debugging BASIC programs. It describes the interface of BASIC-256 which includes a title bar, menu bar, toolbar and areas for writing programs, text output and graphics output. It also explains the print statement in BASIC-256 which is used to display text on the screen.

Uploaded by

Crafting Villa
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

BASIC Programming

BASIC 256 7
LESSON

Learning Outcomes
Introduction to programming language
By the
Haveendyou
of this
everlesson, you will
wondered how becomputers
able to: work? Can they make a decision and
• doWrite syntax-based programs.
their work alone? No, the computer can’t do their work alone. They don’t
• have
Take any
inputintelligence.
from users. Computers depend on humans to tell them what to do
• and
Perform
howarithmetic and string
to do it. “Telling” theoperations
computers on“what
data. to do ‘’ is termed as Instructions.
• ToDisplay numerical,
instruct textual we
the computer andneed
graphical output. called programming language.
a language,
Programming language is a tool, used to write instructions for computers.
Programming languages are of three types
Tejas, Jyoti and their classmates are excited as they are about to learn a new programming
language• called BASIC.
Machine The application called BASIC-256 is opened on a computer by
language
Moz. All of them surround the computer and see that the window of this application has
• Assembly language
some familiar options like New, Open, Save, etc.
They also• notice
High-Level language
some new options like Run.

Basic 256 is an example of a high-level language. In this chapter, we are going to


discuss the Basic -256 Programming language.
Basic (Beginner’s All-Purpose Symbolic Instruction Code). BASIC is one of the
simplest and earliest high-level programming language supports in all operating
systems. BASIC-256 is an easy to use version of BASIC which is a free and open
source software. The window of this application is given below.
Title bar
Menu bar
Some frequently used tools

Display area for text output


Area to write the program

Display area for


graphics output

BASIC Programming 139

BASIC 256
3
_CBSE_CM_Level-6.indd 139 10/26/2017 5:35:45 PM

Class VII.indd 3 12-05-2022 17:34:34


and displays the result.
• For getting output of PROGRAM OUTPUT
several print statements Print “Sum of 100 + 75=”; Sum of 100 + 75=175
on the same line, use a ; Print 100 + 75
(semicolon) at the end of
each print statement.

Moz: Now that you have understood the print statement, go ahead and try it
Title bar: Displays the name of the program. Default name on the title bar is
out some more.
“Untitled 1-BASIC-256”
Tejas: Should we start a new program?
Menu bar: menu bar contains File, Edit, View, Run, and Help options.
Moz: You can add more statements and run the same program or you can
The options
start awhich are frequently
new program used
(using New). Youarecan displayed below(using
also save programs the menu bar. It is a
movableSave)
toolbar, weacan
and load savedchange
programits position.
later (using Open).

To execute a program To stop the execution of a program

To locate and To execute instructions


Tejas: There
remove is a menu bar, which looks like any other
errors application's
one by one menu
bar, with File, Edit, View, Run, and Help options, and a toolbar with
frequently-used tools like Open, Save, Copy, Paste, etc.
Features
Jyoti: The of Basic-256
toolbar also has programming
a Run option. Doeslanguage
this execute the program?
BASIC Programming 141
• BasicYes.
Moz: 256 is aexecutes
Run high-level programming
the program. You writelanguage
the instructions in the
program area
• It is easy to learn of the application.
Print Statement – To Display Output
02_CBSE_CM_Level-6.indd 141• Basic-256 has simple rules to write the program 10/26/2017 5:35:49 PM

Tejas: I am eager to write a program and run it.


• It supports both text and graphical output
Moz: OK. Let us start with the Print statement. This is used to display text and
• The numbers
same Basic 256
on the program
screen. is supported
First, start in allbyOperating
a new program systems
clicking New. Enter (Cross-
platform language)
the print statements in the program area as shown and click Run. The
output will be displayed in the Text Output area.
• It is an Open Source software i.e you can download and install it for free
Print – BASIC-256
BASIC-256 Programand
Program and Text
TextOutput
Output
Info
Syntax of a
programming
language is a set of
rules that specifies
the grammar of
the programming
Img: Syntax of the Print Statement language.
Jyoti: In the first statement, print is displaying text which is inside quotes.
Moz:
Print This is called a string.
statement:
Tejas: In the second statement, print is printing the sum of the two numbers.
• The This
printmeans
statement
the two is used to
numbers aredisplay text
added and and
then thenumbers on the text output
result is printed.
area.The outputs of the third and fourth print statements are on the same
Jyoti:
line. Is it because of the semi-colon (;) at the end of the third print
statement? COMPUTER MASTI
4 Moz: You are right. You have explained the syntax of print statements.

Syntax of a Programming Language


Concept

Class VII.indd 4 12-05-2022 17:34:34

• Syntax of a programming language is the set of rules that specifies the


grammar of the programming language.
• The print statement followed by text number and other symbols (Ex- &, %, A, 0
Arithmetic Expressions
...9 , a ....z and so on), enclosed in double quotes (“ “) displays them as they are,
Tejas: Icalled
want tostrings.
include division and multiplication in my statements. Which is
• the division
Print symbol
followed on arithmetic
by an keyboard? expression, (Ex- Addition, multiplication,
Moz: Use slash and
division (/) for
sodivision and asterisk
on) evaluates (*) for multiplication.
the expression These
and displays areresult.
the
the symbols used for division and multiplication in many programming
• For getting output of several print statements on the same line, use a
languages.
semicolon (;) at the end of each print statement.
Tejas: Can we also use brackets like we do in Maths?
Arithmetic expressions
Moz: Yes, you can. The order of operations is also exactly the way you do in
Maths, that operator
Arithmetic is, BODMAS. BASIC-256(Keyboard symbols)
+ B(Addition)
Brackets +
–O Orders (powers and square roots)
(Subtraction) –
xD(Multiplication)
Division (left-to-right) * (asterisk)
M (Division)
Multiplication (left-to-right) / (slash)
Note:
A TheAddition
order of operations is also exactly the way we do in Maths, That is,
BODMAS.
S Subtraction (left-to-right)
PROGRAM Operators
Arithmetic OUTPUT

Print "Average of 50, 68, 35 ="; Average of 50, 68, 35 = 51


Arithmetic operation / 3Operator
Print (50+68+35) BASIC-256
The cost program and= text
of an apple 13 output
Print "The cost of an apple = 13" The cost of 12 apples = 156
PROGRAM OUTPUT
Print "The cost of 12 apples
Division / = ";
Info

Print 13 * 12 Print 135 / 9 15

PROGRAM OUTPUT
Jyoti: In the
Multiple statement Print
operators
Concatenation * (50+68+35)/3, BODMAS
Print 250 + (250 - 100) * rule850is used to evaluate
the arithmetic expression and20then
/5
the result is displayed.
The ‘+’ operator, when used with strings, joins them together. This operation is
Arithmetic Operators In concatenation two or more strings are joined together
called concatenation.
Moz:to make
Now trya out thesestring.
longer statements.
Arithmetic operation Operator BASIC-256 program and text output
PROGRAM OUTPUT
PROGRAM OUTPUT
Addition +
Print "Jyoti and Tejas " + "are learning BASIC." Jyoti and Tejas are learning BASIC.
Print 256 + 567 + 678 1501
Info

PROGRAM OUTPUT
PROGRAM
Subtraction – OUTPUT
Print 1000 - 750 250
Print "Today the price of 12 apples is = Rs. " + Today the price of 12 apples is = Rs. 60
(5 * 12)
PROGRAM OUTPUT
Multiplication ×
Print 250 * 20 5000
PROGRAM OUTPUT
Print "The area of a rectangle of length 12 units The area of a rectangle of length 12 units and
and breadth 8 units = "+ (12 * 8) + " square units" breadth 8 units = 96 square units

Tejas: In these statements, phrases (strings) are combined to get a full sentence.
142 Computer Masti
BASIC 256
Jyoti: In the second statement, the price of 12 apples is calculated and printed. 5
Moz: The ‘+’ operator, when used with strings, joins them together. This
CBSE_CM_Level-6.indd 142
Class VII.indd 5
operation is called concatenation. In concatenation, two or more strings 10/26/2017 5:35:54 PM
12-05-2022 17:34:35
are joined together to make a longer string.

String Operation
Start
End
Read A
Moz: Use the example values where A = 346 and B = 478.

PROGRAM OUTPUT
Read B
Sum of A + B = 824
A = 346

Numeric variables- To store numeric values B = 478


Sum = A + B
Sumof=AA+ B+=B”;
Print “Sum
Print Sum
Let us convert the following additional flow chart into a programme.
Variables – To Store Numeric Values
Variable is a space in the memory of aPrint Sum
computer to store information. Each
Moz: What are you instructing the computer to do in the first and second
variable
Let us convert the following has aflowchart
addition name into
for reference.
a program. statements?
End

Start Use the example


Jyoti:
Moz: Use the example
values
The
values
where= A=346
firstAstatement
where = 346 andisB instructing
478.
and
the B=478.
computer Memory

to store 346 in a variable named A. The second A 346


PROGRAM OUTPUT
instruction similarly instructs the computer to B 478
store 478 in a variable
Sum of named
A + B = 824B.
Read A A = 346
B = 478
Sum = A + B Memory
Print “Sum of A + Tejas:
B = ”; Next, we are instructing the computer to add the two
Print Sum numbers, A and B, and store the result of the addition Sum 824

Read B in the variable named Sum. (346+478)

Moz: What are you instructing the computer to do in the first and second
Thestatements?
first statement is instructing the computer to store 346 in
Sum = A + B a variable
Jyoti: named
144
The first statement A. The
is instructing the second
computer instruction Memory similarly instructs
Computer Masti

theto computer to store


store 346 in a variable named A.478 in a variable
The second A named B.ln the third
346
instruction similarly instructs the computer to
Print Sum statement, we are
store 478 in a variable instructing
named
02_CBSE_CM_Level-6.indd 144
B. the computer
B 478
to add the two 10/26/2017 5:35:58 PM

numbers
Tejas: Next, we areAinstructing
and Bthe and store
computer thetheresult
to add two ofMemory
the addition in a
variable named sum.
numbers, A and B, and store the result of the addition Sum 824
End in the variable named Sum. (346+478)

Once we have created a variable we can store, retrieve and


Use the example values where A = 346 and B = 478.
use information in it in our programme using its name.
144 Computer Masti
ROGRAM OUTPUT
Variable naming
Sum ofrules
A + B = 824
A = 346
B = 478
• A variable name can begin with the letter and followed by letters and numbers.
02_CBSE_CM_Level-6.indd 144 10/26/2017 5:35:58 PM
Sum = A + B
Print “Sum of A + B = ”;
Print Sum (Ex- sum, valuel, A)
• Numeric values (Integers and decimals) are stored and retrieved using numeric
variables.
What are you instructing the computer to do in the first and second
statements? • The variable name is case sensitive, which means that A and a are two different
variables.
The first statement is instructing If we have stored value
the computer Memory with a name ‘A’ we can not retrieve it with

to store 346 in a variablename


named ‘a’.
A. The second A 346
instruction similarly instructs the computer to 478
store 478 in a variable String
named B.variables - To store Bstrings

Thethevariable
Next, we are instructing computerin to which we store text is called string variable.We put a ‘$’ sign at
add the two
Memory

numbers, A and B, and the end


store theof theofname
result of the variable
the addition Sum 824 (Ex- A$) to instruct that the value that will be
in the variable namedstored
Sum. is a string. In a string variable,
(346+478)
alphabets, numbers, word, sentences and
any special symbols can be stored.

Computer Masti

10/26/2017 5:35:58 PM

COMPUTER MASTI
6

Class VII.indd 6 12-05-2022 17:34:35


Moz: The variable
Jyoti: Where in which
do we store text? Is you
therestore
a texttext is called string variable. You have
variable?
to put a $ at the end of the name of a variable (e.g., A$) to instruct that
Moz: The variable in which you store text is called string variable. You have
theputvalue
to a $ atthat willofbethestored
the end name ofis aa variable
string. (e.g.,
In a A$)
string variable,
to instruct thatalphabets,
numbers,
the words,
value that will besentences, and any
stored is a string. In a special symbols
string variable, can be stored. Enter
alphabets,
the following
numbers, words,statements
sentences, and andanysee whatsymbols
special happens.
can be stored. Enter
the following statements and see what happens.
PROGRAM OUTPUT
PROGRAM OUTPUT
Memory
NamePet$ = "Prince" Prince is my pet. Memory
NamePet$ = "Prince" Prince is my pet. NamePet$
Print NamePet$;
Print NamePet$; NamePet$
Print
Print "" isismy
mypet"
pet" Prince Prince

Jyoti: When
Jyoti: When we start a new program, the output of the previous program isprogram
still
cls and clgwe
displayed. Is
start
statements
it
a new
possible to
program,
clear the
the output
Text Output
of the previous
area?
is still
displayed. Is it possible to clear the Text Output area?
Moz: cls clears the Text Output area and clg clears the Graphics Output area.
Whenclswe
Moz: startthe
a new programme, theclgoutput of the previous programme is still
Youclears
can also useText
theseOutput area
statements in and
programs clears
to clearthe
theGraphics
Text and Output area.
displayed.
You can‘els’
Graphics clears
also
Output use the text
these
areas. outputinarea
statements and ‘clg’
programs clears
to clear the the
Textgraphics
and output
area. Graphics Output areas.
PROGRAM OUTPUT

PROGRAM
cls OUTPUT
clg
cls
clg
PROGRAM OUTPUT
Memory
NamePet$ = “Prince” Prince is my pet.
it comes OUTPUT
When I call my pet by its name Prince,
PROGRAM
Print NamePet$;
running to me. NamePet$
Print " is my pet."
Input statement- To take inputPrince
from the user
Print "When I call my pet by its name ";
NamePet$ = “Prince” is my pet.
Prince Memory
Print NamePet$;
Print
Print ",NamePet$;
it comes running to me." When I call my pet by its name Prince,
it comes running to me. NamePet$
Input
Print " is a statement
is my pet." to retrieve the string or numbers that the user types.
Print A
Jyoti: "When
valueI call my pet by
assigned to its name ";variable is enclosed in quotes.
a string Prince
Print NamePet$;
PROGRAM
Print While
Tejas: ", it comes running to
retrieving have to give the stringOUTPUT
weme." variable name in a statement
Printto“Please
retrieve theyour
enter value. We”;have to keep in mind
name: Pleasethat
enterstring variables
your name: | are
Jyoti:Input
AName$
value
also assigned
case sensitive tonumeric
like a stringvariables.
variable is enclosed in quotes.
Print “Hello,";
Tejas:
Input
PrintWhile
Name$ retrieving we have to give the string variable name in a statement
Statement – To take Input from the User
to retrieve the value. We have to keep in mind that string variables are
Jyoti: Wealsowant
PROGRAM
casethe
sensitive
computerlike numeric
to take variables.
input from Input given by the user
the keyboard and print the
OUTPUT
sum of the numbers. What is the statement to take input?
Memory
Input
Moz:Statement
Print
The“Please
answer – To
enter intake
is your Input
name:
your ”; from
question. Inputthe User
Please
is the enter your
statement name: Jyoti
to retrieve the
Input Name$ Hello, Jyoti Name$
strings
Print or numbers that the user types. Enter the following programs and
"Hello,";
Print
runName$
them. Find out how each statement is executed. Jyoti
Jyoti: We want the computer to take input from the keyboard and print the
sum of the numbers. What is the statement to take input?
146 PROGRAM Computer Masti
OUTPUT Cursor
Moz: The answer is in your question. Input is the statement to retrieve the
Input Name$ |
Printstrings
“Hello ” or numbers that the user types.
+ Name$ Enter the following programs and
02_CBSE_CM_Level-6.indd 146
run them. Find out how each statement is executed. 10/26/2017 5:36:04 PM

146 Computer Masti


Rem statement
Moz: You are right. The input statement displays a cursor to indicate that
• The input
# andhas
Remtostatements
be given. are called comment statements.
02_CBSE_CM_Level-6.indd 146
• These are not case sensitive. Input given by the user
10/26/2017 5:36:04 PM

PROGRAM OUTPUT
Memory
Input Name$ Jyoti
Print “Hello ” + Name$ Hello Jyoti Name$
Jyoti

Jyoti:
BASIC 256We enter a name at the cursor. The name that we enter is stored in the
7
string variable Name$.
Tejas: Next, a message is displayed using the name that was stored in Name$.
Class VII.indd 7
The string stored in Name$ is retrieved and displayed. 12-05-2022 17:34:35

Moz: Now, can you explain the program below?


• The BASIC application ignores the rest of the text on the line which begins with #
or Rem.
• Comments make a program easier to understand.
Graphic Statements

Graphics output area has X and Y coordinates ranging from Oto 299 each, starting
from the top-left corner. The greed of X and Y coordinates are given below.
Graphics OutputTejas:
area in There is a XGraphics
axis Output area in X axis
(0,0) (299,0)
C-256 program interface. the(0,0)
BASIC-256 program interface.(299,0)
we get output on this area? How do we get output on this area?
(50,50) (50,50)
Y Y
amiliar with x and y
Moz: You are
a familiar with x and y a
es. The Graphics Output coordinates.
x
The Graphics Output x
i i
and y coordinates, area has
s x and y coordinates, s
(200,150)
om 0 to 299 each, startingranging from 0 to 299 each, starting (200,150)
op-left corner. (200,125)
from the top-left corner. (200,125)
ew the grid of x and y
es? Jyoti: Can we view the grid of x and y
(0,299)
coordinates? (0,299)
an. You have to enable the
Moz:
Window Grid Lines optionYes, youView
in the can.menu.
You have
Now, to enable
enter the the
statements.
EnableWindow
Graphics the Graphics
Grid Lineswindow
option in thegrid line
View option
menu. in the
Now, enter the View menu. Now enter the
following
following statements.
statements.
clg: statement clears the graphics
output area.
color: Statement specifies the
drawing colour and direct draws a
rectangle in blue.
rect statement: draws a rectangle,
where 0,0 are the X and Y
coordinates of the rectangles
top left corner and the next two
numbers, 300,300 are its length and
breadth. In this case they are equal.
Hence we have a square.
PROGRAM OUTPUT
clg (0, 0)
X
color blue
rect 0,0,300,300
300

tatement clears the Graphics Output area. The next statement, 300

cifies the drawing colour.


Moz: Yes. A rectangle can be drawn by giving the (x, y) coordinates of its top-
u can specify a colour by using the name of the colour. left corner, and its length and breadth.
Tejas: Syntax: Rect x,clears
The first statement
statement, rect, draws a rectangle in blue.
y, length, breadth
the Graphics Output area. The next statement,
Tejas: So, 0, 0 are the x and y coordinates of the rectangle’s top-left corner, and
the next two numbers 300, 300 are its length and breadth.
color, specifies the drawing colour.
Rect statement uses the current drawing colour and draws a rectangle on the In this case they are equal, hence we have a square.
Moz: Right. You can specify a colour by using the name of the colour.
Graphics Output area. The first two numbers specifyRectthe Statement
x and y coordinates of
Jyoti: The next statement, rect, draws149
a rectangle in blue.
the rectangle’s top left corner. The next two numbers specify the length and
Syntax: Rect x, y, length, breadth

breadth respectively. (x, y)


Info

The rect statement uses the current drawing colour and X


draws a rectangle on the Graphics Output area. The first two
numbers specify the x and y coordinates of the rectangle’s Breadth
BASIC Programming 10/26/2017 5:36:10 PM
149top-left corner. The next two numbers specify the length and
breadth respectively.
Length

COMPUTER MASTI
8 Jyoti: Next, the colour is changed to yellow. The circle statement draws a circle.
The first two numbers (145, 150) must be the (x, y) coordinates of the
02_CBSE_CM_Level-6.indd 149 10/26/2017 5:36:10 PM
centre. The third number (150) is the radius.
Moz: Yes. The (x, y) coordinates of the centre and the radius of the circle have
to be given to draw a circle.
Class VII.indd 8 12-05-2022 17:34:36
Tejas: Next, another colour, red, is specified. Then a red-coloured circle of
radius 100 is drawn. It has the same centre (145, 150), as the previous
circle.
PROGRAM OUTPUT
The first two numbers (145, 150) must be the (x, y) coordinates of the
centre. The third number (150) is the radius.
Moz: Yes. The (x, y) coordinates of the centre and the radius of the circle have
to be given to draw a circle.
Circle Statement Tejas: Next, another colour, red, is specified. Then a red-coloured circle of
radius 100 is drawn. It has the same centre (145, 150), as the previous
Circle Syntax:
statement: circle.
Circle x, draws
y, radiusa
OUTPUT
circle. The first two numbers PROGRAM

(145,150) must be the X and Y color blue


Info
The circle statement uses the current rect 0,0,300,300
color yellow
coordinates of the centre, the circle 145,150,150
drawing color and draws a filled circlecolor red
(x, y) (145, 150)
×100
third number 150atis(x,the radius. X

0
15
with its centre y) and the circle 145,150,100 r
Next colour
specifiedred is specified that
radius.
a red coloured circle of the radius 100 is drawn. It has the same centre (145,150)
as the previous circle. 150 Computer Masti

Tejas: In all these statements, the radius and the (x, y) coordinates of the centre
Syntax: circle
areX,already
Y, radius.
given.
The Circle statement uses the current drawing colour
02_CBSE_CM_Level-6.indd 150 10/26/2017 5:36:12 PM

Jyoti: Let us try whether we can draw a circle and rectangle by taking values
and Rodraws a filled circle with its centre at (X, Y) and (x, y)
from the user instead.
the specified radius. x r
Moz: Which statement will you use to take values from the user?
Note: We can take values from the user using an input
Tejas: Input
statement statement.
to draw a rectangle, square and a circle.
Moz: Go ahead and try it.
PROGRAM OUTPUT
Memory
Rem To draw a rectangle Text Output
Print "Give the x and y coordinates of the Give the x and y coordinates of x1 0
top-left corner of the rectangle: " the top-left
y1 0
Input "x coordinate: ", x1 corner of the rectangle:
Input "y coordinate: ", y1 x coordinate: 0 length1 200
y coordinate: 0
Input "Length of the rectangle: ", length1
Length of the rectangle: 200 breadth1 250
Input "Breadth of the rectangle: ", Breadth of the rectangle: 250 x2 200
breadth1 Give the x and y coordinates of
Color Yellow the centre: y2 150
Rect x1, y1, length1, breadth1 x coordinate of centre: 200 r 100
Rem To draw a circle y coordinate of centre: 150
Radius of circle: 100
Print "Give the x and y coordinates of the
centre:” Graphics Output
Input "x coordinate of centre: ", x2
Input "y coordinate of centre: ", y2
Input "Radius of circle: ", r
Color Green
Circle x2, y2, r

Tejas: By using the input statement, the user can give values and draw a circle
or a rectangle.
Moz: Now use all the statements that you have learnt and write a program.
You can also use graphical statements with other kinds of statements in
your program.

BASIC Programming 151

BASIC 256
9
02_CBSE_CM_Level-6.indd 151 10/26/2017 5:36:13 PM

Class VII.indd 9 12-05-2022 17:34:36


circle 150,150,70
# put on the eyes
color black
circle 105,110,15
circle 185,110,15

WORKSHEET
1. Some BASIC-256 commands are given below. Select the correct output area for each
command.
(a) Print “Hello there.” Text Output area / Graphics Output area
(b) Rect 100, 100, 200, 50 Text Output area / Graphics Output area
(c) Input “Enter a number: ”, A Text Output area / Graphics Output area
2. Given here are some BASIC-256 commands and their possible outputs. Circle the
correct output for each.

(a) PROGRAM (b) PROGRAM


Print 200+(75+10)/5-3 Print (545+35)3

i) 142.5 i) 1740
ii) 214 ii) Syntax error around character 15.
iii) 274 iii) (54535)3
iv) 200+(75+10)/5-3 iv) (545+35)*3

(c) PROGRAM (d) PROGRAM


BASIC Programming
Print "Plants can be classified into "+ "trees, Print “Hi, there! ”; 153
shrubs and herbs." Print “Welcome to BASIC. ”

i) “Plants can be classified into” i) Hi, there! Welcome to BASIC.


02_CBSE_CM_Level-6.indd 153
“trees, shrubs and herbs.” ii) “Hi, there!” “Welcome to
10/26/2017 5:36:17 PM

ii) Plants can be classified into BASIC.”


trees, shrubs and herbs. iii) Hi, there! Welcome to BASIC.
iii) Syntax error on line 1. iv) “Hi, there!” “Welcome to
iv) “Plants can be classified into” BASIC.”
+ “trees, shrubs and herbs.”

(e) PROGRAM (f) PROGRAM


HeroName$=”Napoleon” Print “BODMAS: (25+35-10*100) =”
Print HeroName; + (25+35-10*100)
Print “was a military leader of France.”

i) “Napoleon was a military i) “BODMAS: (25+35-10*100) =”


leader of France.” + (25+35-10*100)
ii) Napoleon was a military leader ii) BODMAS: (25+35-10*100) =
of France. -940
iii) ERROR on line 2: Unknown iii) BODMAS: (25+35-
variable HeroName 10*100) = (25+35-10*100)
COMPUTER MASTI
10
iv) Napoleon was a military leader of iv) -940
France.
Class VII.indd 10 12-05-2022 17:34:36
(g) PROGRAM OUTPUT
Rem Find the sum of apples with Ali and Savani. Type in the number of apples with Ali: 67
Type in the number of apples with
i) “Napoleon was a military i) “BODMAS: (25+35-10*100) =”
leader of France.” + (25+35-10*100)
ii) Napoleon was a military leader ii) BODMAS: (25+35-10*100) =
of France. -940
iii) ERROR on line 2: Unknown iii) BODMAS: (25+35-
variable HeroName 10*100) = (25+35-10*100)
iv) Napoleon was a military leader of iv) -940
France.

(g) PROGRAM OUTPUT


Rem Find the sum of apples with Ali and Savani. Type in the number of apples with Ali: 67
Print “Type in the number of apples with Ali:” ; Type in the number of apples with
Savani: 28
Input A
Print “Type in the number of apples with
Savani: ” ;
Input B
Sum = A+B
A$ = “The total number of apples is ”
Print A$+Sum

i) “The total number of apples is” Sum


ii) Syntax error on line 1 around column 7
iii) The total number of apples is 95
iv) 95

3. Anand has written a program to find the profit or loss for a given selling price and
154cost price. When he ran the program it gave an error as shown below. Computer Masti
PROGRAM OUTPUT
CostPrice$ = 500 Error assigning a string to a numeric
SellingPrice$ = 450 variable.
02_CBSE_CM_Level-6.indd 154 10/26/2017 5:36:20 PM
Loss = CostPrice$ - SellingPrice$
Print Loss

Upon seeing the error message he realised that he had made more such errors. Can
you correct all the errors in the program?

4. Study the program and answer the following questions.


PROGRAM OUTPUT

Input “Your name is ”, Name$ Error assigning a string to a numeric


variable.
Input “Which school do you study in?”, School$
Input “What is your age?”, Age
Input “What is your date of birth?”, Birthdate
Input ”In which month were you born? ”, Birthmonth$

(a) Circle the correct option.


i) What String/Integer is being stored in the variable School$?
String/Integer or decimal number
ii) What String/Integer is being stored in the variable Birthdate?
String/Integer or decimal number
BASIC 256
(b) What are the numeric variables in the above program? 11
5. Here are some commands in BASIC-256. What is the function of each command? Fill
Class VII.indd 11
in the blanks with the correct options. 12-05-2022 17:34:37

(a) In “circle 100, 150, 10”, 10 is the .


i) radius of the circle ii) x coordinate of the circle’s centre
Input ”In which month were you born? ”, Birthmonth$

(a) Circle the correct option.


i) What String/Integer is being stored in the variable School$?
String/Integer or decimal number
ii) What String/Integer is being stored in the variable Birthdate?
String/Integer or decimal number
(b) What are the numeric variables in the above program?
5. Here are some commands in BASIC-256. What is the function of each command? Fill
in the blanks with the correct options.
(a) In “circle 100, 150, 10”, 10 is the .
i) radius of the circle ii) x coordinate of the circle’s centre
iii) y coordinate of the circle’s centre iv) diameter of the circle
(b) In “Rect 110, 5, 20, 18”, 110 and 5 are the .
i) length and breadth of the rectangle
ii) x and y coordinates of the top-left corner of the rectangle
iii) length and diagonal of the rectangle
iv) None of the above
(c) ‘cls’ clears .
i) the Text Output area ii) the Graphics Output area
iii) the command area iv) the entire screen

(d) Rem is used to .


i) add
BASIC Programming comments to a program ii) remove a command 155
iii) erase the Graphics Output area iv) None of the above
6. A program which draws a picture is given below with comments. Read and follow the
commands and draw the picture in the graph area given below.
02_CBSE_CM_Level-6.indd 155 10/26/2017 5:36:22 PM

X axis
Rem My little red car! 100
(0,0) 50 150 200 250 300
clg
Rem to draw the top portion of the car
Color Red Y 50
a
Rect 100, 0, 100, 50 x
Rem to draw the lower portion of the car i 100
s
Color Red
150
Rect 50, 25, 200, 50
Rem to draw wheels 200
color black
circle 100, 75, 25 250
circle 200, 75, 25
300

7. Given here is a program which finds the perimeter and area of a rectangle.
PROGRAM OUTPUT
# Program to find the area and perimeter of a rectangle. Length of the rectangle = 50
Print "Length of the rectangle = 50" Breadth of the rectangle = 5
Print "Breadth of the rectangle = 5" Area = 250
Area = 50*5 Perimeter = 110
Perimeter = 2*(50+5)
Print "Area = "+ Area
Print "Perimeter = "+ Perimeter
COMPUTER MASTI
12
(a) Change and write the program, so that the length and breadth can be given by
Class VII.indd 12
the user. Give your own input for the program in the Text Output area, and 12-05-2022 17:34:37
calculate the area and perimeter.
(b) Find how many tiles with the dimensions given by you in the above program are
Color Red
150
Rect 50, 25, 200, 50
Rem to draw wheels 200
color black
circle 100, 75, 25 250
circle 200, 75, 25
300

7. Given here is a program which finds the perimeter and area of a rectangle.
PROGRAM OUTPUT
# Program to find the area and perimeter of a rectangle. Length of the rectangle = 50
Print "Length of the rectangle = 50" Breadth of the rectangle = 5
Print "Breadth of the rectangle = 5" Area = 250
Area = 50*5 Perimeter = 110
Perimeter = 2*(50+5)
Print "Area = "+ Area
Print "Perimeter = "+ Perimeter

(a) Change and write the program, so that the length and breadth can be given by
the user. Give your own input for the program in the Text Output area, and
calculate the area and perimeter.
(b) Find how many tiles with the dimensions given by you in the above program are
needed to cover the floor of a room of length 1000 units and breadth 500 units.
PROGRAM OUTPUT
# Program to find the number of tiles.
RoomArea=1000*500
Print "Area of the room=" + RoomArea
TileArea=________________
Print "Area of the tile=" + TileArea
TileNumber=RoomArea/TileArea
Print "Number of tiles=" + TileNumber

(c) Write a similar program to find the area and perimeter of a triangle.

8.  Fill in the Blanks:


(a) To instruct the computer we need ___________.
156 Computer Masti

(b) HLL stands for ____________________________.


(c) Basic 256 is a __________________ language.
(d) ______ statement clears the text output.
02_CBSE_CM_Level-6.indd 156 10/26/2017 5:36:23 PM

9.  Find whether the following statements are True or False


(a) A variable name should begin with alphabet.
(b) print statement used to display text in graphics output area.
(c) Variable name abc and ABC can be consider as the same variable name.
(d) rem statement is used to write comment in Basic 256.
(e) rect statement can be used to draw a square.

BASIC 256
13

Class VII.indd 13 12-05-2022 17:34:37


10. Answer the following questions in brief.
(a) What are the three types of programming languages?
(b) Which button allows you to run the program in Basic 256?
(c) What is the use of cls and clg statements?
(d) Write the statement to draw a circle

11. Answer the following questions


(a) What are the features of Basic 256 programming language?
(b) Write the rules for variable naming in Basic256?

Lab Activity:
LAB ACTIVITY Lab Activity:
ACTIVITY 1. Create a simple dart board using Basic-256 graphical user interface.
1. Create a simple dart board using Basic-256 graphical user interface.
1. Create
1. Attempt the following:
a simple dart board using Basic-256 graphical user interface.
(a) Run the following program and find out its display.
clg
circle 35,20,8
clg
circle 45,20,8
clg
circle 55,20,8
clg
circle 65,20,8
clg
circle 75,20,8
(b) Change the clg command to cls and then run the program. What do you observe?
(c) What will you do2.to makeCreatethe object light
a traffic moveusing
alongBasic
the Y-axis
256 instead?
2. Savani, Ali and Asmit went for a picnic. Each one
carried
2. Create `100 towards
a traffic expenses.
light using Write a program to
Basic 256
2. Create
find the following. Include a traffic
proper lightsousing
comments that Basic 256
others are able to understand your program.
(a) At the picnic they went on a ride. The cost of
each ticket was `30. Find the amount left with
each after the ride.
(b) Savani had an ice cream that cost `20,
Ali had orange juice that cost `25, and
Asmit had an ice cream that cost `30.
Then they returned home.
How much money is left with each of
them now?
3. Group Activity Activity and Project
(a) Use some coloured marble papers and glue to make the patterns given below.
COMPUTER MASTI
14 You have to meet the following conditions while making these patterns –
i) You can use only rectangles and circles.
Activity and Project
ii) You have to arrange the papers one above the other to make the required
Class VII.indd 14 12-05-2022 17:34:37
pattern.
iii) Then, write programs to make similar patterns using BASIC-256.
ACTIVITY
1. Attempt the following:
(a) Run the following program and find out its display.
clg
circle 35,20,8
clg
circle 45,20,8
clg
circle 55,20,8
clg
circle 65,20,8
clg
circle 75,20,8
(b) Change the clg command to cls and then run the program. What do you observe?
(c) What will you do to make the object move along the Y-axis instead?
2. Savani, Ali and Asmit went for a picnic. Each one
carried `100 towards expenses. Write a program to
find the following. Include proper comments so that
others are able to understand your program.
(a) At the picnic they went on a ride. The cost of
each ticket was `30. Find the amount left with
each after the ride.
(b) Savani had an ice cream that cost `20,
Ali had orange juice that cost `25, and
Asmit had an ice cream that cost `30.
Then they returned home.
How much money is left with each of
them now?
3. Group Activity
(a) Use some coloured marble papers and glue to make the patterns given below.
You have to meet the following conditions while making these patterns –
i) You can use only rectangles and circles.
ii) You have to arrange the papers one above the other to make the required
pattern.
iii) Then, write programs to make similar patterns using BASIC-256.

BASIC Programming 157


BASIC 256
15
02_CBSE_CM_Level-6.indd 157 10/26/2017 5:36:33 PM

Class VII.indd 15 12-05-2022 17:34:37


PROJECT
Similar to the funny story program in the lesson, write a program to take input from
the user about 5 animals, their food habits, and their sounds. Using the inputs, build an
interesting story about the animals. You must use all the BASIC programming statements
that you have learnt in the lesson at least once. For example, you can have a situation
where the animals:
(a) Have gone for a picnic. (b) Are visiting a mall to buy food.

Explore!

1. Explore the Debug option in BASIC-256.


2. Find out how to export text and Graphics Output of a program to a file.

Facilitator’s Corner Lesson 7


• The purpose of this lesson is to teach the students a new programming language, BASIC-256. The students are already
familiar with another programming language, Scratch. Ask the students to recall the features of Scratch. Now tell them
that just like Scratch, BASIC is another programming language.
• Open the latest version of BASIC-256 and show the interface. Let the students become familiar with the interface. Ask
questions to draw their attention to the new icons they see on the menu bar.
• Show them an example which has both text and graphic output to show the functions of these new icons. This exercise
will also make them familiar with the different parts of the interface like the program area, the Text Output area and
the Graphics Output area.
• Write on the blackboard, Print ‘Hello World’. Now demonstrate the same by typing this on the Basic-256 interface
and then press the ‘Run’ icon to see the output.
• Now type another Print statement without the quotes. Show the syntax error message. Explain to them the importance
of correct syntax. Correct it and run it again. Also draw attention to the colour code used in the BASIC-256 interface
for various commands.
• Ask them to recall the BODMAS rule already taught in mathematics while teaching arithmetic expressions. Point out
the difference between a numeral and a string. Demonstrate how the use of the ‘+’ operator gives different results in
case of numeric and string variables. Solve question 2 of the worksheet, which reinforces the knowledge of arithmetic
operators and print statements.
• Ask them to recall the commands for retrieving inputs from the user in Scratch. Tell them that similarly, the
command used in BASIC-256 is ‘Input’. Demonstrate the syntax of the Input command.
• Once the students are comfortable with the syntax of the above commands, proceed to the Graphics Output area.
Demonstrate the ‘Rect’ and ‘Circle’ syntax. Teach them about the size and coordinates of the
graphics area.
Clear the Graphics Output area using the ‘Clg’ statement. Draw attention to the fact that like ‘Clg’ statement, ‘Cls’
statement clears the Text Output area. Solve question 4 of the Worksheet and Activity 1, which will check students’
understanding of these commands.
• Tell them ‘Rem’ is another important statement which helps us to add comments to program segments and enhance
the readability of the code. Finally students can attempt Activity 2 where they can write a program using some of the
commands taught in the lesson. Ask them to complete the project as practice work.
Further Reading:
http://www.basic256.org/index_en
http://sourceforge.net/projects/kidbasic/

158 Computer Masti


COMPUTER MASTI
16

02_CBSE_CM_Level-6.indd
Class VII.indd 16 158 10/26/2017 5:36:35
12-05-2022 PM
17:34:37
NOTES

Class VII.indd 23 12-05-2022 17:34:38

You might also like