A Textbook of Computer - Foundation of Information Technology-8
A Textbook of Computer - Foundation of Information Technology-8
KEY FEATURES
Text is presented in a clear and simple language, with enhanced visual appeal.
All the ideas and concepts are explained with clear-cut and practical examples.
d
Lt
Each and every topic is thoroughly researched and certified by consultant teachers from schools.
t.
The illustrations given in the chapters lend enormous support as learning aids.
Pv
For the Teacher boxes provide teaching ideas and tips for the teachers.
a
Did You Know and Note boxes impart more information and interesting facts about the topic being
di
discussed.
In
An exhaustive set of questions and activities are given at the end of each chapter to reinforce
rs
learning and develop practical computer skills.
he
Revision exercises and Project work at the end of the book help to sharpen the concepts learnt in
is
the chapters.
bl
Pu
Sample questions based on National Cyber Olympiad at the end of the book help students prepare
for the Olympiads.
n
illa
ITL Education Solutions Limited (ITL ESL) is a part of the ITL group which has operations all over
the world with a significant presence in education and IT-enabled services. It specialises in handling
m
educational projects in IT domains with a dedicated R&D wing of industry experts that helps in designing
ac
and developing content.
M
We will be happy to respond to you on any query relating to the series.
©
Write to us at [email protected]
` 435
All rights reserved under the copyright act. No part of this publication may
be reproduced, transcribed, transmitted, stored in a retrieval system or
translated into any language or computer language, in any form or by any
means, electronic, mechanical, magnetic, optical, chemical, manual, photocopy
or otherwise without the prior permission of the copyright owner. Any person
who does any unauthorised act in relation to this publication may be liable
to criminal prosecution and civil claims for damages.
d
Cuttack Guwahati Hyderabad Jaipur Lucknow Madurai
Lt
Nagpur Patna Pune Thiruvananthapuram Visakhapatnam
t.
ISBN: 978-93-9006948-4
Pv
Designed and developed by the Research & Development Wing,
a
ITL Education Solutions Ltd., 2nd Floor, GD-ITL Towers,
di
Netaji Subhash Place, Pitampura, New Delhi 110 034 In
Published by Macmillan Publishers India Private Ltd,
rs
Printed at
b lis
Pu
n
illa
m
ac
“This book is meant for educational and learning purposes. The author(s) of the book has/have taken all reasonable care to
ensure that the contents of the book do not violate any existing copyright or other intellectual property rights of any person in any
M
manner whatsoever. In the event the author(s) has/have been unable to track any source and if any copyright has been inadvertently
©
ACKNOWLEDGEMENTS
We are immensely thankful to Ms Anne Dias, M.A., M. Ed., Director – Special Projects, Academic and Continuous Professional
Development, Ms Tracy Cardoz, M.A. M. Ed., Vice President – Curriculum Development, Ms Jaya Venkatram, M.A, B.Ed.,
A.G.M. – Curriculum Development and Dr Shefali Bharti, Ph.D., Sr. Manager – Academics Operations, VIBGYOR Group
of Schools, Mumbai for their active interest in promoting excellence in education and their invaluable contribution in the
successful completion of the project. Their guidance in designing the content and course structure for the series with regular
quality check has made the product par excellence.
We would also like to thank the Curriculum development team members Mr Sankalp Korde and Ms Shraddha Kambli along
with the Heads of the Computer Science Department Ms Amreen Khan, Ms Shruti Kamat, Ms Puja Kumar and Ms Sarla Devi
and all the Computer teachers of the VIBGYOR Group of Schools for their constant inputs and support during the making
of this series.
d
Lt
The book discusses various software applications including LibreOffice Base, Python and App
t.
Development. The book has been designed with emphasis on interactive and creative approach. It
Pv
serves as an ideal classroom support for computer education. It is based on the latest guidelines
a
of National Curriculum Framework (NCF), NCERT and all major state boards.
di
The book incorporates the features of a textbook, a workbook as well as a manual to ensure
In
maximum benefit to the student.
rs
he
Key Features
lis
• Text is presented in a clear and simple language, with enhanced visual appeal.
b
• All the ideas and concepts are explained with clear-cut and practical examples.
Pu
• Each and every topic is thoroughly researched and certified by consultant teachers from schools.
n
• The illustrations given in the chapters lend enormous support as learning aids.
illa
• For the Teacher boxes provide teaching ideas and tips for the teachers.
m
• Did You Know and Note boxes impart more information and interesting facts about the topic
ac
being discussed.
M
• An exhaustive set of questions and activities are given at the end of each chapter to reinforce
©
Rohit Khurana
Founder and CEO
ITLESL
d
Lt
t.
5 Introduction to Python 65
Pv
a
6 Advanced Features of Python di 90
In
rs
he
8 Networks 122
n
illa
Revision 143
Terminology 146
d
Let’s start!
Lt
operating systems.
t.
Pv
a
di
In
rs
he
b lis
Pu
n
Contents
illa
Software
ac
The keyboard, monitor, mouse, scanner, printer, speakers, web camera and
microphone are some examples of computer hardware. Computers operate according
to the instructions given to them, as they do not work or take decisions on their own.
Hence, it is necessary to instruct computers to solve a problem. These instructions are given
to the computers by software. A computer needs both hardware and software to work.
A computer with only the hardware is just like an empty box which is useless unless it is
provided with the necessary software.
1.1 SOFTWARE
Software is an organised collection of computer data and instructions. It is responsible
for controlling and managing the hardware components of a computer.
1
d
is developed
Lt
t.
Portability: The ability of the software to be used across different platforms (different
Pv
operating systems) as well as different hardware
a
1.1.2 Types of Software
di
In
Software can be categorised into application software and system software.
rs
he
and databases, drawing and colouring pictures, sending e-mail, designing graphics,
b
Pu
System software: The software that manages and controls all activities in the computer
system is known as system software. It carries out the hardware functions such as
m
ac
computer hardware. The operating system is the most important system software.
©
Software
Application System
Software Software
d
Lt
An operating system (OS) is a set of programs which controls the working of a computer
t.
system. It manages the computer hardware and software, and provides common services
Pv
for computer programs. It is the first program that gets loaded into the computer’s memory
when the computer is switched on. Every computer, be it a desktop, laptop, or a tablet,
a
di
needs operating system to work. Microsoft Windows (such as Windows 10, Windows 8,
In
Windows 7, Windows Vista and Windows XP), Mac OS, Linux, Ubuntu, and Android are
rs
(a) Microsoft Windows (b) Mac OS (c) Linux (d) Ubuntu (e) Android
m
ac
d
Lt
Processor management: An operating system manages the allocation of the processor
t.
(CPU) to the processes in run and deallocates the processor when it is no longer
Pv
required by a process. It does it in a way that the processor remains occupied most
of the time.
a
di
Memory management: It keeps track of the computer’s memory like what part of
In
memory is in use and by whom, and what part is free. It allocates memory to various
rs
Device management: It controls the working of all the input and output devices of
lis
the computer. It keeps track of which device is busy with which process and for how
b
much time.
Pu
File management: It manages the files and folders stored on different storage devices.
n
illa
It allocates a file (opens the file) for use and deallocates it (closes the file) after use.
m
d
interaction are well-served by batch operating system.
Lt
t.
Time-sharing operating system: Time-sharing operating systems allow multiple
Pv
people, located at various terminals, to use a single computer system at the same
time. Multiple jobs are executed by the CPU by switching between the jobs at a very
a
di
high speed, making each user get immediate response. This gives a feeling to a user
In
that only he/she is using the computer.
rs
processing system in which the time interval required to process and respond to
lis
inputs is very small. RT Linux, Symbian OS, VX Works are some examples of real-
b
processors to serve multiple real-time applications and multiple users. Data processing
illa
jobs are distributed among the processors accordingly. The processors communicate
m
with one another through various communication lines such as telephone lines.
ac
Processors in a distributed system may vary in size and function. The World Wide
M
d
Lt
t.
Pv
a
di
In
rs
he
b lis
Pu
n
illa
A GUI-based operating system provides users the graphical means to interact with the
©
system. The operating system displays icons, buttons, dialog boxes, etc., on the screen.
The user sends instructions by moving a pointer on the screen (generally, a mouse) and
selecting certain objects by pressing buttons on the mouse while the mouse pointer is
pointing at them. Typically, a GUI is more resource-consuming than a CUI. With advancing
technology, programmers and designers have been creating complex GUI designs that
work with more efficiency, accuracy and speed.
d
Lt
t.
Pv
a
di
In
Icon
rs
he
Pointer
blis
Pu
n
illa
Window
Menu
m
ac
GUI systems require both the mouse and CUI systems just require a keyboard to
keyboard. work.
Windows, Linux and Mac OS are examples MS-DOS and UNIX are examples of CUI-
of GUI-based operating systems. based operating system.
Points to
Remember
d
Lt
Software is an organised collection of computer data and instructions.
t.
Pv
The four characteristics of software are reliability, efficiency, functionality and
portability.
a
di
Software can be categorised into application software and system software.
In
The operating system is the most important system software. It is a set of programs
rs
he
User interface (UI) refers to the means by which the user interacts with a computer
n
system.
illa
m
User interfaces are broadly divided into two categories: character user interface
ac
Exercises
1. Tick (ü) the correct option.
a. Which of the following is responsible for managing computer hardware and
software?
(i) Operating system (ii) Utility software
(iii) Language translator (iv) None of these
d
Lt
(iii) Batch-processing system (iv) None of these
t.
Pv
e. Which of the following is not an element of GUI?
a
(i) Window (ii)
Icon
di
In
(iii)
Command prompt (iv)
Menu
rs
different platforms.
m
ac
d
Lt
t.
Pv
Activities
a
1. di
Go to your computer lab and make a list of operating systems being used on the
In
computers there.
rs
2. With the help of the Internet, collect information about different types of operating
he
systems and their features. Make a presentation for the same in Impress.
b lis
Pu
Ask students about software and its types learnt in the previous classes.
m
ac
Explain to students about operating systems along with their features and
M
functions.
©
10
d
Lt
t.
Pv
a
di
In
rs
he
b lis
Pu
n
illa
Contents
m
ac
d
text file. It uses a simple structure with a single table. LibreOffice Calc and Microsoft
Lt
Excel are examples of flat file databases.
t.
Pv
Structured database: A structured database contains a number of tables arranged
in an order and interconnected with each other through special fields. LibreOffice
a
di
Base, Microsoft Access, FoxPro, DBase and Oracle are some examples of structured
In
database.
rs
he
Database models refer to the way of designing a database and storing information in it.
b
There are three types of database models, namely, hierarchical, network and relational.
Pu
The most commonly used database model is the relational data model in which information
n
is stored in the form of tables and different tables are related through common fields.
illa
The DBMS design based on a relational model is known as the Relational Database
m
The basic components of a DBMS are table, record and field. A table represents data
in the form of rows and columns. In a DBMS, rows are called records and columns are
called fields. A field holds one piece of information about an item. Multiple related fields
combine to form a record and finally, multiple records combine to form a table.
Fields
d
in many files. However, in database management systems, the data is stored at a
Lt
central location and shared by all the users. As a result, data redundancy is reduced.
t.
Pv
Reduced inconsistency: When there are two or more files containing the same data
and one file is updated, while the other file contains the old data, the data is said to
a
di
be inconsistent. Most of the database management systems are designed to eliminate
In
data inconsistency as data is stored at a central location.
rs
Sharing data: The data stored in the database can be shared by a number of users
he
Data security: Due to centralised storage of data, security constraints can be easily
b
enforced. This ensures that the data is accessed only through authorised channels.
Pu
Various security tools such as user codes and passwords can be used to control
n
help feature. This feature can be used whenever a user faces some problem while
ac
Backup and recovery: Most of the DBMSs come with backup and recovery tools that
©
d
Lt
Report: It defines a medium through which you can present data in a professional
format. Generally, a report is used to obtain a ‘printed copy’ of the data.
t.
Pv
Starting LibreOffice Base
a
To open LibreOffice Base, follow these steps.
di
In
1. Click the Show Applications icon ( ) at the bottom of the Launcher.
rs
2. Type LibreOffice Base or Base in the search bar if it is not already listed.
lis
d
Lt
t.
Pv
a
di
In
rs
he
b lis
1. In the Database Wizard window, select the Create a new database option
M
2. Click the Next button to move to the next screen of the wizard. Here, you can find
the following options.
Yes, register the database for me: Select this option if you want to register your
database with the LibreOffice website.
No, do not register the database: Select this option if you do not want to register
your database with the LibreOffice website. Since we are in the learning phase,
it is recommended to choose this option for now.
Open the database for editing: Select this check box if you want the database
to open immediately after you save it. It saves the time to reopen the database.
Create tables using the table wizard: Select this check box if you want to create
tables in the database through Table Wizard.
15
3. Choose the desired option and click the Finish button. This displays the Save dialog
b
box.
Pu
4. Specify the location where you want to save your database from the left pane of the
n
dialog box.
illa
Note
In LibreOffice Base, a database is saved with the .odb extension.
Database Window
The Database window is divided into five sections as shown in Fig. 2.6.
Description
Tasks
d
section
Lt
section
t.
Pv
a
di
In
rs
he
b lis
Pu
n
illa
m
ac
M
©
The Database section displays icons for the objects that you can create in your
database.
The Tasks section displays the options for creating the object selected in the Database
section.
The Description section provides description of the option you select or point with
the mouse in the Tasks pane.
17
d
then follow these steps.
Lt
1. Click the File menu and then click Open.
t.
Pv
OR
Click the Open icon ( ) on the Standard toolbar.
a
The Open dialog box appears.
di
In
2. Locate and select the database you want to open.
rs
he
b lis
Pu
n
illa
m
ac
M
©
d
Lt
t.
Pv
a
di
In
rs
he
lis
2. Click the Create Table in Design View option under the Tasks section. The Table
n
d
Lt
specified as 25 and you store only six
t.
characters then trailing spaces are padded
Pv
with blanks. The default length of this data
type is 100.
a
Text [VARCHAR]
di
This is the default data type that stores
In
only the characters entered by the user,
rs
digits.
Small Integer [SMALLINT] It can store integers or whole numbers.
©
d
are available for entering dates; the default
Lt
format is MM/DD/YY.
t.
Pv
Time [TIME] It is used to store time values by storing
information on hours, minutes and seconds.
a
di
Various formats are available for entering
In
time; the default format is HH:MM:SS.
rs
information.
©
Field Properties section: This section is used to define the properties of the fields in
a table. The properties of the fields are dependent on the data types. Each data type
has a different set of properties. Some of the common properties are Entry required,
Length, Decimal places, Default value and AutoValue.
21
d
Lt
Length: 10
t.
To create the sample table in the Table Design window, follow these steps.
Pv
1. In the Field Definition section, type the name of the first field of your table (that is,
a
di
Roll Number) under the Field Name column. In
2. Select the required data type for the field, that is, Integer [INTEGER], from the drop-
rs
3. Type a description about the field under the Description column, if required.
lis
4. In the Field Properties section, specify the desired properties for the field. For example,
b
select the Yes option from the Entry required drop-down list.
Pu
5. Similarly, enter other fields of the table and specify the desired properties.
n
illa
m
ac
M
©
8. Click OK. A message window appears that prompts you to create a primary key for
d
the table. Click Yes to let Base automatically create a primary key for the table, click
Lt
No if no primary key is required and click Cancel to remain in the design view.
t.
Pv
a
di
In
rs
he
b lis
Pu
n
illa
A primary key is the field that has a unique value across all occurrences in the table.
©
In other words, when a field is set as a primary key, it ensures that no two records in the
database contain the same value for that field. It is the field that uniquely identifies the
records in a table. For example, the roll number of a student is unique as two students
cannot have the same roll number in the same class. Hence, in a table containing data
about students, the roll number is the primary key.
You can also create a primary key even after creating a table. For example, to set the
Roll Number field as the primary key in the Result table, follow these steps.
1. Select the Roll Number field. To select, click on the grey area on the leftmost corner
of the field. The entire row gets highlighted.
2. Right-click on the green arrow icon( ) beside the selected field and select the
Primary Key option from the shortcut menu that appears.
23
3. Click the Close button ( ) on the top-right corner of the Table Design window to
lis
close the table. Base prompts a message window that asks you to save changes.
b
Pu
d
Lt
t.
Pv
a
di
In
rs
he
Fig. 2.15 Selecting the sample table in the Table Wizard window
lis
4. Click on the field you want in your table in the Available fields list box. To select
b
Pu
multiple fields, hold down the Ctrl key and then click on the field name.
5. Click the ( ) button to move the selected field(s) from the Available fields list box
n
illa
to the Selected fields list box. If you want to include all the available fields in your
table, simply click the ( ) button.
m
ac
M
©
d
Lt
t.
Pv
a
di
In
Fig. 2.17 Setting field types and formats
rs
he
7. Click the Next button. The next screen of Table Wizard appears which prompts you
lis
8. Select the desired option, for example, we have selected Automatically add a primary
key option for now, and click the Next button.
n
illa
m
ac
M
©
d
Lt
t.
Pv
a
di
In
rs
he
10. Click the Finish button. You can see the table you just created listed under the Tables
Pu
section in the Database window. Also, the Table Data View window opens up where
n
Lt
Fig. 2.20 Table created using Table Wizard
t.
Pv
2.6 WORKING WITH TABLES
a
di
In this section, you will learn how to open a table, enter and edit data in a table, modify
In
the structure of a table, sort records in a table, etc.
rs
he
You can open a table in the Table Design view or Table Data view. If you want to modify
b
the structure of a table, you should open it in the Table Design view. On the other hand,
Pu
if you want to enter or edit data in the table, you should open it in the Table Data view.
n
To open a table, first click the Tables icon under the Database section in the Database
illa
To open in the Table Design view, right-click on the table you want to open under
ac
the Tables section in the Database window and then select the Edit option from the
M
d
Lt
Fig. 2.22 Opening a table in the Table Data View
t.
Pv
2.6.2 Entering and Editing Data in a Table
a
Once the structure of a table is defined, you can enter data into it. Suppose you want to
di
In
enter the data given in Table 2.3 in the table Result that you created earlier.
rs
1 Aditya 77 56 67
b
2 Bhanu 89 78 82
Pu
3 Nidhi 67 66 92
n
4 Rani 67 88 85
illa
5 Ruchi 78 90 88
m
ac
6 Tanvi 56 87 90
M
To enter the sample data in the table Result, follow these steps.
©
1. Open the table Result in the Table Data View. You will see a blank row to add a new
record.
2. Type 1 in the Roll Number field. As you start typing, a new blank row automatically
appears below the current row with an asterisk symbol ( ) in the row selector.
A pencil icon ( ) appears on the row selector of the current row, indicating that the
record is being entered or edited.
3. Press the Tab or Enter key to go to the next field in the same row and type Aditya
under the Name field.
4. Similarly, type values in the remaining fields of this record and press the Tab or Enter
key to move to the Roll Number field of the next record. This way, you can add other
records in the table.
29
5. Save the table by clicking the Save icon ( ) on the Standard toolbar.
d
You can also make changes in the values that are already entered in the fields. To make
Lt
changes in the value of any field, follow these steps.
t.
Pv
1. Move the cursor to the location where you want to modify the data.
2. Type the new value for the field and press the Enter or the Tab key.
a
di
In
2.6.3 Deleting Records from a Table
rs
You can delete the existing records, if required. Suppose you want to delete the record of
he
the student named Nidhi from the table. To delete this record, follow these steps.
lis
2. Click the Edit menu and then click the Delete Record option.
n
OR
illa
Right-click on the selected row and then select the Delete Rows option from the
m
Pv
Fig. 2.24 Deleting a record from a table
a
A message box appears that asks you to confirm the deletion. Click Yes to confirm the
di
In
deletion and No to keep the record in the table.
rs
he
b lis
Pu
n
illa
m
ac
Note
You can also delete the selected record by pressing the Delete key on the
keyboard.
31
d
Lt
t.
Pv
Fig. 2.26 Selecting the field for sorting the records
a
2. Click the Sort Ascending (
di
) or Sort Descending icon ( ) present on the Standard
In
toolbar to arrange the records in ascending or descending order, respectively.
rs
Figure 2.27 shows the records of the Result table arranged in the descending order
he
32
d
Lt
t.
Pv
a
di
In
rs
To delete an unwanted field from an existing table in the Table Design view, follow these
n
steps.
illa
2. Right-click and select the Delete option from the shortcut menu that appears.
M
©
d
Lt
t.
Pv
a
di
Fig. 2.30 Message box
In
rs
he
Points to
lis
Remember
b
Pu
Creating, adding, modifying, deleting and retrieving data to and from a database
illa
database in an effective and efficient manner so that data can be updated and
M
There are mainly two types of databases, flat file database and structured database.
Database models refer to the way of designing a database and storing information
in it. There are three types of database models, namely, hierarchical, network and
relational.
The most commonly used database model is the relational data model in which
information is stored in the form of tables and different tables are related through
common fields.
The DBMS design based on a relational model is known as the Relational
Database Management System (RDBMS).
34
d
in the Field Properties section, you specify the properties of the fields in the table.
Lt
A primary key is a field that has a unique value for all records in the table. When
t.
Pv
a field is set as the primary key, it ensures that no two records in the database
contain the same value for that field.
a
di
Table Wizard provides some sample fields and tables to guide and help you in
In
creating tables. You can define the table structure, data types and the field sizes
rs
Exercises
m
ac
35
d
Lt
b. A .............................. represents data in the form of rows and columns.
t.
c. LibreOffice Base saves a database with .............................. extension.
Pv
d. The .............................. view is used to create and organise the structure of
a
di
a table. In
e. The .............................. section in the Table Design window is used to
rs
d. Integer [INTEGER] data type is used to store numeric values with decimal.
M
e. Table Wizard provides some sample fields and tables to guide and help you
©
in creating tables.
36
d
Lt
4 Pride and Prejudice Jane Austen 5
5 Middlemarch George Eliot 1
t.
Pv
a. Set ‘Book Code’ as the primary key.
a
b. Delete the record ‘Middlemarch’ from the table.
di
In
c. Sort the table according to the field ‘Author’.
rs
he
b lis
For Teacher
Pu
the
n
Initiate the discussion with the basics of a database. Explain the concept of
illa
database with the example of an attendance register which is the database of all
m
Introduce to students the Base window and explain its various components.
M
Demonstrate the steps for creating tables in a database and perform various
©
operations.
37
d
Lt
t.
Pv
a
di
In
rs
he
b lis
Pu
n
illa
Contents
m
What is a Query? tables. Each table may further contain several records.
M
Note
Queries are made on tables and their results are also displayed in form of
tables containing the rows and columns that match the specified criteria.
d
Use the Query Wizard to create a query
Lt
t.
Create a query in the SQL View
Pv
Let us learn to create a query in Design View.
a
Creating a Query in the Design View di
In
rs
Suppose you want to create a query to view the roll number, name and marks of students
he
who have scored more than 75 marks in Maths from the table Result of Student database
(you created in previous chapter). To create this query in the Design View, follow these steps.
b lis
3. Click Create Query in Design View option under the Tasks section.
illa
m
ac
M
©
d
Lt
t.
Pv
a
di
In
rs
Fig. 3.2 Query Design window with Add Table or Query dialog box
he
6. Click the Close button to close the Add Table or Query dialog box. This displays the
lis
fields of Result table in the top section of the Query Design window, named Object
b
Pu
Relationship pane.
n
illa
m
ac
Object
Relationship pane
M
©
Design Grid
d
Lt
t.
Pv
a
di
In
rs
8. Similarly, select Result.Name and Result.Maths in the next two columns of the Field
b
row.
Pu
9. In the Criterion row, specify the criterion, that is, type >75 under the Result.Maths
n
column. Now, the Query Design window resembles as shown in Fig. 3.5.
illa
m
ac
M
©
d
Lt
t.
Pv
a
di
In
rs
11. Save your query for future reference by clicking the Save button ( ) on the Query
b
12. Type a suitable name for the query in the Query name text box and click OK.
n
illa
m
ac
M
©
d
Lt
2. In the Database window, click Forms under the Database section.
t.
3. Select the Use Wizard to Create Form option under the Tasks section.
Pv
a
di
In
rs
he
b lis
Pu
n
illa
The Database Form window opens up displaying the Form Wizard window.
M
©
d
Lt
t.
Pv
a
di
In
rs
he
Fig. 3.11 Selecting the desired table and fields for the form
lis
6. After you have selected the desired fields, click the Next button to move to the next
b
7. Here you can choose to add a subform—a form within a form that lets you add more
n
specific data to the original form—by selecting the Add Subform check box. You can
illa
d
Lt
t.
Pv
a
di
Fig. 3.13 Selecting the layout of the form
In
10. Click the Next button to move to the next step of the Form Wizard.
rs
he
11. Select the desired data entry mode for the form. Here you have two options. If you
want to use the form only for entering new data, select the first option. However,
lis
if you want the form to display all the data, select the second option.
b
Pu
n
illa
m
ac
M
©
Fig. 3.14 Selecting the data entry mode for the form
12. Click the Next button to move to the next step of the Form Wizard.
13. Select the desired style for your form from the Apply styles list and select the desired
option for the field border from the Field border section.
45
a
14. Click the Next button to move to the next step of Form Wizard.
di
In
15. Type a suitable name for your form in the Name of the form text box and select the
rs
desired option to specify How do you want to proceed after creating the form?.
he
b lis
Pu
n
illa
m
ac
M
©
16. Click the Finish button. The Database Form window opens up displaying the form
you have created. You can navigate through the records using the record navigation
buttons on the Form Navigation toolbar at the bottom of the Database Form window.
These buttons are used to move to the first, last, next, previous or any specific record
in a table.
46
d
toolbar
Lt
t.
Pv
a
di
Fig. 3.17 Database Form window displaying the form
In
rs
17. Save the form by clicking the Save button ( ) on the Standard toolbar.
he
18. Click the Close button ( ) on the top-right corner of the Database Form window
lis
to close it.
b
Pu
Now, when you click Forms under the Database section in the Database window, the
form you have created is displayed under the Forms section. You can simply double-
n
47
d
Lt
To create a report using the Report Wizard, follow these steps.
t.
Pv
1. Open the desired database.
a
2. In the Database window, click Reports under the Database section.
3. di
Click the Use Wizard to Create Report option under the Tasks section.
In
rs
he
b lis
Pu
n
illa
m
ac
M
©
48
t.
Pv
4. Select the table to be used for creating the report from the Tables or queries drop-
a
down list. As you select, all the fields of the selected table are displayed in the
Available fields list box.
di
In
5. Select the field that you want to include in the form from the Available fields list and
rs
click the ( ) button to move it to the Fields in report list. You can also click the
he
6. After you have selected all the fields, click the Next button to move to the next step
b
Pu
Fig. 3.21 Selecting the desired table and fields for the report
7. Specify the labels for the fields included in the report. Label is the text that will
appear in the report in place of the field name.
49
8. Click the Next button to move to the next step of the Report Wizard. Here you have
d
Lt
to define the grouping levels for the fields. Simply, click the Next button to skip this
step and move to next step of Report Wizard.
t.
Pv
9. Specify the fields based on which you want to sort the records in ascending or
descending order and click the Next button.
a
di
In
rs
he
b lis
Pu
n
illa
m
ac
13. Click the Finish button. The report you have created opens up in a Writer document.
d
Lt
t.
Pv
a
di
In
rs
he
b lis
Pu
14. Click the Close button ( ) on the top-right corner of the Writer window to close the
report.
m
ac
Now, when you click Reports under the Database section in the Database window,
the report you have created is displayed under the Reports section. You can simply
M
d
Lt
Reports take the data from one or more tables and/or queries and display it in a
t.
professional format.
Pv
In Base, you can create reports in two ways: Create Report in Design View and
a
Use Wizard to Create Report.
di
In
rs
he
lis
Exercises
b
Pu
(iii)
Form (iv) Report
©
52
d
c. The result of a query is displayed in the form of a .............................. .
Lt
d. .............................. generally display one record at a time on the screen.
t.
Pv
e. The .............................. section in Database window displays different
a
options to create a report.
di
In
3. State true or false.
rs
he
in the tables.
illa
d. A form can be customised to display all or only selected fields from the
m
table.
ac
M
53
d
Lt
5 Middlemarch George Eliot 1
t.
Now, perform the following operations.
Pv
a. Set ‘Product_No’field as the primary key.
a
di
b. Add 10 records in the table. In
c. Make the following queries to retrieve the records.
rs
d. Create a form for the table using the Form Wizard to add 5 records in it.
Pu
e. Create a report for the table displaying only the Product_Name, Price and Qty-
n
in_hand fields.
illa
f. Create a report for the table, grouping the records according to ‘Reorder_Level’
m
field and then sorting each record under a group according to ‘Product_Name’
ac
field.
M
©
54
d
and flowcharts.
Lt
t.
Pv
a
di
In
rs
he
b lis
Pu
n
illa
m
ac
4.1 ALGORITHM
An algorithm is a step-by-step processof solving a problem. It is written in a simple
language such as English, so that anyone can understand the problem-solving logic.
It is an important part of program development.
d
Note
Lt
The instructions of an algorithm when written in any programming language
t.
Pv
form a computer program.
a
di
In
4.1.1 Characteristics of an Algorithm
rs
An algorithm that goes on performing a set of steps infinitely is not of any use.
b
Pu
Definiteness: An algorithm should be clear and unambiguous. Each step and its
input/output must be clear. There must be no ambiguity in any instruction.
n
illa
Effective: An algorithm must be effective, which means each step in the algorithm
M
must be simple and basic so that any person can carry out these steps easily and
©
d
Step 9 : Stop.
Lt
Similarly, you can write algorithms for the operations to be performed by the computer.
t.
Pv
Algorithm to add three numbers
a
di
Step 1 : Start. In
Step 2 : Take three numbers as inputs, say A, B and C.
rs
Step 5 : Stop.
b
Pu
Step 1 : Start.
illa
Step 5 : Stop.
©
d
Lt
Start/Stop box An oval represents the beginning and the end
of a flowchart.
t.
Pv
Input/Output box A parallelogram represents the input and
output instructions in a flowchart.
a
Process box di
A rectangle represents the processing
In
instructions in a flowchart.
rs
he
a flowchart.
ac
a flowchart together.
©
d
Lt
t.
Input A, B, C
Pv
a
D=A+B+C
di
In
rs
he
Print D
b lis
Pu
Stop
n
illa
Start
M
©
Input A, B, C, D
Avg = (A+B+C+D)/4
Print AVG
Stop
59
Start
Input A and B
Yes
Is A = B?
d
Lt
t.
Print “A is greater.” Print “B is greater.”
Pv
a
di
In
rs
Stop
he
Example 4: Draw a flowchart to find the sum and average of marks in four tests. If average
lis
is greater than or equal to 65 then print ‘Eligible’, else display ‘Not Eligible’.
b
Pu
Start
n
illa
A
m
ac
Yes Is Average No
©
>=65?
Sum = M1 + M2 + M3 + M4
Print Print
“Eligible” “Not Eligible”
Average = Sum/4
A Stop
60
Advantages Limitations
The symbols used in a flowchart In case of large programs, the
are self-explanatory. This makes a flowcharts may continue to many
flowchart easier to understand. pages. This makes them difficult to
Being a graphical representation, understand.
flowcharts are better to communicate It takes a lot of time to represent
the problem-solving logic to the users. a problem diagrammatically as
With the help of a flowchart, a problem compared to writing algorithms.
d
Lt
can be analysed in an effective way. Any changes or modification in a
t.
flowchart usually requires redrawing
Pv
the entire flowchart.
a
If the problem logic is complicated,
di
flowcharts become complex.
In
rs
he
Points to
lis
Remember
b
Pu
simple language such as English so that anyone can understand the problem-
solving logic.
m
ac
61
Lt
t.
(iii) (iv)
Pv
a
c. How many flow lines can come out from a process symbol in a flowchart?
(i) One (ii) di
Two
In
rs
62
d
a. Define algorithm.
Lt
t.
b. List three rules that should be kept in mind while writing algorithms.
Pv
c. Explain any three symbols used in a flowchart.
a
di
d. What is the difference between an algorithm and a flowchart?
In
rs
e. Mention four rules that you must follow while drawing a flowchart.
he
Activities
ac
M
Step 1: Start.
Step 2: Take five numbers A, B, C, D, E.
Step 3: Add A, B, C, D, E and store the result as Total.
Step 4: Divide Total by 5 and store result as Average.
Step 5: If Average is greater than or equal to 65, display ‘Eligible’.
Step 6: If Average is less than 65, display ‘Not eligible’.
Step 7: Stop.
2. Write an algorithm for how you go to school.
63
...................
Input ................
No
Is A < B?
d
Yes
Lt
Yes No
Is A < C?
t.
Print “....... is smallest.”
Pv
No
a
Print “A is smallest.”
di
Print “....... is smallest.”
In
rs
he
b lis
Pu
.................
n
illa
a. Accept age and print ‘Cannot vote’ if age < 18 and print ‘Can vote’ if age
ac
>= 18.
M
b. Input marks and print ‘Fail’ if marks < 40 and print ‘Pass’ if marks >= 40.
©
64
d
Lt
t.
Pv
a
di
In
rs
he
b lis
Pu
n
illa
Contents
m
Python on Ubuntu
previous class, you learnt a programming
Working with Python language named Scratch. Now, you will learn
Tokens another language named Python which is
one of the most widely used programming
Data Types languages today. It is a dynamic object-
Variables and Assignments oriented language that has applications in a
Input and Output variety of areas. In Python, you can develop
simple programs for solving mathematical
Comments in Python problems as well as large web-based
Some Simple Python Programs applications, games, 3D applications and
almost everything that any object-oriented
programming language can do.
65
Note
Python was created as a successor of a language called ABC (All Basic
Code) and released publicly in 1991.
d
Lt
t.
5.1.1 Features of Python
Pv
The following are some features of Python that have made it so popular.
a
di
Easy to learn and use: Python is a great language for beginner-level programmers
In
because it uses simple English words and has a simple syntax.
rs
programs line by line at runtime. The interpreter takes the source code and then
lis
Free and open source: Python is available on the Internet for free and you can
download it from the official website of Python. It is an open-source program, which
n
illa
means the source code of Python is also available. Anyone can read its source code,
m
Interactive: It provides an interactive shell that allows you to directly interact with the
M
Extensible: The code written in some other language such as C, C++, CORBA and
Java can be merged with Python programs and run to give scripting capabilities to
that program.
Object-oriented language: Other than functional and structured programming
methods, Python also supports object-oriented programming (OOP) approach
that encapsulates code within objects. It provides a simple yet powerful way of
implementing OOP, especially in comparison to languages such as C++ or Java.
66
d
Python 3.8 is not available in Ubuntu’s default repositories. You can download it from
Lt
Python’s website using the following link.
t.
Pv
https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tgz
a
After you have downloaded the software, extract the folder and then install it on your
system by following these instructions.
di
In
1. Open the Terminal program.
rs
he
2. Type the following command to update the packages list and press the Enter key.
lis
3. Ubuntu asks for your password. Type the password and press the Enter key.
Pu
n
illa
m
ac
M
©
d
Lt
t.
Pv
a
di
In
rs
he
b lis
5. Add the deadsnakes PPA to your system’s sources list by typing the following
n
illa
sudoadd-apt-repositoryppa:deadsnakes/ppa
ac
During the process, whenever prompted, press the Enter key to continue.
M
©
(a) (b)
Fig. 5.3 Adding the deadsnakes PPA to the list of the system’s sources
68
d
Lt
t.
(a) (b)
Pv
Fig. 5.4 Installing Python
a
di
In
5.3 WORKING WITH PYTHON
rs
Once Python has been installed, you can use it in two modes:
he
lis
Command-line mode
b
IDLE mode
Pu
In Python programming from command-line mode, you can type the code directly into the
n
Python interpreter at the prompt (>>>). The Python interpreter immediately returns the
illa
output for each command that you enter. Open the Terminal window and type python3.8
m
d
Lt
5.3.1 Starting Python (IDLE)
t.
Pv
IDLE is the standard and the most popular Python development environment. It lets you
edit, run, browse and debug Python programs from a single interface.Once Python IDLE
a
has been installed, you can start it by following these steps.
di
In
1. Open the Terminal window.
rs
idle-python3.8
lis
The Python Shell window opens up with a cursor blinking at the prompt >>>.
b
Pu
n
illa
m
ac
M
©
70
You can create a new file, write the Python program (script) in it and then use the
n
illa
interpreter to run the script and obtain the output. This is referred to as the script
mode of IDLE.
m
ac
M
Python, in interactive mode, is good enough to learn, experiment or explore, but its
only drawback is that we cannot save the statements for further use and we have to
retype all the statements to re-run them.
d
2. Type the code for your program in the window.
Lt
t.
Pv
a
di
In
rs
he
b lis
Pu
n
illa
m
ac
M
Observe that the ‘#’ symbol in the program code shown in Fig. 5.9 indicates that the first
line is a comment.
Note
You can also press Ctrl + N to create a new file.
d
Lt
t.
(a) Choosing the Save option (b) Save As dialog box
Pv
Fig. 5.10 Saving the program
a
di
In
5.3.4 Running the Python Program
rs
After you have written and saved a program, the next step is to execute it. To run a Python
he
program, click the Run menu in the Python Shell window and then click the Run Module
lis
option. The program will run and the output will be displayed in the Python Shell window.
b
You can also run a program by pressing the F5 key on the keyboard.
Pu
n
illa
m
ac
M
©
(a) Choosing option to run the program (b) Output of the program
Fig. 5.11 Running the Python program
5.4 TOKENS
A token is the smallest individual unit of a program. It is defined as a set of characters that
logically belong together. Python tokens include keywords, identifiers, literals, operators
and punctuators. Let us learn about these one by one.
73
d
finally is return def
Lt
t.
Pv
5.4.2 Identifiers
a
Identifiers refer to the names given by a programmer to different parts of a program such
di
as variables, functions, lists, objects, dictionaries, etc., in order to identify them uniquely.
In
They are the basic building blocks of a program.
rs
While defining identifiers in Python, programmers must follow the rules given below.
he
It must contain only uppercase and lowercase letters, underscore (_) and digits 0 to 9.
Pu
It must start with a letter or an underscore followed by zero or more letters, underscores
n
from that in lowercase. For example, nUM, num, Num, and NUM are considered
ac
Python does not allow the use of punctuation characters such as $, @, and % in the
name of identifiers.
Some valid identifiers are listed below.
Numvar NEWVAR _chk Pvar P_var123 _DISK
The following are some invalid identifiers.
982ds invalid; as it starts with a digit
Num@Var invalid; as it contains the special character @
lambda invalid; as it is a keyword
74
String Literals
String literals refer to an ordered sequence of any number of characters enclosed in either
single (‘ ’) or double quotes (“ ”). For example, ‘g’, ‘K’, ‘7’, “India”, “Rahul” and
“date” are some valid string literals. Here it is important to note that the quotes are not
part of the string. They only tell the computer where the string literal begins and ends.
d
Lt
Python also allows you to use certain non-graphic characters (which cannot be typed from
t.
the keyboard) such as tab space, new line, carriage return, etc. within the string values.
Pv
These characters can be represented by using escape sequences. An escape sequence is
nothing but a special character that has a specific function. It is represented by a backslash
a
di
(\) followed by one or more characters. Table 5.2 lists some of the escape sequences in
In
Python.
rs
\r Carriage Return
illa
\b ASCII Backspace
m
\\ Backslash (\)
ac
Numeric Literals
Numeric literals refer to the numbers consisting of a sequence of digits (with or without
decimal point) that can be either positive or negative. However, by default, numeric literals
d
are positive. In Python, there are four types of numeric literals, as given below.
Lt
int: The numeric literals of int type are signed integers—the positive or negative
t.
Pv
whole numbers with no decimal point.
a
long: The numeric literals of long type are also signed integers but with unlimited
di
size. They are written like integers and followed by the letter L (in uppercase or
In
lowercase).
rs
float: The numeric literals of float type are real numbers, that is, the numbers
he
with a decimal point that separates the integer and fractional part.
lis
complex: The numeric literals of complex type are complex numbers of the
b
Pu
form a+jb, where a is the real part of the number and b is the imaginary part.
n
illa
The integer numeric literals (of type int and long) can be represented by three
M
different number systems, namely, decimal (base 10), octal (base 8) and hexadecimal
©
numbers (base 16). The octal constants are preceded by a 0 (zero) and contain only 0
to 7 digits, while the hexadecimal constants are preceded by a 0x and contain only 0
to 9 digits and A to F or a to f letters.
Boolean Literals
A Boolean literal is used to represent one of the two Boolean values: True or False.
That is, the value of a Boolean literal can be either True or False.
d
Arithmetic operators + (addition), - (subtraction), * (multiplication),
Lt
/ (division), ** (exponent), % (remainder/
t.
modulus), // (floor division)
Pv
Relational operators <(less than), >(greater than), <= (less than or
a
equal to), >= (greater than or equal to), ==
di
(equal to), != or <>(not equal to)
In
Logical operators and (logical AND), or (logical OR)
rs
exclusive OR)
lis
Note
The combination of values (constants), variables and operators form an
expression, which generates a single value. For example, x+5 is an expression.
The expression values can also act as operands for operators.
5.4.5 Punctuators
Punctuators, also known as separators, are the tokens that serve different purposes based
on the context in which they are used. Some punctuators are used as operators, some are
77
d
Lt
Floating Complex String Tuple List Dictionary
t.
Integer
Pv
Point
Boolean
a
di
Fig. 5.12 Data types in Python
In
Let us learn about these data types.
rs
he
5.5.1 Numbers
lis
The number data types are used to store numeric values. The data types in Python which
b
Pu
floating-point numbers
m
complex numbers
ac
M
Integers
©
Integers are the whole numbers (positive or negative) with no decimal point. In Python,
the data types, int, long and bool are used to store integers.
int: This data type is used to store signed integer values, for example, 82, −356,
etc. It uses 4 bytes (32 bits) to store a value. The range of an integer in Python can
be from −2147483648 to 2147483647.
long: This data type is used to store long integers, for example, 5436723L,
78634467238L, etc. A long integer has unlimited range subject to available memory.
When we want a value to be treated as a very long integer value, we append ‘L’ to
the value. Such values are treated as long integers by Python.
bool: It is a unique data type, consisting of two constants, True and False. A Boolean
True value means a non-zero, non-null and non-empty, while a Boolean False means
a zero value.
78
Note
Even though the value 1 is an integer, the value 1.0 is a floating-point number.
Complex Number
A complex number is of the form A+Bj where A is the real part, B is the imaginary part
and j represents √(-1). The complex data type used to store a complex number in
d
Python is made up of two floating-point values, one each for real and imaginary parts.
Lt
For accessing different parts of a complex number (say, x), we will use x.real and
t.
x.image.
Pv
a
5.5.2 None
di
In
This is special data type with a single value. It is used to signify the absence of value/false
rs
5.5.3 Sequences
b
Pu
Strings
m
by enclosing them in either single quotes or double quotes, for example, ‘a’, ‘abc’,
M
‘Kevin’, “ritu 123”, “Her’s”, etc. There can be a string with no characters in it, such
©
Lists
A list in Python is a list of values of any data type enclosed within square brackets [] and
separated by commas. The individual values in the list are called elements or items and
are indexed. Lists are mutable which means individual elements of a list can be modified.
Examples:
[1, 2, 3, 4, 5]
[‘h’, ‘e’, ‘l’, ‘l’, ‘o’]
[89, 75.3, “Saachi”]
79
Note
A set can have any number of items and they may be of different types
d
Lt
(integer, real, tuple, string, etc.). But a set cannot have a mutable element,
t.
such as a list, set or dictionary, as its element.
Pv
5.5.4 Sets
a
di
In
A set is an unordered collection of items. Every element must be unique (no duplicates)
and must be immutable (which cannot be changed). However, the set itself is mutable.
rs
We can add or remove items from it. A set is created by placing all the items (elements)
he
Examples:
b
Pu
{1, 2, 3}
n
5.5.5 Mappings
M
A mapping data type is unordered and mutable. Dictionaries fall under mappings.
©
Dictionary
Dictionary is an unordered collection of items enclosed within curly braces {} and separated
by commas. Each item in a dictionary is expressed as a key:value pair. While values
can be of any data type and can repeat, keys must be of immutable type (string, number
or tuple with immutable elements) and must be unique. The values in a dictionary can be
accessed with the help of the key.
Examples:
{1:‘a’,2:‘b’,3:‘c’}
{1: ‘apple’, 2: ‘ball’}
{‘name’: ‘John’, 1: [2, 4, 3]}
80
d
num = 75
Lt
Here, num is a variable and an integer value of 75 is assigned to it. Now, consider these
t.
Pv
statements.
a
pi = 3.14
Name=‘Sanaya’ di
In
rs
In the first statement, pi is a variable that has been assigned a floating-point value 3.14,
he
while in the second statement, Name is a string variable that has the text Sanaya stored in it.
b lis
Note
Pu
Python lets you assign a single value to multiple variables at the same time. You can even
M
Python lets you assign a single value to multiple variables at the same time using a single
statement. For example, the following statement assigns the value of 20 to three variables
x, y and z, simultaneously.
x = y = z = 20
You can also assign different values to multiple variables in a single statement. For example,
the following statement assigns the values 20, 30 and 40 to three variables x, y and z,
respectively, at the same time.
x, y, z = 20, 30, 40
Note that the above statement assigns values order-wise, that is, the first value is assigned
to the first variable, the second value to the second variable, and so on.
81
d
Lt
a string. To understand, type the following statement at the prompt >>> in the interactive
t.
mode and press the Enter key.
Pv
>>>x=raw_input()
a
The cursor blinks and waits for you type a value. Type the value and press the Enter key.
di
Whatever you type, the raw_input () function converts it into a string and then assigns it
In
to the variable on the left-hand side (x in our case).
rs
he
The raw_input() function can also display a message and then wait for the input.
For example, type the following statement at the prompt >>> in the interactive mode
lis
We can use the raw_input() function to enter numeric data also. In that case, we
ac
typecast (change) the string of digits entered by the user to an appropriate numeric type
M
using the function. For example, type the following statement at the prompt >>> in the
interactive mode and press the Enter key.
©
Note
In the latest Python release 3.x, the raw_input() function has been
renamed as input() function and the old input() function (of release
2.x) that we discussed above has been removed.
d
Lt
5.7.3 The print()Function
t.
Pv
The print() function lets you display a constant, the value of a variable or the result of
an expression. For example, consider the following statements.
a
print(8) displays 8 di
In
rs
While entering numeric values using raw_input(), ensure that the values entered by
he
Comments are the non-executable statements that are used in a program to increase
n
its readability. They are used to explain the program code to anyone who views your
illa
program.
m
In Python, you can use either a single-line or a multiline comment in a program. A single-
ac
line comment starts with a hash ‘#’ symbol. For example, the statement given below is a
M
is a
multiline comment.”””
83
d
Lt
Fig. 5.13 Program to add, subtract, multiply and divide two numbers
t.
Pv
Example 2: A Python program to compute the simple interest
a
di
In
rs
he
b lis
Pu
n
illa
m
Example 3: A Python program to convert number of days into hours, minutes and seconds
84
d
Lt
Example 5: A Python program to find the perimeter and area of a square
t.
Pv
a
di
In
rs
he
b lis
Pu
Example 6: A Python program to find the square and cube of a given number
M
©
85
d
Lt
Points to
t.
Remember
Pv
a
A well-defined set of instructions that directs the computer to do a particular task
is called a program. di
In
rs
Once Python has been installed, you can use it in two modes: command-line
b
IDLE has a Python Shell window where you can write and run Python programs.
n
illa
You can use Python IDLE in two different ways: interactive mode and script
mode.
m
ac
A data type defines the type of data and the operations that can be performed on
it. Various data types available in Python are numbers (integer, floating-point and
complex numbers), None, sequences (strings, tuple and list), sets and mappings
(dictionary).
A variable is a name that represents a memory location which stores a value of a
specific data type. The data stored at a particular location can be accessed using
the variable name.
You can create a variable by just assigning to it some value of a particular data
type such as a numeric value, a string, etc. You can assign a value to a variable
using the assignment operator(=).
86
d
Exercises
Lt
t.
Pv
1. Tick (ü) the correct option.
a. Which of the following identifiers is invalid in Python?
a
(i) _var123 (ii)
Var_Num di
In
rs
(i) // (ii)
#
b
Pu
””” (iv)
(iii) @
n
break
(iii) (iv) All of these
M
(i) () (ii)
[]
{}
(iii) (iv) None of these
e. Which of the following statements is not true for Python?
(i) It is an object-oriented and high-level programming language.
(ii) It can run on different operating systems.
(iii) It is available free of cost.
(iv) Its source code cannot be modified.
87
d
Lt
a. Python is a case-sensitive language.
t.
Pv
b. The statement print(5>=3) displays 5.
a
c.
di
In Python, a floating-point number is accurate up to 10 decimal places.
In
d. In Python, strings are represented by single quotes only.
rs
he
e. Discuss the data types used to store numeric values in Python with examples.
f. Mention any three rules that must be followed while defining identifiers in
Python.
g. How can you assign a single value to multiple variables at the same time?
Explain with the help of an example.
h. Differentiate between single-line and multiline comments.
i. Discuss the two input functions provided in Python release 2.x. What change
has been made in Python release 3.x?
88
d
Lt
2. Write a Python program to input the length and breadth of a rectangle and then
t.
print its perimeter and area.
Pv
3. Write a program in Python to read distance in kilometres and print it in miles.
a
di
4. Write a program in Python to input the radius of a circle and print its circumference.
In
5. Write a program in Python to input a number n and print the sum of n, n2 and
rs
n3.
he
blis
Pu
Help students open Python in command-line as well IDLE modes. Explain the
M
Demonstrate the steps to create, save and run a Python program in the IDLE
mode.
Tell students about the different programming elements of Python, including,
tokens, variables, data types, and input and output functions.
Guide students write some simple programs in Python and execute them.
89
d
Lt
t.
Pv
a
di
In
rs
he
b lis
Pu
n
illa
Contents
m
ac
Conditional Statements
only once. However, the serial execution of
Some More Python Programs
statements makes a program inflexible and
unsuitable for most practical applications.
To make a program more flexible, control statements are used to alter the flow of control
of the program.
In Python, the control statements are broadly classified into conditional statements and
iteration (looping) statements. All these control statements are commonly used with
the logical tests or test conditions to alter the flow of control conditionally. To alter the
flow conditionally, a particular condition is evaluated to control the flow of execution.
In this chapter, you will learn about conditional statements only. Before that let us have a
recap of the commonly used operators available in Python and how they work.
90
d
+ Adds the value of its two operands. x+y 7
Lt
- Subtracts the value of the right operand x-y 3
t.
Pv
from the left operand.
* Multiplies the value of its two operands. x*y 10
a
/ Divides the value of the left operand by the x/y
di
In 2.5
right operand and gives the quotient.
% Gives the remainder on dividing the two x%y
rs
1
he
operands.
// Integer division; returns the floor of the x//y
lis
2
b
quotient.
Pu
Relational operators are used to compare two values or expressions. These operators
ac
can work with all numeric data types, strings, lists, tuples and Boolean values and return
M
either True or False.Table 6.2 lists the working of various relational operators available in
©
Python.
Table 6.2 Relational operators
91
d
left operand is equal to that of the
Lt
right operand and False otherwise.
t.
Pv
a
Note
di
In
When floating-point values are compared using relational operators,
rs
the comparison is done after removing trailing zeros after the decimal point.
he
lis
When relational operators are used with strings, these rules are followed.
b
Pu
Values are compared on the basis of lexicographical ordering, that is, the order in
which they appear in a dictionary.
n
illa
For example, the expression ‘Rahul’ < ‘Ruhani’ returns True, while ‘RUHANI’ > ‘Ruhani’
ac
returns False.
M
©
Note
The operators ==and != are also known as equality operators as they
are used for checking the equality of operands.
92
d
tuples it returns the second
Lt
‘Python’or’’ ‘Python’
operand as the result.
t.
‘d’or’m’ ‘d’
Pv
Otherwise, it returns
the first operand as the
a
result.
di
(3==2)and(6!=6) False
R e l a t i o n a l Returns True only
In
expressions if all the relational (4>2) and(8<9) True
rs
expressions evaluate
he
otherwise.
b
Pu
and
illa
‘Python’and’’ ‘’
False truth-value).
ac
93
d
precedence of operators. The order in which different operators in an expression are
Lt
evaluated is determined by the precedence of operators. The operators with a higher
t.
precedence are evaluated before the operators with a lower precedence. Table 6.4 lists
Pv
different operators in Python in the order of higher to lower precedence.
a
Table 6.4 Precedence of operators
di
In
Operator Description
rs
() Parentheses
he
** Exponentiation
lis
The order in which operators of the same precedence are evaluated is determined by the
associativity of operators. The associativity of an operator can be either from left to the
right or from right to left. The operators with left-to-right associativity are evaluated from
the left-hand side while the operators with right-to-left associativity are evaluated from the
right-hand side.
The order of operations of mathematical operators in Python is same as that in
mathematics. The ** operator is evaluated first, the *,/,// and % are evaluated next
from left to right, and the + and – operators are evaluated last (also from right to left).
You can use parentheses to override the usual precedence if you need to change the order.
Consider the following statement.
x=5+4*2
94
d
condition evaluates to True, then a given set of statement(s) is executed. However, if the
Lt
condition evaluates to False, the program control passes to the statement following the if
t.
statement.
Pv
Syntax:
a
di
if<conditional_expression>: In
statement(s)
rs
line and a body. The header line of the if statement begins with the keyword if followed
lis
that follow form the body of the if statement and are called a block or suite. The first
Pu
unindented statement marks the end of the block. Each statement inside the block must
n
The colon (:) is significant and required. It separates the header of the statement
from the body.
M
The body of the if statement may consist of a single statement, compound statement
©
Note
Sometimes, it is useful to have a body with no statements. In that case, we
can use the pass statement.This statement does nothing.
95
d
Lt
Figure 6.1 illustrates the operation of the if statement.
t.
Pv
False
a
Condition?
di
In
True
rs
he
Body of if
b lis
Pu
n
Python relies on indentation to define the scope in the code. If the statement after the
colon is not indented, Python will raise an error. That is, the following code will result
in an error.
if b>a:
print(“b is greater than a”)
To understand how the if...else statement works, consider the following code segment.
a=39
b=21
if b>a:
d
print(“b is greater than a”)
Lt
else:
t.
Pv
print(“b is not greater than a”)
In this example, since a is greater than b, the condition b>a evaluates to False. So we go
a
to the else part and the message b is not greater than a is displayed on the
di
screen.
In
rs
False
b
Condition?
Pu
n
Body of if
m
ac
M
©
97
d
Lt
b=33
if b>a:
t.
Pv
print(“b is greater than a”)
elif a==b:
a
print(“a and b are equal”)
di
In
else:
rs
In this example, a is greater than b, so the first condition is not true, also the elif
lis
condition is not true, so we go to the else part and the message a is greater than
b
Note
There is no limit on the number of elif statements but only a single (and
m
ac
optional) final else statement is allowed and it must be the last branch in
M
the statement.
©
98
d
min=z
Lt
print(“Smallest number is”, min)
t.
Pv
Output:
Enter the first number: 67
a
di
Enter the second number: 89 In
Enter the third number: 52
rs
Smallest number is 52
he
or zero
x=int(input(“Enter a number: “))
n
illa
if x>0:
print(“Number is positive.”)
m
ac
elif x==0:
print(“Number is zero.”)
M
else:
©
print(“Number is negative.”)
Output:
Enter a number: -5
Number is negative.
Points to
Remember
To make a program more flexible, control statements are used to alter the flow of
d
control of the program.
Lt
In Python, the control statements are broadly classified into conditional statements
t.
Pv
and iteration (looping) statements.
The control statements involve a condition which is basically an expression
a
di
formed of literals/variables joined by different operators.
In
The conditional statements, also known as the decision control statements or
rs
statements.
b
Pu
The if statement selects and executes the statement(s) based on a given condition.
If the condition evaluates to True, then a given set of statement(s) is executed.
n
illa
Python allows you to use a condition within another condition. Such a condition
m
“if the previous conditions were not true, then try this condition”.
©
Exercises
1. Tick (ü) the correct option.
a. Which of the following is used to define a block in Python?
(i) [ ] (ii)
{ }
(iii) ( ) (iv) Indentation
100
d
Lt
(i) empty (ii)
pass
t.
Pv
elif
(iii) (iv) None of these
a
e. What will be the output of the code segment given below?
di
In
if 5>=5:
rs
print(5)
he
(i) 1
b lis
(ii) 5
Pu
d. The indented statements that form the body of a conditional statements are
called a ............................... .
101
d
b. Which type of control statements are supported in Python?
Lt
t.
c. What are conditional statements?Which conditional statements are provided
Pv
by Python?
a
d. Differentiate between the if and if...else statements.
di
In
e. Define nested condition. Explain with the help of an example.
rs
Activities
m
1. Write a Python program to check whether a number provided by the user is even
ac
or odd.
M
a vowel.
3. Write a Python program to input a number and check if it is divisible by 5 or not.
102
d
own app.
Lt
t.
Pv
a
di
In
rs
he
b lis
Pu
n
illa
m
Contents
ac
Difference between
Application Software and computer program or a set of programs that lets
©
d
that enables you to complete various tasks designed to run specifically on a mobile
Lt
on a computer. device, such as a smartphone or tablet
t.
computer.
Pv
Application software may or may not be Apps are executable.
a
executable.
di
In
Application software may not be specific to Apps are often operating-system specific.
one operating system. For example, apps designed for Android
rs
Thousands of apps have been designed till date---some of which can be downloaded for
n
free, while others must be purchased from an app store. These apps can be categorised
illa
referred to as a desktop application (or desktop app). These were the first apps to be
invented for PCs. However, with the introduction of the Internet and online commerce,
the development of mobile and Web apps gained more importance.Some examples of
desktop apps are Facebook, Microsoft Office, Web browsers, Instagram, Calculator, etc.
104
d
multiple platforms separately. For example, a single application that runs in Chrome will
Lt
work on both Windows and OS X.
t.
Pv
Note
a
di
The apps that combine the features of both mobile and Web apps are referred
In
to as hybrid apps.
rs
he
lis
Nowadays, there are a number of apps available for use.There is an app for every purpose
and need. Let us learn about some of the common apps specific to different fields.
n
illa
Educational mobile apps are the software programs that help individuals to facilitate
learning on their terms and their location choices. These apps provide the same access
M
to learning material irrespective of the place you are in. The use of educational apps is
©
changing the way students study around the world. A lot of educational websites and
applications are available even in the remotest areas of the world through which anyone
can attain education. Some examples of educational websites and apps are Todo Math,
edX, BYJU’S, Khan Academy,etc.
105
d
Lt
Facebook Twitter Instagram Hike messenger
t.
Pv
Fig. 7.2 Social networking apps
a
7.3.3 Entertainment Apps di
In
Entertainment means leisure activities such as listening to music, playing games, and
rs
commerce activities such as blogging, shopping and podcasting. You can find unlimited
he
entertainment apps on the Internet. Some examples are YouTube, Netflix, Spotify, etc.
b lis
Pu
n
illa
m
106
d
Lt
t.
Pv
a
di
In
rs
3. Select the app you want to download and tap the ( ) button. The app will
start downloading.
n
illa
m
ac
M
©
d
If you do not have a connected Android phone, you can build your apps using the Android
Lt
Emulator, which is a software that runs on your computer and behaves just like the phone.
t.
Pv
In this chapter, you will learn to build the apps using a phone.
In App Inventor, you build apps by working with the following.
a
•
di
App Inventor Designer: Here, you design the user interface by selecting the
In
components for your app.
rs
•
App Inventor Blocks Editor: Here, you assemble the program blocks that specify
he
Let us build a simple app called HelloPuppy in which you create a button that has a
b
Pu
picture of a pup on it and then program the button so that when it is clicked the phone
will make a bow-bow sound. To build this app, we need a picture of a pup and an mp3
n
file of dog sound. So, before starting to build the app, download the image and sound file
illa
Fig. 7.8 Typing the user name Fig. 7.9 Typing the password
d
The Welcome screen appears.
Lt
t.
Pv
a
di
In
rs
he
b lis
Pu
n
illa
Click on the START A BLANK PROJECT button. The Create new App Inventor
5.
M
6.
Type a name for your project in the Project name text box. Remember that spaces
and underscores are not allowed.
d
Lt
t.
Pv
a
di
In
rs
he
lis
8.
From the User Interface palette, drag and drop the Button control onto Screen1 in
the Viewer pane.
n
illa
m
ac
M
©
110
d
Lt
t.
Pv
a
di
In
rs
he
lis
b
Pu
n
11.
Click the Open button. The File Upload dialog box closes and you come back to the
m
Upload File dialog box with the name of the image file appearing beside the Browse
ac
button.
M
©
Fig. 7.17 Upload File dialog box with name of image file
111
d
Lt
t.
Pv
Fig. 7.18 Button with blank text property field
a
14.
From the User Interface palette, drag and drop the Label component below the
di
picture of the puppy in the Viewer pane. It will appear under your list of components
In
as Label1.
rs
15.
Change the following properties of Label1 control in the Properties pane.
he
• Text: Delete the existing text (Text for Label1) and write Touch Me!.
lis
• BackgroundColor: Click on the box below the property and choose the desired
colour from the list of colours.
n
illa
• TextColor: Click on the box below the property and choose the desired colour
from the list of colours.
m
ac
M
©
d
word None and then click the Upload File button to open the Upload File dialog
Lt
box. Click the Browse button to display File Upload dialog box. Locate and select
t.
the desired sound file (for example, Bow bow.mp3 in our case)
Pv
a
di
In
rs
he
b lis
Pu
n
Fig. 7.21 Upload File dialog box Fig. 7.22 File Upload dialog box
illa
18.
Click the Open button in the File Upload dialog box and then click OK in the Upload
m
113
d
Lt
t.
Pv
a
di
In
Fig. 7.24 Blocks Editor window
rs
he
Now, you can start programming your app with blocks by following these steps.
lis
1. On the left side of the Blocks Editor window, click the Button1 drawer to open it.
b
The bunch of blocks related to your components appears in the Viewer pane. These
Pu
2. Drag and drop the block from the Viewer pane to the work area
Both blocks connect like puzzle pieces and you can hear a voice of clicking when
you they connect.
d
Lt
t.
Pv
a
di
Fig. 7.26 Sound added by dragging blocks
In
The purple blocks are called command blocks, which are placed in the body of event
rs
handlers. When an event handler is executed, it runs the sequence of commands in its
he
body. A command is a block that specifies an action to be performed (for example, playing
lis
sound) when the event (for example, pressing Button1) is triggered. Now you can see that
b
the command block is in the event handler. This set of blocks means: “when Button1 is
Pu
clicked, Sound1 will play.” The event handler is like a category of action.
n
illa
You have three options for setting up live testing on your phone while you build apps.
ac
1. If you are using an Android device and you have a wireless Internet connection, you
M
can start building apps without downloading any software to your computer. You will
©
need to download and install the App Inventor Companion app on your device.
2. If you do not have an Android device, you will need to install software on your
computer so that you can use the on-screen Android Emulator.
3. If you do not have a wireless Internet connection, you will need to install software on
your computer so that you can connect to your Android device over USB.
Let us use option 1 to connect your Android device (phone or tablet) to App Inventor by
following these steps.
1. Open Google Play Store in your Android phone or tablet.
2. Start typing mit ai2 companion in the search bar. As you type, a list of search results
appears.
3. Tap on MIT AI2 Companion in the list.
115
5. After finishing the installation of the app in the phone or tablet, find the app in your
he
phone.
lis
6. Ensuring that your phone and computer are connected on the same Wi-Fi network,
b
Pu
open the MIT AI2 Companion app in your Android phone or tablet.
n
illa
m
ac
M
©
d
Lt
t.
Pv
Fig. 7.29 Connect tab of MIT App Inventor menu
a
di
The Connect to Companion dialog appears showing a QR (Quick Response) code and a
In
connect code.
rs
he
b lis
Pu
n
illa
m
ac
M
©
d
Lt
7.5.4 Packaging Your App
t.
As long as your Android device remains connected to App Inventor, your app runs in real
Pv
time on your device. Once you disconnect your device, the app will vanish. However, you
a
can always make it return by reconnecting the device.
di
In
To have an app running without being connected to App Inventor, you must package the
app to produce an application package (.apk file). To package the app to install on your
rs
he
device or to send to someone else, click the Build tab at the top of the MIT App Inventor
screen on your computer. There are two options available for you to choose from.
b lis
•
App (provide QR code for .apk): You can generate a QR code with this option.
Pu
When you scan this code using a QR scanner app on your phone, a link is generated
which you can use to install the app on the phone. You can also share this code with
n
illa
others, but they have to use it within two hours of after generating it.
m
•
App (save .apk to my computer): You can download the app to your computer as an
ac
.apk file, which you can distribute and share as you like by manually installing it on
M
other devices.
©
d
run specifically on a mobile device, such as a smartphone or a tablet.
Lt
t.
A Web application (or Web app)is a program that runs on a web server and must
Pv
be accessed through a web browser.
a
Nowadays, there are a number of apps available for use such as educational,
social networking, entertainment and e-commerce apps.
di
In
An app store refers to an online shop from where you can choose and download
rs
You can download applications from Google Play Store in Android smartphones,
lis
from App Store in iOS smartphones, and from Microsoft Store in Windows
b
Pu
smartphones.
There are a number of websites and applications available which let you develop
n
illa
Exercises
©
119
d
Lt
2. Fill in the blanks.
t.
Pv
a. Spreadsheets are an example of ................................ software.
a
b. An application that is designed to run standalone in a desktop or laptop
di
computer is referred to as a ............................... .
In
rs
120
e. Write the steps to download an application using Google Play Store in your
mobile.
Activity
d
Lt
t.
Take the help of your computer teacher or parents and try to build an app using the
Pv
“Appy Pie” application on a smartphone. It is very easy and you will have fun doing it.
a
di
In
For the Teacher
rs
he
Illustrate the use of Web, desktop and mobile apps to the students.
lis
Help students understand how to build an app online using a Web or mobile
application.
n
illa
m
ac
M
©
121
d
Lt
t.
Pv
a
di
In
rs
he
b lis
Pu
n
illa
Contents
m
Note
The Internet is the world’s largest computer network.
When you connect your computer to a network via a cable or some other communication
means, you become a network user and your computer becomes a workstation
(or sometimes, called node) on the network. Your computer can access all its local resources
such as local hard drives or printers as usual. In addition, it can use the network resources,
d
Lt
including printer, disk storage space, etc. For example, you can print a document on the
printer attached to some other computer on the network.
t.
Pv
8.1.1 Advantages of a Computer Network
a
di
A networked environment of computers has a number of advantages. Some of these are
In
given below.
rs
he
S
peed: You can share and transfer files within a computer network very rapidly.
It saves time while maintaining the integrity of files.
b lis
C
ommunication: A computer network facilitates communication via e-mail,
Pu
a single computer known as the server. All the other computers in the network can
m
R
esource sharing: The primary aim of networking is to share resources regardless of
M
the physical location for better communication. Resource sharing involves the sharing
©
of both the hardware and software resources among multiple users connected to the
network.
P
reservation of information: It is easy to take backup of data in a networked
environment rather than on a number of stand-alone computers.
C
ost-effectiveness: Due to the interconnection of computers, it is easier to access and
transfer a large amount of data from a large distance in a cost-effective manner and
in a short period of time.
Reliability: The backup facility in networking makes it a reliable mode for
communication and sharing files. In case one computer in a network fails, the file
can be accessed from other computers.
123
d
Lt
D
egraded performance: If the traffic of data increases on the network, the performance
t.
of the system degrades, if it is not designed properly.
Pv
a
8.2 TYPES OF NETWORKS
di
In
Computer networks can be categorised based on their size, the distance they cover and
rs
the links used for their interconnection. According to the physical distance a computer
he
network covers, it can be categorised into four types, namely, Personal Area Network
(PAN), Local Area Network (LAN), Metropolitan Area Network (MAN) and Wide Area
lis
Network (WAN).
b
Pu
A PAN is the smallest possible network intended for one person. It is used to interconnect
m
personal devices such as a computer, laptop, mobile phone, tablet or any other hand-
ac
held device of an individual. The devices in a PAN are linked together either using cables
M
or wirelessly. In a wired PAN, the devices communicate through a USB cable, while
in a wireless PAN, Bluetooth and infrared technologies are used for communication.
©
This network can cover an area of only a few metres (less than 10 metres).
Printer
PDA
Desktop Laptop
Computer
Mobile
LAN
d
Lt
t.
Pv
a
di
Fig. 8.2 Local area network (LAN)
In
rs
A MAN is a network that covers an area larger than a LAN, for example, a city. It is basically
b
example of a MAN is the cable TV networks that are spread over a city. It is more efficient
and provides high-speed connection using fibre-optic cables.
n
illa
m
ac
M
©
d
Lt
t.
Pv
a
di
In
rs
he
network.
ac
M
©
Client
Client
d
Lt
Client Client
t.
Pv
Fig. 8.5 Client-server network
a
8.3.2 Peer-to-Peer Network
di
In
A peer-to-peer network does not rely on a central server for communication. Instead,
rs
the computers having equal capacity and capability (called peers) are connected to each
he
other to use the resources on the network. Each computer on a peer-to-peer network can
lis
Client Client
m
ac
M
©
Client Client
Fig. 8.6 Peer-to-peer network
8.5 PROTOCOLS
d
The communication between computers is possible by using a protocol that offers
Lt
a standard format and method for communication. A protocol is a formal set of rules
t.
and conventions that governs how computers exchange information over a network.
Pv
There are a large number of protocols that can be used in a network depending on the
need they fulfil. Two of these are discussed here.
a
T
di
CP/IP (Transmission Control Protocol/Internet Protocol): It is the suite of
In
communication protocols which is used as a standard for transmitting data over
rs
networks. TCP/IP consists of two protocols, namely, TCP and IP. The TCP is responsible
he
for dividing the message or file into small packets at the source computer that are
lis
transmitted over the network. Then at the destination computer, it reassembles the
b
packets into the original message or file. On the other hand, the IP handles the
Pu
address part of each packet so that it reaches the right destination. Any computer or
a device which is connected to the Internet must be supported by TCP/IP.
n
illa
H
TTP (HyperText Transfer Protocol): It is the Internet protocol responsible for
m
transferring and displaying web pages. It provides a way for web clients and web
ac
8.6.1 Bluetooth
Bluetooth is a wireless technology used for exchanging data over short distances. It is used
to create a wireless PAN that lets the electronic devices such as computers, cell phones,
PDAs and wireless keyboards to communicate with each other within the range of 10
metres. It uses radio waves to facilitate communication among devices. Thus, it is not very
expensive and has a low power consumption.
d
Lt
t.
Pv
a
di
In
rs
he
b lis
The name Bluetooth has come from the Danish king Harald Blatand (Bluetooth in
English).
M
©
d
Lt
t.
Pv
a
Terminator
di
In
rs
Advantages
b
Pu
Disadvantages
m
ac
The entire network becomes unusable in case of failure of the bus or backbone.
©
It is difficult to identify where the problem is, if the entire network shuts down.
Disadvantages
A failure in any cable or device breaks the loop and can take down the entire network.
I t is a little slow as the message is passed through all the workstations between the
sender and the receiver.
T
he addition and removal of a device or a workstation from the network require
rewiring and rerouting of all the cables.
d
Lt
8.7.3 Star Topology
t.
Pv
In a star topology, the workstations are not directly connected to each other; rather they
are connected to a centralised network device known as a hub. The hub acts as a central
a
di
controller and the workstations are connected to it via cable segments. If a computer
In
wants to send data to another computer on the network, it sends the message to the hub,
rs
Hub
illa
m
ac
M
©
Advantages
The network is not disrupted even if a workstation fails or is removed from the
network.
New workstations can be added easily in the network by just upgrading the central
hub.
Fault detection and removal of faulty parts are easier in a star network.
131
d
Lt
t.
Pv
a
di
In
rs
he
Advantages
n
Disadvantages
©
Note
A fully connected mesh network with n devices has n(n − 1)/2 physical links.
For example, if an organisation implementing the mesh topology has 8
nodes, then 8(8 − 1)/2, that is, 28 links are required.
132
d
Lt
Each Ethernet cable has RJ-45 connectors at both
t.
ends with each connector usually having eight pins.
Pv
These connectors look similar to telephone jacks
Fig. 8.13 Ethernet cable
which may have four or six pins.
a
di
In
8.8.2 Modem
rs
from the digital to the analog form and back to the Fig. 8.14 Modem
M
133
8.8.4 Hub
A hub is a small rectangular device that connects multiple
devices on a network so that they can communicate with
one another. It gathers the signals from a device connected
to the network and transmits them to all other connected
d
devices. A hub has multiple ports ranging from 4 to over
Lt
400. Fig. 8.16 Hub
t.
Pv
8.8.5 Switch
a
di
A switch, like a hub, is also a multiport device that connects
In
computers to a network. The only difference is in the way of
rs
8.8.6 Router
m
It determines the next network point to which a received data packet should be forwarded
M
A router can be wired or wireless. A wired router connects computers and other devices
to the network through cables. On the other hand, a wireless router connects devices
through radio signals. It has wireless antennas that enhance the range of communication
of radio waves. It allows greater mobility to portable computers such as laptops, tablets
and smartphones.
d
are peer-to-peer network.
Lt
T
he Internet is the largest network that connects millions of computers worldwide
t.
Pv
to share information and services. An intranet is a private computer network
owned by a company or an organisation and is accessible only to its employees.
a
An extranet is a computer network that allows outside users to have limited access
di
In
to the part of the orgranisation’s information.
rs
A
protocol is a formal set of rules and conventions that governs how computers
he
A
data transmission media refers to the medium used for transmitting data
Pu
T
he way in which the network components (cables, computers and other
m
topology. Some of the basic topologies are bus, ring, star and mesh network.
M
N
etwork devices are the components that help the computers to connect to a
©
Exercises
1. Tick (ü) the correct option.
a. NIC stands for:
(i) Network Interface Card (ii) Network Internet Card
(iii) National Interface Card (iv) National Internet Card
135
d
Lt
(iii) HTTP (iv) SMTP
t.
Pv
2. Fill in the blanks.
a
a. A ............................... provides a physical path between the communicating
di
devices in a network.
In
rs
136
d
h. Write short notes on the following.
Lt
(i) Modem (ii) Hub (iii) NIC (iv) TCP/IP
t.
Pv
a
di
In
rs
Activities
he
lis
the Internet. Make a presentation on the same. Apply different formatting and
Pu
in a tabular form.
m
3. Go to your computer lab and find out the various network devices being used
ac
137
d
Lt
(c) Both (a) and (b) (d) None of these
t.
4. Which is the smallest computer network intended for one person?
Pv
(a) PAN (b) LAN
a
di
(c) MAN In (d) WAN
5. Which of the following is not an operating system?
rs
138
d
Lt
(c) Command prompt (d) Menu
t.
15. Which of the following symbols is used only once in a flowchart?
Pv
(a) Process (b) Flow lines
a
(c) Decision (d) Stop
di
In
16. Which of the following devices enables a computer to transmit digital data over
analog telephone lines?
rs
he
17. Which of the following network devices now comes pre-installed in the computers by
Pu
the manufacturer?
n
(c) { } (d) ( )
©
139
d
Lt
(c) Batch-processing system (d) None of these
t.
26. In Base, queries, forms and reports can be designed
Pv
(a) In the design view (b) Using the wizard
a
(c) Both (a) and (b) (d) None of these
di
In
27. An algorithm should always begin with the word:
(a) Begin (b) Start
rs
he
28. Which computer network allows outside users to have limited access to the part of
b
29. Which of the following protocols is responsible for transferring and displaying web
m
pages?
ac
30. Which network covers a relatively small area such as a residence, a building or a
campus?
(a) LAN (b) PAN
(c) WAN (d) MAN
ANSWERS
1. (a) 2. (c) 3. (a) 4. (a) 5. (b)
6. (a) 7. (b) 8. (d) 9. (a) 10. (d)
11. (b) 12. (d) 13. (a) 14. (c) 15. (d)
16. (c) 17. (a) 18. (b) 19. (b) 20. (c)
21. (c) 22. (d) 23. (a) 24. (a) 25. (b)
140 26. (c) 27. (b) 28. (b) 29. (d) 30. (a)
LibreOffice Base
1. Create a database for your class named Class_Database containing these tables.
a. A table named Student_Details with these fields to store the details of the
students in your class.
d
Lt
Field Name Data Type
t.
Roll Number Integer [INTETGER]
Pv
Sname Text [VARCHAR]
a
Address di
Text [VARCHAR]
In
rs
b. A table named Exam_Marks with these fields to store the marks of the students
b
in all subjects.
Pu
n
2. Enter the data of all the students in your class in both the tables.
3. Create a query on the Student_Details table to display only Sname and Phone
Number.
4. Create a report using the Exam_Marks table in which the records are sorted in a
descending order of the Total field.
141
Percentage Grade
90 or above A
d
80–89 B
Lt
70–79 C
t.
Pv
60–69 D
a
di
50–59 In E
Less than 50 F
rs
he
b lis
Pu
n
illa
m
ac
M
©
142
d
Lt
c. Which of the following is used to connect different symbols in a flowchart?
t.
(i) Flow lines (ii) Connector
Pv
(iii) Process (iv) None of these
a
di
d. Which key needs to be processed to run a query in Base?
In
(i) F5 (ii) F6
rs
(iii) F7 (iv) F8
he
b. The two ways of creating a report in Base are using .............................. and
using .............................. .
c. There are three types of database models: .........................., ..........................
and ............................... .
d. The result of a query is displayed in the form of a...............................
e. A ............................... is a pictorial representation of an algorithm.
3. State true or false.
a. Command prompt refers to the place where the user types the command and
feeds to the system.
b. In Base, forms define a medium through which you can present data in a
professional format.
143
d
Lt
Worksheet 2
t.
Pv
(Based on Chapters 5, 6, 7 and 8)
1. Tick () the correct option.
a
a. In Python, a mapping data type is
di
In
(i) Unordered (ii) Mutable
rs
he
(i) ** (ii) ^
Pu
(iii) % (iv) #
n
c. In which type of network topology is each note linked to every other note in the
illa
network?
m
d
4. Answer the questions.
Lt
a. Explain different sequence data types available in Python.
t.
Pv
b. Differentiate between guided and unguided media.
c. Write a short note on personal area network (PAN).
a
di
d. Describe the use of the if...else statement in Python.
In
e. What is the difference between mobile apps and Web apps?
rs
he
b lis
Pu
n
illa
m
ac
M
©
145
d
Batch-processing operating system: an operating system in which the instructions, data
Lt
and some control information are submitted to the computer in the form of batches
t.
Pv
Bluetooth: a wireless technology used for exchanging data over short distances
Client-server network: a computer network in which many workstations (called clients)
a
di
are connected to a centralised host computer known as server
In
Comments: non-executable statements used in a program to increase its readability
rs
Computer network: a group of computers and other peripheral devices (such as printers
he
and modems) connected by means of communication links to share their resources with
lis
each other
b
Pu
Data transmission media: the medium used for transmitting data between the connected
devices in a network—can be classified as guided and unguided media
n
illa
DBMS: stands for Database Management System—a collection of programs that allow
you to create, add, modify, delete, and retrieve data to and from a database
M
Distributed operating system: an operating system that uses multiple central processors to
serve multiple real-time applications and multiple users
E-commerce: buying or selling of goods and services online
Extranet: a computer network that allows outside users to have limited access to a part of
the organisation’s information
Field: holds one piece of information about an item
Flat file database: a database that stores data in the form of a plain text file
Flowchart: a pictorial representation of an algorithm
Form: provides a medium of entering, editing, and viewing the information in the tables
in Base
146
d
building or a campus
Lt
Literals: the identifiers whose values do not change during program execution
t.
Pv
MAN: stands for Metropolitan Area Network—a network that connects a large area such
as a city or an area up to 100 sq. km.
a
di
Mobile app: a type of application software designed to run specifically on a mobile device,
In
such as a smartphone or a tablet
rs
Multiprocessor operating system: an operating system that runs on more than one
n
Multi-user operating system: an operating system that allows multiple users to use the
m
Network devices: devices which help computers to get connected in a network for efficient
M
communication
©
Network topology: the way in which computers and other devices are connected to each
other in a network
NIC: stands for Network Interface Card—a hardware device that enables a computer to
connect to a network using an Ethernet cable with a RJ-45 connector
Operating system: a set of programs which controls the working of a computer system
Operators: the symbols that define the type of operation (such as addition, subtraction,
and so on) to be performed on the data items used in a program
PAN: stands for Personal Area Network—smallest computer network for one person’s use
Peer-to-peer network: a computer network in which the computers having equal capacity
and capability (called peers) are connected to each other to use the resources on the
network
147
d
Record: a group of related fields
Lt
Relational data model: a data model in which information is stored in the form of tables
t.
and different tables are related through common fields
Pv
Social networking: the use of online platforms such as websites or applications by the
a
people to build social relationship with other people who share similar interests
di
Software: an organised collection of computer data and instructions
In
Structured database: a database that contains a number of tables arranged in an order
rs
System software: the software that manages and controls all activities in the computer
lis
system
b
Pu
Time-sharing operating system: an operating system that allows multiple people, located
at various terminals, to use a single computer system at the same time
n
illa
User interface: the means by which the user interacts with a computer system
Variable: a name representing a memory location which stores a value of a specific data
M
type
©
Web app: a program running on a web server and to be accessed through a web browser
Wi-Fi: stands for Wireless Fidelity—widely used for creating wireless LANs and also for
providing wireless Internet access
Report: defines a medium through which you can present data in a professional format
Table: represents the data in the form of a grid which comprises rows (records) and
columns (fields)
TCP/IP: stands for Transmission Control Protocol/Internet Protocol—the suite of
communication protocols which is used as a standard for transmitting data over networks
WAN: stands for Wide Area Network—a network that spans several cities or even countries
148
KEY FEATURES
Text is presented in a clear and simple language, with enhanced visual appeal.
All the ideas and concepts are explained with clear-cut and practical examples.
d
Lt
Each and every topic is thoroughly researched and certified by consultant teachers from schools.
t.
The illustrations given in the chapters lend enormous support as learning aids.
Pv
For the Teacher boxes provide teaching ideas and tips for the teachers.
a
Did You Know and Note boxes impart more information and interesting facts about the topic being
di
discussed.
In
An exhaustive set of questions and activities are given at the end of each chapter to reinforce
rs
Revision exercises and Project work at the end of the book help to sharpen the concepts learnt in
is
the chapters.
bl
Pu
Sample questions based on National Cyber Olympiad at the end of the book help students prepare
for the Olympiads.
n
illa
ITL Education Solutions Limited (ITL ESL) is a part of the ITL group which has operations all over
the world with a significant presence in education and IT-enabled services. It specialises in handling
m
educational projects in IT domains with a dedicated R&D wing of industry experts that helps in designing
ac
Write to us at [email protected]
` 435