CBSE_Hexa_G8_AY25-26

Page 1


One Byte at a Time

COMPUTER SCIENCE

COMPUTER SCIENCE Hexa

Acknowledgements

Academic Authors: Jatinder Kaur, Ayushi Jain, Anuj Gupta, Simran Singh

Creative Directors: Bhavna Tripathi, Mangal Singh Rana, Satish

Book Production: Rakesh Kumar Singh, Sakshi Gupta

Project Lead: Jatinder Kaur

VP, Learning: Abhishek Bhatnagar

All products and brand names used in this book are trademarks, registered trademarks or trade names of their respective owners.

© Uolo EdTech Private Limited

First published 2025

This book is sold subject to the condition that it shall not by way of trade or otherwise, be lent, resold, hired out, or otherwise circulated without the publisher’s prior written consent in any form of binding or cover other than that in which it is published and without a similar condition including this condition being imposed on the subsequent purchaser and without limiting the rights under copyright reserved above, no part of this publication may be reproduced, stored in or introduced into a retrieval system, or transmitted in any form or by any means, electronic, mechanical, photocopying, recording or otherwise, without the prior written permission of both the copyright owner and the above-mentioned publisher of this book.

Book Title: Hexa Computer Science 8

ISBN: 978-81-979297-3-1

Published by Uolo EdTech Private Limited

Corporate Office Address:

85, Sector 44, Gurugram, Haryana 122003

CIN: U74999DL2017PTC322986

Illustrations and images: www.shutterstock.com, www.stock.adobe.com and www.freepik.com

All suggested use of the internet should be under adult supervision.

Preface

In today’s rapidly evolving digital landscape, computer science has become an essential field of study, shaping the world around us in countless ways. From the smartphones in our pockets to the vast networks that connect people across the globe, computer science drives innovation and progress in nearly every aspect of modern life. In today’s fast-paced digital world, understanding the basics of computer science is as important as learning to read, write, or solve maths problems.

Recognising this imperative, the National Education Policy (NEP) 2020 has strongly recommended the integration of coding skills, computational thinking, critical analysis, and problem-solving abilities into the curriculum.

Inspired by these insights, Uolo has introduced a comprehensive program, Hexa, for grades 1 to 8, to empower young minds with the knowledge and skills they need to thrive in the digital age. From the basics of how computers function to the tools that shape our digital landscape, this series opens the door to a world of endless possibilities. This series will build a strong foundation, helping shape the next generation of digital citizens and innovators. It aims to demystify the world of computer science, making it accessible and engaging for young learners, while preparing them for future academic and professional pursuits in the field.

We believe that learning computer science should be an engaging and accessible experience for all children. This series takes a project-based approach, allowing students to learn by way of concurrently applying acquired knowledge and skills. As they progress through the course, they will build strong foundations in computational thinking, coding basics, and digital literacy. Our program focuses on three key areas:

1. Computer Science Fundamentals: Core concepts are introduced step by step, ensuring a solid grasp of how computers function, and how information is processed and stored.

2. Latest Computer Tools: Various computer tools relevant to today’s world are included, equipping students with the confidence to thrive in the digital age.

3. Introduction to Coding: The series offers an introductory look into coding, preparing students for more advanced learning in the future.

To broaden the learning process, we have included informational annexures on Artificial Intelligence (AI) and its related fields, offering students an early insight into the groundbreaking technologies that are shaping our world. These sections aim to inspire curiosity and encourage a deeper exploration of computer science.

Our mission is to make computer science approachable and exciting for young learners. By providing early exposure, we aim not only to teach about computers but also to cultivate skills that will benefit students in their future endeavours.

We invite you to embark on this exciting journey with us through the world of computer science. Let us empower the next generation with the skills and the knowledge they need to thrive in a digital world.

The NEP Tags

The National Education Policy (NEP) 2020 outlines essential skills, values, dispositions, and learning approaches necessary for students to thrive in the 21st century. This textbook identifies and incorporates these elements throughout its content, activities, and exercises. Referred to as “NEP Tags”, they are defined as follows:

INTEGRATED

Art Integration

Bringing creativity and fun into learning by combining music, drama, and art with other subjects CRITICAL

Sports Integration

Using games and sports in daily life to enrich computer-related activities

Holistic & Integrated Learning

Cross-curricular linkages to make the learning experience more holistic, joyful and meaningful

Critical Thinking

Coding opportunities to apply higher-order skills like algorithmic and computational thinking, and problem-solving

SDG

Hands-on Activity

Step-by-step activities to enable learners put theoretical knowledge into practice

Sustainable Development Goals

Applied computer science activities related to real-world issues and sustainable development

SEL Social Emotional Learning

Developing the skills to understand and manage emotions, build positive relationships with others and make responsible choices

GAMES

1

ISP

Chapter at a Glance Walkthrough of Key Elements

An Internet Service Provider, or ISP, is a company that provides you access to the internet, often for a fees. Some examples of ISPs are BSNL, Airtel, Jio, and Excitel.

To draw a circle, press and hold down Did You Know?

Communication Media

Communication media helps us connect to the internet. Let us see some of their types. 1.

DSL

DSL stands for Digital Subscriber Line. It is a type of communication media that uses your telephone line to transmit data.

Project-based Learning: A project-based learning approach employed to foster an engaging and interactive learning experience

2. Cable

Cable is a type of communication media that uses the existing cable television wires to connect your computer to the internet.

3. Fibre

NEP Tags: To show alignment with NEP skills and values

Fibre optic cable is a type of communication media that uses light rays to connect your computer to the internet. Fibre optic cables are much faster than copper or cable wires. In fibre cables, the data travels in the form of light. Nothing in the universe travels faster than light. So, the internet through fibre optic cables is often the fastest type of internet connection available.

2

Chapter Checkup

Discuss: A multi-faceted probing question, related to the concept, that arouses curiosity

Discuss!

Find out which type of internet connection your house or school has.

go to the main drawing area.

Now think of the fan speed knob, or regulator, on the switchboard. It changes the speed at which the fan spins, instead of just switching it on or off. We can have the fan spin at the fastest speed, reduce it to a slower speed, then much slower, and finally switch it off. We can do more things with the regulator than the switch. That is how analog signal works.

e  I hold all the blocks for a block category. A Fill in the blanks.

Did You Know: Interesting facts related to the topic

Did You Know?

India has the second-largest internet user base in the world, with over 70 crore users.

3

Think and Tell

Can you think of more examples of analog and digital signals?

Hints menu bar  untitled  backdrop  blocks  create

ISP

4. Hold the left mouse button, move the pointer and then release the button. You will see that a triangle has been drawn.

1 In Scratch, we use colourful to create our own games, stories, and drawing.

An Internet Service Provider, or ISP, is a company that provides you access to the internet, often for a fees. Some examples of ISPs are BSNL, Airtel, Jio, and Excitel.

Do It Yourself: Short exercises between the chapter to pause and assess comprehension

Communication Media

2 To create a project in Scratch, you need to click .

In the same way, we can draw many shapes in Paint.

Communication media helps us connect to the internet. Let us see some of their types.

3 By default, the name of the Scratch project is

1. DSL

Think and Tell: Analysis, reflection, and text-to-self connection based prompts for discussion in class

DSL stands for Digital Subscriber Line. It is a type of communication media that uses your telephone line to transmit data.

4 The purple bar at the top of the Scratch editor is called the .

2. Cable

5 The background of the stage is called the

F Apply your learning.

AI Annexures: To offer a basic understanding of specific domains of Artificial Intelligence

Cable is a type of communication media that uses the existing cable television wires to connect your computer to the internet.

Artificial

e  I hold all the blocks for a block category.

3. Fibre

A Fill in the blanks.

Intelligence

Hints menu bar  untitled  backdrop  blocks  create

Artificial Intelligence

Chapter Checkup: Chapter-end practice exercises aligned to different levels of Bloom’s Taxonomy

Artificial Intelligence, or AI, helps computers think. It can learn like people do.It learns new things all the time. AI is very smart. It will keep changing and getting better.

AI

Apply Your Learning: Intellectually stimulating questions designed for higher order thinking and analysis

Test Papers: Designed to evaluate understanding of core concepts and application of skills

A. Fill in the blanks.

1 In Scratch, we use colourful to create our own games, stories, and drawing.

Chapter Checkup

2 To create a project in Scratch, you need to click

1 Nia is making a Scratch project where she needs to move the dog from left to right. Which block should she use?

Fibre optic cable is a type of communication media that uses light rays to connect your computer to the internet. Fibre optic cables are much faster than copper or cable wires. In fibre cables, the data travels in the form of light. Nothing in the universe travels faster than light. So, the internet through fibre optic cables is often the fastest type of internet connection available.

e  I hold all the blocks for a block category. A Fill in the blanks.

3 By default, the name of the Scratch project is

Discuss!

4 The purple bar at the top of the Scratch editor is called the

Hints menu bar  untitled  backdrop  blocks  create

F Apply your learning.

Can Do?

5 The background of the stage is called the

1 In Scratch, we use colourful to create our own games, stories, and drawing.

Chapter 4 • Browsing the Internet

1 Nia is making a Scratch project where she needs to move the dog from left to right. Which block should she use? Chapter Checkup

Find out which type of internet connection your house or school has.

2 To create a project in Scratch, you need to click

3 By default, the name of the Scratch project is

4 The purple bar at the top of the Scratch editor is called the

5 The background of the stage is called the F Apply your learning.

Test Paper (Based on Chapters 1 to 4)

1 Nia is making a Scratch project where she needs to move the dog from left to right. Which block should she use?

Test Paper (Based on Chapters 1 to 4)

1 In Scratch, the blocks you put together in the script area are called a

A. Fill in the blanks.

2 The is the background of the stage.

1 In Scratch, the blocks you put together in the script area are called a 2 The is the background of the stage.

• Introduction to Computer Networks

• Network Terminologies and Devices

• Types of Computer Networks

• Network Architecture and Protocols

• Accessing a File From a Shared Drive

• Network Security

• Introduction to Cyber Ethics

• Unethical Practices

• Online Safety Measures

• Digital Footprints

• Digital Citizenship

• Introduction to

• Cryptocurrency: A Blockchain Case Study

• Introduction to Apps

• Accessing Apps

• Classification of Mobile Apps

• Developing an App

• Understanding Databases

• Database Management System

• Structured Query Language

• More SQL Queries

• Creating a Video in Canva

• Components of Video Editor in Canva

• Adding Videos in Canva

• Basic Video Editing Tools

• Applying Effects on Videos

• Downloading and Sharing a Video

• Introduction to

• Python Data Types

• Variables and Operators

• Conditional Statements

• Iterative Statements

• Lists

• Tuples

• Difference Between Lists and Tuples

• What Is HTML?

• Basic Tags of HTML

Understanding CSS

• What Are HTML Forms?

• Form Structure

• Creating and Displaying a Form

• Form Attributes

• Form Validation

• Creating Links

• Adding Audio and Video

1 Networking Fundamentals

Introduction to Computer Networks

Suppose you are going on a family road trip and observe how roads connect different places, such as villages, cities, and towns.

In a similar way, our world is connected through computer networks. Just as roads link various locations, computer networks link devices, allowing them to share information. These digital roads help messages and data travel between computers, regardless of their location.

A computer network is a way to connect computers using communication devices so that they can exchange data and resources with each other.

Need of a Computer Network

When several people are working on the same project under one roof or at remote places, they need to communicate with each other, and this is possible only with the help of a network. If different people are living in different places, they share messages with each other. If they are all located in one building, they can easily share hardware resources with each other, such as one printer, which can be shared among

many team members. Therefore, there is a great need for computer networks in our lives, even for sending a small message to another person to communicate with people across the globe, for storing huge amounts of information, making video calls, sending audio messages, sharing software among many people, etc.

Uses of Computer Networks

Computer networks are used for different purposes in our daily lives.

File Sharing: With the use of networks, you can share the data and documents with each other. For example, you can share any file with your friend who is located remotely in a different country.

Resource Sharing: Suppose all the students in your class are in the Computer Lab, each using an individual computer. The teacher has asked all the students to print an article on the topic “Importance of Communication in Our Lives”. Will you want a separate printer for every computer? The answer is No.

You can observe that only one printer in the lab will be shared with all the students, and this is possible only because of the computer network. This is called resource sharing.

Communication: Suppose your teacher has assigned a project to you with two other team members. One of your team members has gone to some other city for a week. You can then connect to your team members using a computer network and complete the project on time. This is only possible with the help of computer networks.

Database Access: Computer networks help to access the same database from multiple computers. This further enhances the storage capacity of data and access to the stored data.

Security: Suppose you have stored your class assignments on the network. Your data is secured on the network because in the network, a key (password) is provided to the user to access that data.

Backup: What will happen if you accidentally delete your project files from your individual computer on the network? Do not worry about that. In computer networks, the data is stored on a central computer, known as a server. This server has a backup utility enabled on it. So, taking the backup of data is also a benefit of computer networks. In case of data loss, you will have the backup copy of your data.

Advantages of Computer Networks

Computer networks are beneficial to us in many ways. Some of the advantages of computer networks are discussed:

Cost Reduction: Because the hardware resources (printers and scanners) are shared among all the computers on the network, the cost of additional equipment is saved.

Less Data Redundancy: Data redundancy occurs when the same piece of data exists in multiple places. All the data on the computer network is stored on the server. Therefore, there is less redundancy in the network.

Less Data Inconsistency: Data inconsistency means when the same data exists in different formats at different places. Since data redundancy is reduced, it also reduces data inconsistency.

Data Centralisation: In a computer network, the server provides services to all the other computers. All the data in a computer network is stored on a server at a centralised location. This centralised storage of data provides easy accessibility to all users.

Data Recovery: The server’s capability of taking regular data backup helps with easy data recovery in case of data loss or network failure.

Disadvantages of Computer Networks

Apart from many advantages, there are also some disadvantages of computer networks. Let us learn about them.

Security Concerns: Network security is a major concern as the data is being shared in a wired and wireless medium which can be stolen by some tricky people, leading to data loss or change of data.

High Maintenance Cost: A computer network needs timely maintenance by a special team of experts. The maintenance cost of a computer network is higher than that of an individual computer.

Complex Architecture: Computer networks have a complex architecture, for which a specific type of setup is required. Purchasing the necessary equipment (such as cables and other devices) for network architecture can be expensive.

Compatibility Issues (Hardware and Software): To be a part of the network, you should have the same version of hardware and software as all the other computers that are supposed to be part of the network.

Data Loss (In Case of Network Failure): If the server computer that stores all the data of individual computers fails, all the data will be lost. This is a major disadvantage of a computer network.

Need for Skilled Personnel: Managing a large network is complicated, requires training, and a network manager usually needs to be employed. To maintain a large network, a special team of skilled technical persons is required. Hence, it bears an extra maintenance cost.

Do It Yourself 1A

Answer the following questions.

1 What do you mean by resource sharing?

2 The computer teacher has assigned a project to Sneha and Priyanka. Due to some emergency, Priyanka has to go to New Zealand. How will Priyanka and Sneha complete their project together on time?

3 Suppose there is only one scanner in your computer lab at school. All the subject teachers want to scan their documents while sitting at their computers in the computer lab. Is this one scanner sufficient, or is there a need for a separate scanner for every computer?

Network Terminologies

Some important network terms are discussed as follows:

Term

Node

Meaning

A device in a computer network which is used to send or receive data. A computer, mobile, tablet, laptop, etc., are called nodes.

Link It is a connection between two computers or devices, such as cable, Wi-Fi, fibre optic, etc.

Packet

A unit of data or information that is transferred over the internet. For example, you send an email or message to a friend.

ProtocolProtocols refer to a set of rules which are to be followed for sending data on a network.

TopologyThe physical arrangement of computers or devices to link with each other. For example, star topology, bus topology, etc.

Bandwidth The amount of data or information that can be transmitted over the internet or network. For example, 1 Gbps or 1 Mbps (bps-bits per second, G stands for Giga and M for Mega).

LatencyThe time taken for a message to travel from one end of the network to the other end.

Explore More!

Data units start from one bit and can go up to yottabytes. Scan this QR code to know more about data units.

Network Devices

Computer network devices are hardware components that are required for computers to communicate with one another over the network. Some of these are discussed as follows:

 Network interface card (NIC): It is a hardware component installed on a computer to connect a computer to a network. It is a circuit board or a chip without which a computer cannot connect with another computer on a network.

 Ethernet networking cable: It is a hardware cable which is required to connect one computer with another computer to share information and devices like printers or scanners. This cable connects wired devices in a Local Area Network.

 Modem: Modem stands for Modulator-Demodulator. It is a hardware device which sends and receives data over a telephone line, cable, or fibre optic. A modem converts digital signals from a computer into analog signals which can travel over telephone lines. It also re-converts analog signals back into digital signals.

 Hub: It is a networking device that transmits the received information to all the devices on the network. A hub has many ports in it. A computer that intends to be connected to the network is plugged into one of these ports.

 Switch: A switch is a device that connects different computers on a network. It transfers data from one computer to another. A switch receives data from one computer, processes that data, and forwards that data to the destination device.

 Router: It is a device which routes the data or information over a network. Routers may also be used to connect two or more logical groups of computer devices known as subnets or subnetworks.

Did You Know?

A router needs the IP address of a computer to which the data is to be sent. The IP address of every computer is unique (does not match with any other computer).

Do

It Yourself 1B

1 Fill in the blanks.

a is a device that converts one type of signal to another.

b is used to connect multiple computers and devices directly to the network using cables.

2 Name different computer network devices.

Types of Computer Networks

There are different types of networks, which are categorised according to the geographical area they cover. Let us discuss the types one by one.

Types of Computer Network

Personal Area Network (PAN): A PAN, which is the most fundamental kind of network, consists of a wireless modem, one or two PCs, smartphones, tablets, printers, etc., working within a range of 10 metres. These networks are usually controlled by a single person or business from a single device and they are generally found in small scale workplaces or houses. They can be categorised into wired and wireless, based on the type of connectivity among the networking devices.

Local Area Network (LAN): It is a computer network that only extends up to a few metres across a relatively limited region, such as a school or a college building. LANs are commonly used to link desktop computers and workstations in corporate settings, to share resources. LAN ranges between 100 and 1000 metres.

Metropolitan Area Network (MAN): It is a computer network that connects devices within a metropolitan city or a small town. Two or more connecting LANs form a MAN. A MAN ranges up to an area of 100 km. MAN is costlier than LAN. A cable TV network is an example of a MAN.

Wide Area Network (WAN): Wide Area Network connects computers from various countries and continents. WAN connects different LANs and MANs from across the globe. The internet is an example of WAN.

Wireless Network: A wireless network can be created in a small area such as a room or a house. The technology used to create a wireless network is known as Wi-Fi. Wi-Fi stands for Wireless Fidelity. It is a type of Local Area Network (LAN) that uses wireless communication technology to connect various devices like computers, smartphones, tablets, and other gadgets to the internet using a Wi-Fi router. These devices can be connected without the need for physical cables.

Think and Tell

Types of Network Topologies

Topology is a physical and logical layout of different devices (nodes) and connections in a network. The configuration of how computer systems or network devices are connected to one another is known as a topology Different types of network topologies are discussed as follows:

Bus Topology: In a bus topology, all the nodes are connected to a single common cable. A node puts a message on the cable, that is sent to all other nodes in a network. The disadvantage of it is that the messages clash when multiple nodes try to send data at the same time. Terminator removes data from the line.

Star Topology: In star topology, the nodes are connected to a centralised hub, switch, or a computer forming a star. The central computer is called the server, while other computers are called the clients. The disadvantage of the star topology is that if the central computer fails, the whole network will be disabled.

Ring Topology: In ring topology, the nodes are connected to each other forming a ring. A node forwards the message received from the previous node to the following node. Data flows unidirectionally, in a clockwise direction. The disadvantage of it is that if any one node fails, the entire network will fail.

Tree Topology: In tree topology, nodes are connected in a parentchild hierarchal manner. Tree topology is a combination of star and bus topology. The disadvantage of this topology is that the entire communication depends upon the bus and if the bus fails, the entire network will fail.

Mesh Topology: In the mesh topology, every node is directly connected to every other node forming a mesh. The disadvantage of mesh topology is that the network is costly, due to the large number of cables used and it is difficult to find a faulty node. An example of mesh topology is the internet.

Discuss!

How is a tree topology better than a ring topology?

Network Architecture

The following architectures are used to design networks:

Network Architecture

Peer-to-Peer Architecture

Client-Server Architecture

Peer-to-Peer (P2P) Architecture: It is a type of networking architecture in which all the connected computers have equal abilities. All computers in this network are of the same level. Bitcoin () is an example of P2P architecture.

 Client-Server Architecture: It is a type of network in which a central computer manages most of the resources. This computer, which has all the resources and provides services to others, is called a server and the computers which use services provided by the server are known as clients. That is why the name of this architecture is clientserver architecture.

Difference Between Peer-to-Peer and Client-Server Architecture

The following table summarises the differences between peer-to-peer and client-server architecture:

Peer-to-Peer

In this architecture, every node serves as a client and server.

Peer-to-Peer network is less secure because as the number of nodes increases in this network, the chances of vulnerability also increase.

Every node participates in equal management of the network. Therefore, client growth may affect the performance.

The server is not bottlenecked, because the service requests are distributed among all clients.

Network Protocols

Client-Server Architecture

In this architecture, one or more nodes serve as a server and all other nodes behave as clients.

Client-server network is more secure because the server can validate the client’s access.

Most of the work is managed by the server. Therefore, client growth does not affect the performance.

The server may become overloaded with an increase in the number of service requests by the clients.

A network protocol is a set of rules which governs the communication between computers over a network, i.e., it describes how the information will be transmitted over the network.

Let us learn about some of the main network protocols.

Transmission Control Protocol / Internet Protocol (TCP / IP)

The TCP/IP stands for Transmission Control Protocol/Internet Protocol. TCP/IP is a combination of two separate protocols: Transmission Control Protocol (TCP) and Internet Protocol (IP).

TCP provides end-to-end communication between computers and specifies how the data will be divided into small packets. Then, those packets will be transferred to the destination, where all packets will be assembled again to recreate the original message.

IP assigns a sequence number to every packet so that packets can be assembled in the correct order at the destination.

Hypertext Transfer Protocol (HTTP): HTTP is used to transfer data such as texts, images, videos, and other multimedia files over WWW (World Wide Web). When you want to open any website such as www.flipkart.com, HTTP protocol sends a request to the web server to open that website. The message sent by the client (Web Browser) is called the request and the message responded by the server is called the response.

Simple Mail Transfer Protocol (SMTP): This is the simplest protocol used to send emails between computers. SMTP is used to send messages from mail client to mail server. The email at the receiver’s end is received using IMAP.

Internet Message Access Protocol (IMAP): It is a popular internet protocol for retrieving emails. Its usage varies according to the environment. While using an email application, it is essential to specify the sending protocol (SMTP) and the email receiving protocol (IMAP).

File Transfer Protocol (FTP): FTP is the simplest method to transfer files from one computer to another over a network, using FTP client and FTP server software. This protocol is used for uploading and downloading files from a computer to the internet. It makes use of TCP/IP connections for transmitting files.

Did You Know?

TCP/IP was developed in the year 1970.

Accessing a File From a Shared Drive

Nowadays, you can share your data with other users even if they live in a remote area or faraway place. This sharing or transferring of data is possible only through a shared drive or Google Drive.

It allows you to share your data on Google Cloud Servers. Google Drive offers 15 GB of free storage capacity.

Storing a File on Google Drive

Follow the steps mentioned below to store a file on Google Drive:

1. Sign in with your Google Account. If you do not have a user ID and password, first register yourself on Google.

2. Click on the Google apps icon button located on the top right-hand corner of the Gmail account.

3. Click on the Google Drive icon. The Google Drive window will open.

4. Click on the New button. For uploading a single file, click on the File upload option. For uploading a folder, click on the Folder upload option.

Did You Know?

Google Drive was launched on 24 April, 2012.

5. The Open dialog box will appear. Select the file you want to upload.

6. Click on the Open button. The selected file will be uploaded on Google Drive.

Sharing a File on Google Drive

Follow the steps to share a file on Google Drive:

1. Select My Drive, and select the file you want to share with another user.

2. After selecting a file, click on the Share icon. Type the email addresses of recipients in the Add people and groups box. If you want, you can also add a message that will be emailed to the recipients.

3. You can select whether the other user can edit, comment, or simply view the shared file or folder.

Viewer: Allows the recipient to only view the file.

Commenter: Allows the recipients to add their comments only on the shared file.

Editor: Allows the recipients to edit the shared file.

By clicking on the Send button, the file will be shared. You can also click on Copy Link option to get the link of the shared file and then you can share it with the recipient through email or message.

Select your profile icon and click on the Sign Out button to get signed out of Google Drive.

Network Security

Because of security breaches on the network, it is necessary to use some network security measures. Some common network security measures are discussed below:

Firewall: A firewall is a network security device that monitors and filters incoming and outgoing network traffic based on an organisation’s previously established security policies. It protects unauthorised access to a computer by blocking unsolicited communication. Firewalls come in both hardware and software forms. Some examples of the latest firewalls are Sophos Firewall, Check Point Firewall, pfSense Plus, WatchGuard, etc.

Antivirus: Computers are vulnerable to attacks or viruses when they are connected to a network. Therefore, it is necessary to install antivirus software on the computer system. A number of antivirus software programs are available in the market. For example, AVG, Quick Heal, Norton, McAfee, Avast, Kingsoft, etc. These antivirus software programs scan all the drives of a computer to detect any malicious virus in any file or folder. They get rid of that virus, either by deleting it or making it inactive.

Safe Online Practices

When you access the internet to perform some online activities such as shopping or transferring of money, etc., your computer is at high risk. Therefore, some online protective measures must be followed, some of which are as follows:

 Clear browser cookies.

 Remove unknown or unwanted applications.

 Regularly update all applications and software.

 Perform secure transactions on the portals with a padlock sign.

 Keep passwords safe and strong.

Do It Yourself 1C

1 Match the protocols with their functions.

HTTP (Hypertext Transfer Protocol) Used to send emails between computers.

SMTP (Simple Mail Transfer Protocol) Transfers data such as text, images, and videos over the World Wide Web.

IMAP (Internet Message Access Protocol) Transfers files from one computer to another over a network.

FTP (File Transfer Protocol) Retrieves emails and is essential for email applications.

2 Select the correct network type for each description.

a connects devices like PCs and smartphones within a 10-meter range in a small area.

b links devices within a school or office, covering between 100 and 1000 meters.

c connects networks within a city or town, spanning up to 100 kilometers.

d connects devices across countries and continents, like the internet.

Chapter Checkup

A. Fill in the blanks.

is a group of two or more computers connected to exchange information/data and to share resources.

In a topology, all the nodes are connected to a single common cable.

connects devices within a city or a small town.

Data means when the same data exists in different formats at different places.

software scans all the drives of a computer to detect any malicious virus in the computer.

B. Tick () the correct option.

Which of the following is not an advantage of a computer network?

a  Cost reduction

c  High maintenance cost

b  Less data redundancy

d  Less data inconsistency

A computer network is a group of two or more computers connected together to exchange and to share

a  Data, Resources

c  Software, Connections

b  Devices, Secrets

d  Hardware, Communication lines

Data occurs when the same piece of data exists at multiple places.

a  Inconsistency

c  Consistency

Which of the following is not a network topology?

b  Differentiation

d  Redundancy

a  LAN b  Star

A

C. Write T for True and F for False.

MAN is costlier than LAN.

PAN connects people across the globe.

Hub uses only a single port.

No data recovery is possible in the case of communication over computer networks.

There is no single point of failure in the case of mesh topology.

D. Answer the following questions.

Define WAN.

Write the advantages of computer networks.

Explain the terms hub and router.

Discuss star topology and state one disadvantage of it.

Differentiate between bus and ring topologies.

E. Apply your learning.

Ms Anju wants to open her new office branch in Pune and wants to connect with previously opened branches in Haryana and Mumbai. Which network type will she prefer?

Ram wants to create a computer network in a circular way. Which type of topology will you suggest to him?

In a household, wireless networks (Wi-Fi) are commonly used. Describe the advantages of having a wireless network at home as compared to a wired network.

Arun is the technology officer in an organisation. What are three potential disadvantages or challenges that he might face when managing a computer network?

Imagine you are a businessperson. Why do you think it is a good idea for you to connect all the computers in your company to a network?

Cyber Ethics and Safety 2

Introduction to Cyber Ethics

Imagine you have the habit of diary writing. You write all your secrets in the diary and keep it hidden in your room. What if someone steals it or reads it? This is a violation of your privacy.

Similarly, while using the internet, you have to be very careful and respect others’ privacy. Let us learn more about moral principles in this chapter.

The uses of the internet and other technical breakthroughs have made the world more interconnected in the current digital era. Even though this connectivity has many advantages, it has also raised some ethical questions about how people behave and interact online.

The study of appropriate behaviour and moral principles in the digital sphere is known as cyber ethics, also referred to as internet ethics or online ethics.

Key Aspects of Cyber Ethics

Privacy Safeguards: Cyber ethics places a strong emphasis on the value of protecting people’s privacy online. Every individual’s private data and personal details should remain safe. This therefore includes respecting user consent, handling sensitive data securely, and preventing unauthorised access or data breaches.

Cyber ethics outline moral principles for good human behaviour and interaction in the digital world. These ethical principles are essential to ensure responsible and ethical conduct in the use of technology and the online environment. Cyber ethics include:

Online Behaviour: Ethical behaviour in cyberspace includes promoting respectful and responsible online communication. This involves refraining from cyberbullying, hate speech, harassment, and other harmful types of behaviour that can negatively impact individuals or communities.

Digital Security: The digital devices as well as the data need to be protected against any theft or damage. This means that intellectual property should remain secured. Intellectual property refers to the ownership and protection of creative and unique ideas, inventions, and

digital works over the internet. As you would not take someone’s artwork or story without permission, it is very important to respect and not use people’s digital work online, such as videos, music, and software, without permission. Respecting the rights to one’s intellectual property is a fundamental value.

Bridging the Digital Divide: Not all sections of society have the same access to technology. The poor, for example, have no access at all. Ethical use of technology promotes equitable access to technology for all members of society.

Accountability: People and organisations need to be accountable for their online behaviour in the digital age. This includes taking responsibility for errors, making changes for harm done, and upholding moral principles in all online activities.

Problems in Achieving Cyber Ethics

We now know that bad practices exist in the cyber world. We also understand that cyber ethics tell us how the world should be. There are some issues in achieving cyber ethics:

1. Restriction: Following cyber ethics online is always good. However, if restrictions are too srict, then they can limit the freedom of expression and innovation.

2. Interpretation: One cannot determine that following what type of behaviour online is acceptable or not. People may agree on some points and disagree on others.

3. Enforcement: Due to the international nature of the internet and the fact that several nations have their laws and regulations, it can be difficult to implement cyber ethics on a global scale.

4. Anonymity: Cyber ethics may conflict with people’s desire for online anonymity. It may be required for the people to expose their identity to be held accountable.

5. Evolving technology: As technology evolves rapidly, cyber ethics must adapt, which can be challenging to keep up with.

Unethical Practices

Discuss!

Think of issues on which people might disagree regarding online behaviour.

Many unethical practices are prevalent in society these days. Let us learn about them.

Cyberbullying

Using the internet to harass, scare, or hurt people is referred to as cyberbullying. Cyberbullying can happen if you send or receive messages to humiliate or threaten someone, spread untrue rumours, post embarrassing images, or create fake profiles. The victims of cyberbullying may suffer severe emotional and psychological effects.

Cyberbullying

Cyberstalking

Cyberstalking is the practice of constantly following someone’s online activity, mostly with the intention of frightening or upsetting them. Keeping an eye on someone’s social media pages, sending unwelcome messages, and issuing threats are some examples of cyberstalking. In many places, cyberstalking is prohibited and can lead to serious legal action.

Discuss!

Is it ethical to copy any data for your project from the internet?

Plagiarism

When someone copies another person’s ideas, work, or content without giving proper credit or getting permission, it is called plagiarism. This immoral behaviour can be seen in a variety of circumstances, including online content creation and academic content. It damages the worth of original work and may have negative effects on one’s academic or professional career.

Phishing

Phishing is a dishonest internet practice in which attackers pretend to be reliable organisations and trick people into disclosing personal information, such as passwords or financial information. The attackers can then use your personal information to do malicious things, like steal your money or identity. The most common form of phishing is email phishing.

Hacking

Hacking involves unauthorised access to computer systems, networks, or devices Hackers generally have bad intentions to engage in malicious activities such as data theft, spreading viruses, or disturbing digital infrastructure. Another form of hacking called ethical hacking, or “white hat” hacking, is performed by professionals to fix the problems in a computer system or network to keep them safe from hackers.

Spamming

Spamming refers to sending lots of unwanted and annoying messages to many people, often to make money or promote something. Spamming is considered unethical because it interferes with digital communication.

Identity Theft

Identity theft happens when someone pretends to be someone else. He/she does this often to steal money, data, or other important information, like credit card details, bank details, etc. This can really hurt people, causing them emotional and financial problems.

Do It Yourself 2A

Match the following.

Spamming Pretending to be a reliable source in order to trick others into disclosing their passwords or personal information.

Phishing Sending emails or messages that are meaningless and unnecessary.

Identity theft When an unauthorised person tries to access a computer system, a network, or data.

Hacking

Stealing someone’s personal information to commit fraud.

Online Safety Measures

Online safety measures are safeguards and behaviour designed to keep your security, privacy, and personal information safe when using the internet. Here are some important tips for online safety:

Use Secure Passwords: Create strong, challenging passwords for each of your accounts and change them frequently. Use a combination of symbols, numbers, and letters.

Phishing Alert: Be wary of emails, messages, or websites that request private data, such as passwords or credit card numbers. Before sharing any personal information, make sure the sender or website is genuine.

Regularly Update Software: Update your operating system, antivirus program, and other programs regularly. Security fixes are frequently included in software updates.

Use Secure Wi-Fi: Avoid accessing sensitive accounts or disclosing personal information when using public Wi-Fi networks.

Protect Personal Information: Exercise caution while disclosing personal information on websites and social media. Do not disclose too much personal information to the public.

Privacy Settings: To limit who can view your information, review and modify the privacy settings on social media sites and online accounts.

Educate Yourself:  Keep yourself updated about frequent internet hazards and frauds. The best defence against cyberattacks is awareness.

Secure Your Devices: Use screen locks, PINs, or biometric authentication to secure your PCs, cell phones, and tablets to avoid illegal access.

Data Backup: To prevent data loss due to hacker attacks or hardware failures, regularly backup vital data to an external source or a cloud service.

Think and Tell

What measures should you follow while shopping online?

Digital Footprints

An online activity trail is what a digital footprint looks like. It includes everything you do online, including sending emails, publishing on social media, and even just surfing websites. Your digital footprint reveals where you have been online, just like your footprints in the sand do. Because your digital footprint can impact your reputation and privacy, it is crucial to be cautious online. Think before you click, always!

Some examples of a digital footprint are as follows:

1. Social media posts

2. Online shopping

3. Emails

4. Search history

5. Online comments and review

Digital Citizenship

Digital citizenship is the term used to describe the ethical and responsible use of technology. By engaging in good digital citizenship, we help create a more secure and civilised online community for everyone. Here are a few examples:

1. Respecting others:  A good digital citizen should avoid cyberbullying when making comments on social media or participating in online forums.

2. Privacy protection: Digital citizens should keep their information private, including passwords and communications.

3. Using reliable sources: Always verify the reliability of information before sharing it to stop the spread of false information.

4. Responsible posting: Avoid posting any kind of offensive or dangerous material on social media.

5. Online etiquette: Always use appropriate language and avoid the use of uppercase letters while communicating online.

6. Copyright awareness: Be aware of copyright and refrain from using other people’s work frequently. Do not use anybody else’s work without their consent or due attribution.

7. Cybersecurity: Follow practices such as using secure passwords and keeping software up-to-date to attain a secure working environment.

Did You Know?

In India, when someone writes a book, creates music, or makes art, their work is protected by copyright. This protection lasts for their whole life, and then an additional 60 years. If there are many authors, it lasts for 60 years after the last author passes away.

Do It Yourself 2B

Tick () the activity that will contribute to the digital footprint:

Shopping online for a school bag

Posting a comment on a friend's picture on social media

Chapter Checkup

A. Fill in the blanks.

is the act of using digital platforms to harass, scare, or harm others.

Plagiarism involves using someone else's work or ideas without proper

Phishing is a deceptive online practice that aims to trick individuals into revealing information.

Cyberstalking is an illegal and internet activity. theft happens when someone pretends to be someone else.

B. Tick () the correct option.

What is the primary goal of phishing attacks?

a  To promote online safety b  To imitate trusted entities

c  To spread awareness about cybersecurity d  To encourage ethical hacking

Which of the following is an ethical practice? a

What is the purpose of digital footprints?

a  To track your online actions

c  To protect your identiy

What is the main reason behind identity theft?

a  Drive for fame

c  Financial gain and dishonest behaviour

What is the meaning of the term "digital citizenship"?

a  Being a citizen of a digital nation

c  Acting ethically and responsibly online

C. Who am I?

Protecting every person’s data.

Being kind to others online.

It is the act of harassing someone online.

It is the act of copying another person’s work.

Traces of your online behaviour.

D. Write T for True and F for False.

b  To hide your online activities

d  To stop online communication

b  Requirement for social interaction

d  Individual curiosity

b  Owning a digital device

d  Having a digital footprint

Cyberstalking involves constantly monitoring someone’s online activities.

Spamming refers to sending unwanted emails for promotional purposes.

Digital footprints cannot be traced to a specific person.

Digital citizenship is the term used to describe the ethical and responsible use of technology.

Plagiarism is defined as the act of copying another person’s idea, work, or content giving proper credit or taking permission.

E. Answer the following questions.

What do you mean by cyberbullying?

2

Explain the concept of digital citizenship and why it is important for young internet users.

F. Apply your learning.

Sneha has received some messages from her classmates that are not appropriate. What type of behaviour are her classmates showing? Is it ethical or unethical?

Arvind is very upset as he receives many unwanted emails daily. What is the name of this activity?

Prabha has received an email asking for her bank account details. Should she respond to that email or not?

Ravi uses the internet daily to search for information for his studies. What ethical practices should he be aware of and follow while being online?

You have received an email stating that you have won an iPhone. Should you believe such emails and respond to them or not?

Introduction to Blockchain 3

Introduction to Blockchain

Imagine you went on a school trip. You and your friends decided to create a digital diary. You wanted to store and save the memories of this trip in the drive.

In this diary, you all wrote down all the things that you did together, and everyone in the group has a copy. Whenever you or your friends added anything new to the diary, like a special memory or an important event, everyone of you had to agree if it was true and accurate.

The digital technology named Blockchain works in a similar way. Blockchain is a shared, unchangeable record that helps track transactions and assets in a business network.

To understand Blockchain in a better way imagine that you and your friends were using computers to note down your memories. Each time a new memory was entered, it was like adding a new page to this digital diary.

But here is the interesting part: every new page is linked to the one before it, just like a series of dots that are connected. Each page can be considered a block. Thus, a chain of connected pages is a blockchain.

Since everyone of you can see the whole chain, it’s really hard for anyone else to sneak in and change something without everyone noticing it.

The blockchain helps computers keep important information safe by connecting the pieces together in a way that’s really hard to cheat.

Discuss!

What would happen if one or two individuals of the group could add details in this diary that were not accurate?

Features of Blockchain

Blockchains have the following features:

Decentralisation

Decentralisation means that there is not just one single person, organisation, or central authority in control of it. Instead, control or decision-making is spread out among many different individuals or entities.

A blockchain is a digital chain that may be made up of many blocks from many parties involved. It allows people to store and share information in a decentralised and distributed system.

Transparency

Security and Immutability

A block is a specific unit of data that is part of a blockchain that holds specific verified information. The whole process is designed to be immutable, which means that while the information in it can be seen by all the users, no one will be able to change or delete the information.

Transparency means that everyone who is a part of that blockchain can see all the information, and nothing is kept hidden from them. This helps to build trust among the users.

User Privacy and Security

Blockchain also keeps the personal details of the users safe. This means that while everyone gets to see the information in that blockchain, no user can see each other’s personal information.

Did You Know?

Blockchain technology came into existence in 2008. However, the identity of the person or group behind the creation remains a mystery. The pseudonym “Satoshi Nakamoto” is used as the inventor, but the real identity of this individual or group has never been found.

Working of Blockchains

Let us understand how Blockchains actually work.

Imagine that you want to buy a piece of artwork from an online seller. What would the entire process look like if it were operating through Blockchains? Let us see!

All before, during and after details of the purchase available on the blockchain

Artwork physically transported to buyer, information confirmed and updated on blockchain

Blockchain records accurate purchase agreement that both parties confirm

Blockchain records transfer of money from buyer. Information confirmed by bank.

1. You, as the buyer, get accurate information on the blockchain on whether the artwork you are interested in is actually available with the seller or not. The security and transparency in blockchains allow us to trust the information and the seller.

2. You contact the seller to buy the artwork.

3. You then send a request to the seller that you want to buy the artwork. This request ‘transaction’ is recorded in the form of a block on the blockchain. Remember that each piece of new information is stored as a block in the blockchain. So, both you and the seller will be able to ‘see’ the updated information.

4. The seller reviews your offer, and you mutually agree on the terms of the transaction. Once both parties have agreed, this information will be recorded as a block on the blockchain. Both of you will be able to access this information anytime you want, but neither of you will be able to change it.

Think and Tell

5. After that you make the payment. Once the bank confirms that the money has been deposited into the bank account, this information of making the payment is also safely recorded on the blockchain. Since this information cannot be changed, your money is secured.

6. The seller sends the artwork to you, and you receive it after some time. This information is also updated into the blockchain.

7. Once you receive the artwork, you update the information that the transaction is now complete. What information is so important on the agreement that the blockchain should not allow any party to change it?

8. In case the seller refuses to send the goods even after receiving the money, the entire transaction details are available as proof that the artwork was not sent to you even after you had paid for it. Once again, the blockchain system can save you from losing your money.

9. At the end of the entire transaction, the blockchain now holds all details. It also knows that the seller no longer has that particular artwork, and that you now possess it.

It is important to note that the above example is a visualisation of how the purchase of artwork could work through blockchain. All digital transactions around us do not work on blockchains today.

Explore More!

Blockchain is a technology that can be applied in many fields! See some surprising uses!

Challenges of Blockchain

Like all other technologies, blockchain has some challenges too. Let us look at some of them.

Long Validation Process

One of the biggest strengths of blockchain is that it can provide accurate information. But the process of validation itself is sometimes very cumbersome!

Slow Speed in Working with Large Amounts of Information

The blockchain records all developments as information. But what if there are too many transactions that involve several people? Maintaining verified information at each step would become very difficult. So, while working on a larger scale, maintaining speed with security is difficult.

Interoperability

We learnt that blockchains are decentralised. It is possible that different blockchains are fundamentally different in the way they have been designed and created. This sometimes makes it difficult for different blockchains to communicate with one another.

Legal Challenges

Technology brings users from across the world together! But citizens of different countries are bound by the laws of their respective countries. Laws related to IT and technology tend to vary from country to country. So legal situations while dealing with blockchains might be complicated.

Do It Yourself 3A

Tick () the correct answer.

What is a blockchain?

a  A type of physical network

c  A decentralised digital book of records

b  A digital puzzle

d  A type of computer

Write T for True and F for False.

a  A blockchain is controlled by a single central authority.

b  Different blockchains may be different.

c  Different countries have the same laws related to blockchain.

d The information stored in blocks can easily be accessed by anyone who has access to the blockchain.

Imagine your school starts using blockchain for the entire exam process. Thus, there will be different blocks for creating question papers, conducting exams, and announcing results. Will you be able to change your marks in the system without the teacher knowing? Why/Why not?

Cryptocurrency: A Blockchain Case Study

We use the Indian Rupee, or INR, to buy things in India. The INR is the national currency of our country. Similarly, other countries have other currencies. We use Dollars, Euros and Pounds in the US, Europe and the UK, respectively.

When we withdraw money from the bank to buy something, the bank stores the records of our account. It can, at any time, tell us how much money is left in our account.

What if we use a debit card or UPI to pay? The bank digitally certifies that we have the money and lets us make the purchase. Once the purchase is made, the money immediately gets debited from our bank account.

Cryptocurrencies are very different from our usual currencies. Cryptocurrency is a purely digital or virtual currency that can also work as a medium of exchange. But, it exists only in digital form and doesn’t have physical coins or banknotes.

Bitcoin is the name of a famous Cryptocurrency.

Unlike traditional currencies, Cryptocurrencies do not have a banking system that records transactions. So how do they work? Cryptocurrencies work on blockchain. Let us learn how.

How Does Cryptocurrency Work on the Blockchain?

In usual currencies, the bank is the figure of authority that allows or disallows a transaction. The given infographic shows how the system works for usual currencies.

Buyer requests a purchase

Seller asks the bank if the Buyer has money in the bank

Bank updates the bank account against the purchase Bank confirms that there is money in the bank

In the case of Cryptocurrencies, there is no centralised banking system. The entire system works on blockchain. A blockchain replaces the role of the bank in this case. This process is modified in the following way:

Buyer requests a purchase

Seller seeks a confirmation from the blockchain if the buyer has sufficient Cryptocurrency

A block containing information on the purchase is added to the blockchain and the buyer’s balance is updated

For normal currencies, the bank, as a financial institution, knows all about every transaction and the account details of every person involved in the transaction. How does it work in case of cryptocurrencies?

Let us look at these points to find out how the blockchain system works for Cryptocurrency.

Confirming the cryptocurrency with the buyer: Since blockchain is a decentralised and transparent system, every piece of information is available for confirmation. Hence, the amount of cryptocurrency that the buyer holds can be double-checked.

Making the purchase safely: A new block is added to the blockchain that contains information about this transaction. The entire blockchain now knows how much currency was spent on this purchase.

Account updation after purchase: Once the buyer has bought an item, this information is added to the blockchain as a new block. This amount is deducted from the buyer’s initial sum of cryptocurrency. This new amount is now available for buying things in the future.

Trusting the information: Since Cryptocurrency is purely digital, it is always possible for the buyer to say that they have more money than what they actually have. How can we make sure, then, that the information is true?

We do not have a bank in the case of Cryptocurrencies, but the information regarding the amount is held within the blockchain. This information has been verified by multiple users and records can be doublechecked at any time and from any place.

Do It Yourself 3B

Match the Following: Term Description Cryptocurrency          Physical coins and banknotes used for buying Bitcoin

Digital currency that works on blockchain Traditional Currency    A famous example of a cryptocurrency

Compare traditional currencies (like INR, USD) with cryptocurrencies (like Bitcoin). List at least two similarities and two differences between them.

Chapter Checkup

A. Fill in the blanks.

The specific unit of data that is part of a blockchain and holds verified information is called a .

The information stored in a is divided into blocks.

Blockchain ensures so that the individual and personal details of participants are secured.

Decentralised means that the control or decision-making is spread out among many different

Cryptocurrency is based on blockchain technology. It is not controlled by any or any government.

B. Tick () the correct options.

Which of the following statements about blockchain is incorrect?

a  Anyone can easily change information in a blockchain.

b  Blockchain uses blocks to store information.

c  The information stored in a blockchain is secure.

d  Blockchain utilises decentralisation and security features to store information.

Which feature of blockchain allows everyone in the network to see the entire history of the data?

a  Security b  Transparency

c  Privacy d  Immutability

In a blockchain, each new block needs to be verified by:

a  the buyer b  every individual on the blockchain

c  the seller d  a portion of blocks

What challenge can arise due to the decentralised nature of blockchains and their potential differences in design?

a  Enhanced communication between blockchains.

b  Simplified data sharing among different blockchains.

c  Improved interoperability between various blockchain networks.

d  Difficulty in communication between different blockchains.

C. Who am I?

I am a digital technology that connects pieces of information in a secure way.

I am a type of currency that exists only in digital form and works on blockchain technology.

While withdrawing regular currency notes, I maintain a record of the transaction.

I am a national currency used to buy things in India.

I am a unit of data in a blockchain that holds specific verified information.

D. Write T for True and F for False.

Decentralised means there is one central authority controlling everything.

Blockchain can be used to create transparent voting systems where every vote is recorded and cannot be altered.

If your school uses a blockchain-based digital identity system for students, you cannot view other students’ personal information.

Cryptocurrencies have a banking system that records transactions, similar to traditional currencies.

In a blockchain network, any user can easily access, change or delete the information stored in a block.

E. Answer the following questions.

What are blockchains? Give an example that can work on a blockchain.

What is a cryptocurrency. Write the name of a famous cryptocurrency. How does blockchain ensure the security and immutability of information?

How does the transparency of a blockchain system help build trust among users?

Briefly state the challenges of blockchains.

F. Apply your learning.

Imagine a school club where everyone gets to make decisions. Name the system which allow everyone to make decision?

Suppose your school library considers using blockchain technology for the process of issuing and returning library books. As a student, what benefits do you think this will have?

Imagine if anyone could change their Cryptocurrency balance to show that they have more money than they actually do. What could go wrong in such a case? How does the blockchain prevent this from happening?

We saw in the chapter how the purchase of artwork could potentially work on a blockchain. How is this different from the usual digital purchases?

Let us Develop Apps! 4

Introduction to Apps

Suppose you are ordering food for dinner tonight. You will fetch your phone, use a food ordering app, and place the order. It is that simple!

Your smartphone must have a variety of apps. Do you ever realise how these apps are created and how they work? Well, you will learn about apps in this chapter.

Apps or Applications are software programs or mobile applications that can be downloaded and installed on electronic devices like smartphones, tablets, and computers. These apps serve various purposes and can be used for playing games, accessing social media, learning, productivity, communication, and many other activities. You are likely to be familiar with popular apps and may use them regularly for entertainment, education, or communication.

In short, an app refers to a program or software application designed to perform specific tasks or functions on a computer, smartphone, tablet, or other kinds of digital devices.

Different Types of Apps

1. Social networking apps: Social networking apps are apps that help people connect and share with others online. They let you make friends, post updates, and chat. Facebook, Instagram, LinkedIn, Snapchat, and X (formerly known as Twitter) are some of the commonly used Social Networking Apps.

Did

The first mobile app store was launched by Apple in July 2008, alongside the release of the iPhone 3G. It was called the “App Store,” and it initially featured 500 apps.
You Know?

2. Productivity apps: Productivity apps are apps that help you get things done and be more organised. Microsoft Word, Google Drive, Snapseed, Analytics, and YT Studio are a few examples of productivity apps.

3. Educational apps: Educational apps are digital apps designed to support learning and education across various subjects and skill levels. They include interactive learning platforms which offer engaging lessons; quiz apps, language learning tools, and educational games for younger learners. These apps enhance learning by providing interactive, accessible, and flexible educational experiences.

4. Gaming apps: Gaming apps are apps where you can play fun games. These apps provide entertainment and challenges, allowing you to explore virtual worlds, solve puzzles, or compete with others. Temple Run, Angry Bird, Sportify, MineCraft, and Fruit Ninja are a few examples of gaming apps.

5. Food delivery and cooking apps: Food and cooking apps are apps that help you discover recipes, cook delicious meals, learn about food, and order food. Zomato, Swiggy, DoorDash, Insta Mart, and Zepto are few examples of food delivery and cooking apps.

Accessing Apps

You can access apps from your mobile phone, desktop, or directly from the web. Let us learn all these methods to access the apps.

Think and Tell

What are the most popular apps according to you?

Logo

Desktop Apps

Desktop apps are like the computer version of the apps you use on your phone, but they are designed to work on your computer and do all sorts of different things, from writing documents to playing games or editing pictures.

Desktop apps are software applications that you can use on your computer or a laptop where they are installed and run locally. Desktop applications do not require an internet connection to run. For example, Microsoft Word is a desktop app that helps you write essays and stories on your computer. There are also games like Minecraft that you can play on your computer. Skype, Microsoft Power Point, Paint, Microsoft Excel, and iTunes are a few examples of desktop apps.

Web Apps

A web app is a software application that operates on web servers and is accessed by users through web browsers over the internet.

Web apps, short for web applications, are software applications that run on web servers and are accessed through web browsers over the internet. These applications provide a user interface and functionality similar to traditional desktop applications but are designed to be used within a web browser. Since web apps are hosted on web servers, users can access them from anywhere, using various devices, without the need for installation. This ease of accessibility is a significant advantage for both users and developers. Web apps can be accessed from any device with a web browser and an internet connection. They are not tied to a specific operating system, making them platform-independent. Padlet, YouTube, Gmail, and Google Drive are a few examples of web apps.

Discuss!

Why do you think apps were invented? How do they make our lives easy?

Mobile Apps

Mobile apps are programs you install on your phone to make it more fun or helpful for whatever you want to do.

A mobile app is a tiny computer program that you can download and used on your smartphone or tablet. It makes your phone do fun or useful things beyond making calls or sending texts. Mobile apps can be games you play, tools that help with homework, maps that show you where to go, or even things like filters that make your photos look improved. Mobile apps can be downloaded from the app stores available on your mobile. An app store can host large numbers of mobile apps. You can check the various features of the app you want to download and compare it with other related mobile apps available on the app store. Instagram, Camera, Telegram, iMusic, and Google Maps are a few examples of mobile apps.

Explore More!

To know more about web apps, scan this code.

Do It Yourself 4A

1 Match the different types of apps with their suitable examples:

Types of App Example

2 Fill

a and are social media apps.

b Apps can be and installed on electronic devices.

c run on web servers and are accessed through web browsers over the internet.

d You can download a mobile app from available on your phone.

Classification of Mobile Apps

Apps can be classified based on the technology used to create them, and their usage.

Based on How They Are Created

There are two types of apps based on how they are made. They are:

Native Apps

Native apps are specifically designed for a particular type of phone, such as iPhones or Android phones. They are known for their high speed and excellent performance because they are designed exclusively for your phone. Examples of native apps include Camera, Gallery, Clock, Maps, and Settings.

Did You Know?

Native apps can sometimes be used even without an internet connection! That is because they are installed directly on your device, and many of them store information on your phone. It is like having a little piece of the internet right on your device!

Hybrid Apps

Hybrid apps can work on different types of phones and use web technologies, allowing them to work on multiple platforms and access device features. They are compatible with both iPhones and Android phones and can be downloaded and installed from their respective app stores, such as the Google Play Store for Android phones and iTunes for iPhones. Although they may not match the speed and smoothness of native apps, they offer versatility by running on a wide range of smartphones. Examples of hybrid apps include Uber, Zomato, Instagram, Telegram, and X (formerly known as Twitter).

Difference Between Native Apps and Hybrid Apps

Native Apps

Native apps are built specifically for one type of mobile operating system, such as iOS (for Apple devices) or Android (for Android devices).

Hybrid Apps

Hybrid apps are developed using web technologies like HTML, CSS, and JavaScript and can run on multiple platforms (iOS, Android, etc.) with some modifications. They typically offer the best performance and responsiveness because they are optimised for the particular device and its features.

Native apps have complete access to device features, like the camera, GPS, and sensors, allowing them to take full advantage of these capabilities.

They are distributed through platform-specific app stores like the Apple App Store and Google Play Store.

Based on Usage

There are many apps based on their usage. They are:

Educational Apps

Hybrid apps might not feel as fast or quick as regular apps because they use a part that is like a web browser to show things, and that can be a bit slow.

Hybrid apps can access device features to some extent using plugins, but not as exclusively as native apps.

Hybrid apps can be distributed through web browsers as web applications. They can also be distributed through app stores.

Educational apps are software applications designed to facilitate learning and provide educational content on various subjects and skills. These apps are developed to make learning more engaging, interactive, and accessible for users of all ages, from children to adults.

Discuss!

How can we get hybrid apps onto our phones? Is it similar to how we get native apps?

Social Networking Apps

Social networking apps are like virtual platforms where you can meet and talk to your friends and even make new ones. They are special apps on your phone or computer that help you connect with people, share things about your life, and see what your friends are up to.

Did You Know?

Did you know that the "Like" button on Facebook was originally going to be called the "Awesome" button? Facebook's founder, Mark Zuckerberg, considered different names for it before settling on "Like". So, every time you click "Like" on a post, you are giving it a little touch of awesomeness!

Entertainment Apps

Entertainment apps are online portals for having fun and enjoyment on your phone or tablet. They are special apps that offer all sorts of things to make you happy and have a great time.

Banking Apps

Banking apps are like a virtual bank branch on your phone or tablet. They are the special apps provided by your bank to help you do immediate money transactions without going to the bank in person.

you shop for all sorts of things without having to

Name four native apps and four hybrid apps. Which one between the two categories do you use the most?

Who am I?

a These apps can help users develop a wide range of skills, including reading, writing, maths, and problem-solving.

b These apps are like virtual platforms where you can meet and talk to your friends.

c These apps provide you with help when you do important financial transactions.

d These apps let you shop for all sorts of things without having to go to a physical store.

e These apps are the portals for fun and enjoyment on your phone or tablet.

Developing an App

MIT App Inventor is a visual development platform that allows users to create mobile applications for Android devices without the need to write traditional codes. It is designed to make app development more accessible to a wide range of people, including those who do not have extensive programming experience. MIT App Inventor provides a visual, drag-and-drop interface for designing the user interface and functionality. Users can assemble components and connect blocks to create the app’s logic.

Let us create a simple app using MIT App Inventor.

Idea of the App

The name of this app will be Magic_Button.

The app will have the following components:

1. A button

2. An image (Download any image from the internet and save it on your computer for later use.)

These two components will be added to the app design. Initially, the image will not be visible. The idea is to display the image only after the user clicks on the button. Let us design the app now.

Creating an App

 Visit the following link to open MIT App Inventor: https://appinventor.mit.edu/

 The given screen appears:

 Click on the Create Apps! Button.

 A sign-in screen appears. You can use your Gmail ID to login, or you can create a new one as well.

 After signing in, the Welcome to MIT App Inventor pop-up box appears. Click on the Continue button at the bottom of the screen.

 Another screen appears, from which you can choose to view the tutorials or start a new blank project.

 Click on START A BLANK PROJECT.

Continue Button

 The Project View window appears.

Click here to start a blank project

 A dialog box appears, asking you to give a project name to your project.

 Give an appropriate name to your project, for example, Magic_Button and click on OK.

 A new project with the same name will be created.

 The Project View window will open.

Sections of the Project View Window

The Project View window is divided into four sections:

Palette: Various components are presented under different categories in the palette.

Viewer: You can select any component from the palette and drag and drop it onto the screen in the Viewer section.

Components: The Components section shows the various components that are placed in the Viewer.

Properties: The Properties section shows the properties of the selected components.

Working With the Palette Section

Let us now create the interface of the app.

 From the Palette section, click on the Layout tab.

 Drag the VerticalArrangement component and place it on the screen in the Viewer section.

 Now, click on the VericleArrangement1 component in the Components section and go to the Properties section.

 Scroll down to the Height property and click on it.

 Select the Fill parent option and click on OK

 Similarly, select the same option for the Width property. The VerticalArrangement component will fill the whole screen.

 Now, from the User Interface tab, drag the Button component and drop it on the screen.

 You can also observe that the Button1 component is added under the Components section.

Setting the Properties of the Button

 Now in the Properties section, scroll down to the Text property of the button. Replace the text “Text for Button1” with “Magic_Button”.

 From the Palette section, drag the Button component and place it in the Viewer section on Screen1

 Now, change some more properties of the button in a similar way from the Properties section:

o Font Size: 20

o Background Colour: Cyan

o Text Colour: Blue

o Shape: Rounded

o Height: 10 percent

o Width: Fill parent

 Now, drag an Image component from the User Interface section and place it on the screen.

 From the Components section, select Image1 and click on the Picture option in the Properties section. A drop-down will appear. Click on the Upload File option.

 The Upload File dialog box will open. Click on the Choose File button.

 An Open dialog box appears. Select the picture that you have downloaded from the internet and click on Open.

 The image will appear on the screen.

Setting the Properties of an Image

 You can now set the properties of the image.

o Height: Fit to parent

o Width: Fit to parent

o Visible: Uncheck (to hide the image initially)

After setting all the properties of both objects, the screen will look as shown here:

Creating Code for the App

After that, you have arranged your components on the screen. Let us now create the code for the app.

Coding in MIT App Inventor is very easy and user-friendly. You can create code for your app by using various blocks present in the Blocks Editor.

To create code for your app, follow the given steps:

 Click on the Blocks Editor button on the right-hand upper corner of the Project View window.

 The Blocks Editor will open with the Blocks section on the left and the Viewer section on the right.

 Click on Screen1 > Button1 from the Blocks pane.

 The blocks related to Button1 will appear.

 Drag when Button1.Click block from the Blocks drawer and drop it in the Viewer pane.

 Now, click on the Image1 component in the Blocks panel. The blocks related to the image are displayed.

 Drag set Image1.Visible to block and drop it inside the when Button1.click block.

 Now, from the Built-in > Logic drawer, drag the true block and snap it together with the set Image1. Visible to block.

 The code for your app is complete.

 Now, when you click on the Magic_Button on your mobile app, you will see a picture of a flower.

Testing the App

 To test your app, you will need a mobile phone.

 Go to the Google Play Store of your android phone and search MIT AI2 Companion App.

 Install the app by clicking on “Install”.

 After installation, open the app. You have to provide a six-character code to connect.

 Now, to get the code, go to your computer where you have created your app.

 Go to the Connect menu and select the AI Companion option.

 A Connect to Companion window will open with a six-character code.

 You can now fill in this six-character code on the mobile phone app.

 The app will now open on your mobile.

 Click on the button that you have created, which is the Magic_Button.

 You will be able to see an image of the flower.

Create an app on MIT App Inventor to show your name when you click on a button. Do It Yourself 4C

Chapter Checkup

A. Fill in the blanks.

An is a computer program that you can download and use on your smartphone or tablet. are special apps that let you shop for all sorts of things without having to go to a physical store. apps are developed using web technologies like HTML, CSS, and JavaScript and can run on multiple platforms.

In MIT App Inventor, various components are present under different categories in apps are apps that help people connect and share with others online.

B. Who am I?

I am like a virtual bank branch on your phone or tablet.

I can assist you to design and make the app of your dreams.

I am a computer program that you can download and use on your smartphone.

I can show the properties of the selected components.

I am a type of app that can work on different types of phones, like both iPhones and Android phones.

C. Write T for True and F for False.

Apps are software programs that can be installed on your desktop.

There are two types of apps: hybrid and native.

Web apps do not operate on web servers and are not accessed by users through web browsers. Native Apps provide the best performance as they are optimised for the particular device.

Components

D. Answer the following questions.

What are banking apps?

What are hybrid apps? How are they useful?

How are desktop apps different from web apps?

What are Native Apps? Give examples.

is MIT App Inventor?

E. Apply your learning. HOTS

Ramesh wants to learn how to design an app on MIT App Inventor. Which website should he visit?

Tia wants to understand the e-commerce apps and know a few examples. Can you explain it to her?

Umang wants to download a specific app for his iPhone. Where can he get the app?

Geet is using her computer and wants to learn about web apps. Can you help her understand about them?

Meher has installed an app on her phone that was not a pre-loaded app. What type of app has she downloaded?

Introduction to Database Management System 5

Understanding Databases

When you visit your school library, you can observe that the books are organised in a very systematic manner. You go to the particular bookshelf and fetch the book that you need. Then you ask the librarian to issue it to you. How do you think these books are organised in such a manner?

Yes, they have been given a unique number, and then they are arranged according to their genre, author, date of publication, etc.

Now, think of the same data being organised on a computer. This data can be maintained on a computer, also known as a database.

When we maintain data in an organised and structured manner in digital form on a computer, it is called a database. It is a group of related facts organised together so that they can be accessed, controlled, and modified. It is an organised method of saving and finding information.

A database is a collection of tables, where each table consists of rows and columns. Each row represents a single record, and each column denotes a single piece of information surrounding that record.

Structure of a Table

Think and Tell

Where have you seen the use of a database in your daily life?

A table is a grid-like structure consisting of rows and columns. In a database, the columns are referred to as fields and the rows are referred to as records.

Field: It is the title at the top of each column, describing what kind of data is in the column. It is also referred to as an attribute.

Record: It is a row in the table, containing all the information for one entry.

Student_NameLocation Phone Number Date of Birth

ShreyaDelhi998877665512-03-2010

Asmi Noida334455667723-09-2011 Aarna Gurgaon786756453404-04-2011

Fields Records

In the above table, Student_Name, Location, Phone Number, and Date of Birth are the fields in the table and [Shreya, Delhi, 9988776655, 12-03-2010], [Asmi, Noida, 3344556677, 23-09-2011], [Aarna, Gurgaon, 7867564534, 04-04-2011] are the three records in the table.

Databases are used to store several types of information, such as customer records, product data, and medical records. They are used by almost all organisations, governments, and businesses to keep their records in a systematic manner.

Did You Know?

In the 1960s, the first databases emerged with hierarchical models. Relational databases, introduced in the 1970s by E.F. Codd, revolutionised data management, leading to modern database systems.

Advantages of Database

Here are some of the advantages of using a database:

 It can carry vast quantities of data.

 It can organise data in a manner that makes it easier to retrieve.

 It can be used to modify and erase data rapidly.

 It can be used to share data with others.

Discuss!

Is it important for data to be organised?

Database Management System

A database management system (DBMS) is a software application that enables you to construct, operate, and interact with databases. Some common examples of DBMS are MySQL, Microsoft SQL Server, and Oracle.

Role of DBMS

Here are some of the key roles or functions of a DBMS:

Storing Data: A DBMS can retain a huge amount of data in an organised form. This makes it easy and simple to access and recover the data when necessary.

Managing Data: A DBMS can manage the data in a database, such as adding, removing, modifying, and restoring data. It may also help to ensure that the data is genuine and consistent.

Protecting Data: A DBMS can protect the data in a database from unauthorised entry, change, or loss. It can do this by applying security measures such as user login and encryption.

Querying Data: You can access a specified piece of information from the database by making use of queries. This means that users may ask questions about the data, and the DBMS will deliver the results of the query.

Did You Know?

A database is a structured data storage system used to store, organise, and retrieve information. It has evolved from manual systems to digital databases, playing a crucial role in modern data management.

Types of DBMS

Here are the various types of DBMS systems:

Hierarchical Database Management System (HDBMS) keeps data in a tree-like structure. Each record may have one or more child records, and each child record might have one or more grandchild records. HDBMS are well-suited for maintaining data that has a natural order, such as the structure of a corporation or the arrangement of plants and animals. Some examples of HDBMSs include IBM’s Information Management System (IMS) and the Integrated Data Store (IDS).

Relational Database Management System (RDBMS) are the most commonly used type of DBMS. They hold data in the form of tables, which are made up of rows and columns. Each row represents a record, and each column indicates a field. RDBMS are highly efficient in preserving and locating data, and they are also quite adaptable. Some notable RDBMSs include MySQL, Oracle, and Microsoft SQL Server.

Object-Oriented Database Management System (OODBMS) stores data in the form of objects. Objects are like records, but they may also have methods, which are like functions. OODBMS is well-suited for keeping complicated data, such as data that is tied to things in the real world.

Network Database Management System (NDBMS) stores data in a network-like structure. Each record may have one or more parent records, and each parent record might have one or more child records. NDBMS are well-suited for maintaining data that involves a complicated connection between records, such as airline routes between cities.

Think and Tell

Do you think that a person with special knowledge of databases is required to handle it?

Components of a DBMS

Database Management System consists of six main components.

These are:

• Data

• Hardware

• Software

• Users

• Procedures

• Database Access Language

Access Language

Data: This is the most significant component of a database. It is a collection of fundamental facts and figures that are recorded in the database.

Hardware: The hardware consists of the real computers that store and manage data in the database. This includes the computer, the hard disk drive, and the RAM.

Software: The software is the tool that operates the information. It is responsible for storing, obtaining, and managing data. The most common database application is termed a database management system (DBMS).

Users: The users are the individuals who connect with the database. They might be end-users who use the database to see data or database managers who operate the database.

Procedures: A procedure is a form of general instructions or guidelines for using a DBMS. These instructions include how to set up the database, install it, log in and out, manage it, create a backup, and generate reports from the database.

Database Access Language: Database Access Language is a language that allows users to give commands to a database to operate the data stored. You can use this language to ask the database to do many things, such as getting data, modifying it, or removing it.

Did You Know?

Your favourite streaming service, like Netflix, uses big data and databases to recommend movies and shows to you.

Answer the following questions.

the components of a DBMS.

Structured Query Language

SQL, or Structured Query Language, is a powerful tool used for managing and manipulating data in databases. SQL provides a way to communicate with and manipulate databases through the following main operations:

• Data Querying: Allows users to retrieve specific data from databases.

• Data Manipulation: Includes commands to insert, update, and delete data.

• Data Definition: Enables users to define and modify the structure of the database objects, such as creating, altering, and dropping tables.

Types of SQL Statements

SQL statements are classified into the following two categories:

Data Definition Language (DDL): The SQL statements or commands that are used to create or delete tables are called DDL commands. These are necessary for creating, altering, and deleting the table. For example, create database, create table, add, modify, drop, etc.

Data Manipulation Language (DML): The SQL statements or commands that are used to insert, delete, or update data in the table of the database are called DML commands. For example, insert, delete, update, etc.

Basic SQL Queries

In the previous class, you learnt about creating tables, inserting data, and using the SELECT command with the WHERE clause. In this chapter, you will be introduced to more advanced SQL commands and concepts. Before learning about SQL queries, let us first quickly learn about the various data types and keys used in SQL.

Data Types in SQL

There are the following main data types used in SQL:

Data Type Description

Number Numeric data types are used to store a numeric value in a field column. It may be decimal, integer or real value.

Character (Fixed Length) This data type is used to store fixed-length character strings. If the string is shorter than the specified length, it is padded with spaces.

Varchar (Variable Length) It is used to store variable length alphanumeric data.

NUMBER(n, d) where n specifies the number of digits and d specifies the number of digits to right of the decimal point.

CHAR(size) where size represents the maximum (255 Characters) number of characters in a column.

VARCHAR(size) / VARCHAR2(size) where size represents the maximum (2000 characters) number of characters in a column.

Roll_number int (2)

Salary int (6, 2)

Name char(20)

Address Varchar(50)

Date It is used to store date in columns. The standard date format is YYYY-MM-DD.

Time It is used to store time in columns. The standard time format is hh:mm:ss.

Date

dob Date

Time joining_time Time

Keys in Database

Keys in a database are used to define any constraints on the table. We know a database can have multiple tables. Keys are also used to establish and identify relationships between tables. There are many keys that can be defined for a table. A table can have multiple keys also.

Key Description

Primary Key The primary key is the attribute or set of attributes in a table that uniquely identifies a row in that table. There should be only one primary key in a table.

Candidate KeyThere might be multiple attributes that can uniquely identify a row in a table. Candidate key is the attribute that uniquely identifies a row in the table, but is not considered as the primary key.

Composite KeyWhen a primary key consists of more than one attribute, it is called a composite key.

Foreign key Foreign keys help us to establish a relationship between multiple tables in a database.

Revising SQL Queries

Let us now revise some of the basic SQL commands that you have learnt in the previous grade.

Create Table:

The Create Table command is used for creating tables.

Syntax

Create Table table_name (

column_name_1 data_type_1,  column_name_2 data_type_2,

column_name_n data_type_n );

Example

CREATE TABLE Students (

Student_ID VARCHAR(6),  Student_Name VARCHAR(50),  Grade INT,  Section CHAR(1),  Roll_Number INT,  Library_ID VARCHAR(7),  House_ID VARCHAR(4),  Enrollment_Date DATE );

Create Table Command with Primary Key

The Create Table command is used to create a new table in a database. When defining a table, you can set a primary key to ensure each record is unique.

Syntax Example

Create Table table_name (

column_name_1 data_type_1 PRIMARY KEY,  column_name_2 data_type_2,

………

column_name_n data_type_n );

CREATE TABLE Students (  Student_ID VARCHAR(6) PRIMARY KEY,  Student_Name VARCHAR(50),  Grade INT,  Section CHAR(1),  Roll_Number INT,  Library_ID VARCHAR(7),  House_ID VARCHAR(4),  Enrollment_Date DATE );

Insert Command

Insert table command is used to insert values in the created table.

Syntax

INSERT INTO table_name (column1, column2, ...) VALUES (value1, value2, ...);

Select Statement

Example

INSERT INTO Students (Student_ID, Student_Name, Grade, Section, Roll_Number, Library_ID, House_ID) VALUES (‘STU001’, ‘Riya Das’, 7, ‘A’, 23, ‘LIB007’, ‘H001’, ‘24-07-2024’);

The SELECT statement is used to query the database and retrieve specific data.

Syntax

SELECT column1, column2, ... FROM table_name WHERE condition;

Examples

Output

SELECT * FROM Students;Gives all the records entered in the table

SELECT Student_Name, Grade FROM Students; Gives only two columns Student_ Name and Grade

SELECT * FROM Students WHERE Grade = 7; Gives all the records of the students who study in grade 7.

Let us now learn about some more SQL queries.

Using the SELECT Statement with Additional Clauses

You have seen that we can use the SELECT statement with WHERE clause. There are some more clauses which can be used with the SELECT statement. Let us learn about them.

Order By Clause

The Order By clause allows us to sort the results in ascending or descending order. For example, To list students by age in ascending order:

SELECT * FROM Students ORDER BY Age;

To sort by age in descending order, use DESC:

SELECT * FROM Students ORDER BY Age DESC;

Distinct Clause

The Distinct keyword helps eliminate duplicate values. For example, to list unique cities where students live:

SELECT DISTINCT City FROM Students;

Updating Data in a Table

The Update command modifies existing records. To update the address of a student:

UPDATE Students

SET Address = ‘1010 Elm Street’

WHERE StudentID = 1;

Deleting Data from a Table

The Delete command removes records from a table. To delete a student from the database:

DELETE FROM Students WHERE StudentID = 3;

Using Aggregate Functions

Aggregate functions perform calculations on a set of values and return a single value. Common aggregate functions include:

• COUNT(): Returns the number of rows.

Example: Count the number of students in each grade level:

SELECT Grade, COUNT(*) FROM Students

GROUP BY Grade;

• SUM(): Returns the sum of a numeric column.

Example:

SELECT SUM(salary) FROM Employees;

• AVG(): Returns the average value of a numeric column.

Example:

SELECT AVG(price) FROM Products;

• MAX(): Returns the maximum value.

Example:

SELECT MAX(age) FROM Employees;

• MIN(): Returns the minimum value.

Example:

SELECT MIN(quantity) FROM Orders;

Searching Data

To search for specific data in a MySQL database, you can use SQL queries by specifying some conditions.

Using the Where Clause:

The where clause is used to filter the rows returned by a query based on specified conditions.

Syntax:

select * from table_name where condition;

Example:

select Student_Name from Student where Gender = ’F’;

This SQL statement retrieves the Student_Name of the girl students.

Using the Wildcard Operators

Output

Wildcard operators in SQL are special characters for pattern matching in text data. They help in finding data that matches a pattern, not just an exact value. They are used with the 'like' clause in an SQL query. Two main wildcard characters used in SQL are '%' (matches multiple characters) and '_' (matches a single character). Let us look at their usage.

Using '%' Character: The percent sign (%) represents zero, one, or multiple characters.

Syntax:

select column_name from table_name where column_name like '%pattern';

Diksha
Payal
Shreya

Example:

select Student_Name from Student where Student_Name like '%s%';

Using '_' Character: The underscore (_) represents a single character.

Syntax:

select column_name from table_name where column_name like 'pattern_pattern';

Example:

select Student_Name from Student where Student_Name like 'P_yal';

Do It Yourself 5B

Match the following.

Create Descending order

Distinct Filter rows

Where Create a new table

Desc Eliminates duplicate values

Chapter Checkup

Which of the following is an example of RDBMS?

a  IDS

c  Oracle

Which of the following is NOT a component of DBMS?

b  IMS

d  None of these

a  Users b  Data

c  Hardware d  Network

What is a record in a database?

a  A collection of data

c  A row in a database table

b  A collection of books

d  A column of information

What is a primary key called when it consists of more than one attribute?

a  Primary key

c  Foreign key

C. Who am I?

b  Composite key

d  Candidate key

B

Wildcard operator A column in a database table

DBMS Relational, hierarchical, and network 3  Different types of DBMS A software application that helps users create, manage, and access databases

4  Components of a DBMS A special character for pattern matching in text data

5  Attribute

D. Write T for True or F for False.

Data, hardware, software, users, procedures, and database access language

A database is a collection of data organised in a way that makes it easy to retrieve, manage, and update.

In a database, information is stored in tables, which are made up of rows and columns.

The where clause is used to filter the rows returned by a query based on specified conditions.

Databases are only used by businesses and organisations; they have no relevance in our everyday lives.

Consider

Insert two more rows in the table.

Video Editing in Canva 6

Video editing is the process of arranging and modifying video clips to create a video project. It involves cutting, adding, and enhancing clips to make the video more interesting and effective. Video editing is used to create presentations and reports in schools and offices, producing stories for series and movies and to create content for social media platforms.

Creating a Video in Canva

Let us start a video project from scratch.

Follow the given steps to create a blank video in Canva:

1. Log in to www.canva.com and create an account if you do not have one.

2. Click on the Create a design button on the home page.

3. A drop-down list of options will appear.

4. Click on the Video option.

Did You Know?

You can also click on the Video icon on the home page and select from the various options.

Let us discuss the various components of Canva window as marked in the above image.

1. Canvas: The canvas is your workspace, where you build and design your video. Here you can add and arrange all the elements of your video project, including text, images, videos, and audio.

2. Timeline: The timeline is a critical component that allows you to control the timing of your video. You can arrange elements on the timeline to determine when they appear and for how long. It helps you arrange objects like text, images, and videos in the desired sequence.

3. Zoom controls: Canva offers zoom controls that allow you to zoom in and out of your canvas. This feature helps you focus on specific details while working on your video.

4. Grid view: Grid view provides an overview of all the pages in your video project, helping you visualise the structure and flow of your video. It is a useful tool for organising your content effectively.

5. Preview: The Preview option allows you to see how your video will appear to your audience. It is a valuable tool for reviewing your video before finalising it, ensuring everything looks and sounds right.

6. Elements: The Elements option offers a wide range of design elements, including photos, videos, stickers, shapes, and icons. You can search and browse for elements to enhance the visual appeal of your video project.

7. Text tool: Text tool enables you to add text to your video. You can choose from various fonts, colours, sizes, and styles to customise your text elements. This is essential for creating titles, captions, and onscreen messages.

8. Uploads: This feature allows you to upload your own media files, such as images, videos, and audio clips, to incorporate them into your video project. It is a way to personalise your content and add unique elements.

9. Draw: You can draw any shape in your video by using the tools present under this drawer.

10. Projects: You can view all your projects that you have created up to now under this option. You can select any one of them to work upon.

11. Notes: You can add notes to your project to keep track of ideas, reminders, or specific instructions. Notes are useful for collaborating with others on your video project.

12. Canva assistant: This is a artificial intelligence tool that helps you with your queries during the project. You can ask any query by clicking on the Canva Assistant button. You can use Canva’s Timeline feature to precisely control when each video element appears and disappears.

Did You Know?

Do It Yourself 6A

Match the features with its correct descriptions.

Canvas Lets you zoom in and out of your canvas to focus on details.

Timeline Enables you to add and customize text in your video.

Zoom Controls Your workspace where you build and design your video.

Preview Helps you control the timing of your video by arranging when elements appear.

Text Tool Lets you see how your video will appear to your audience before finalizing it.

Adding Videos in Canva

You can add videos to your project using various options. Let us discuss them one by one.

Using Uploads Option

You can upload your videos to Canva and add them to your project. Follow the given steps to add video from your device.

1. Click on the Uploads option in the side bar.

2. Click on Upload files and select the video files from your device. Wait for the upload to complete.

3. Drag and drop the uploaded video onto the timeline.

Using Canva’s Video Library

Follow the given steps to add videos to your video project in Canva:

1. Click on the Elements option in the side bar.

2. Type keywords related to the type of video you need in the Search bar (e.g., ‘nature,’ ‘city,’ ‘people’).

3. Go to Videos section, click on the video you want and drag it to the timeline.

4. You can resize it from the ends of the video to fit it according to the dimensions.

5. You can also add a new page and then add the video to that page.

Basic Video Editing Tools

Let us discuss some basic video editing tools.

Trimming and Splitting Videos

To trim and split your videos, follow these steps:

1. Click on the video in the timeline to select it.

2. Hover over the beginning or end of the video clip and drag the edge to trim the video to the desired length.

3. Move the playhead (the vertical line) to the point where you want to split the video. Click on the Split button that appears above the timeline.

Resizing and Cropping Videos

To resize or crop your video, follow the given steps:

1. Click on the video in the timeline.

2. Drag the corners of the video to resize it.

3. Crop the video by clicking on the Crop button above the canvas. Drag the edges of the video to crop it to the desired size. Click Done when finished.

Adding and Editing Audio

You can add music or sound effects to your video:

1. Click on the Element option in the side bar and go to Audio section.

2. Type keywords in the Search bar to find the type of music or sound effect you want.

3. Click on the audio track and drag it to the audio timeline.

4. Click on the audio track in the timeline to adjust the volume or trim the audio.

Applying Effects on Videos

You can enhance your video in Canva using the following effects.

Applying Filters and Effects

Follow the given steps to apply filters and effects in your video:

1. Click on the video in the timeline.

2. Click on the Edit video button above the canvas.

3. In the tools tab, go to the Filters section. Select the filter of your choice.

4. Use the slider to adjust the intensity of the filter.

Adding Text and Graphics

You can add text and graphics to your video by following the given steps:

1. Click on the Text option in the side bar.

2. Select a text style and click on it to add it to the canvas.

3. Double-click on the text box to edit the text. Change the font, size, colour, and position as needed.

4. Click on the Elements option in the side bar. Search for graphics or stickers and drag them onto the canvas.

Using Animation

You can make your video more dynamic by adding animations to it. Follow the given steps:

1. Click on the text or graphic you want to animate.

2. Click on the Animate button present above the canvas.

3. Select an animation style from the options.

4. Customise the animation duration and delay if needed.

5. Your video is ready. Click on the Play button to watch your video.

Downloading and Sharing a Video

Downloading lets you save your video, while sharing helps you show it to others or collaborate on it.

Download Your Video

Follow these steps to export your finished video:

1. In the top right corner, click on the Share button.

2. Select Download from the dropdown menu.

3. Choose the video format (MP4 is recommended).

4. Wait for the video to process and download to your device.

Sharing Your Video

Now that your video is ready, you can share it with others by following the given steps:

1. In the top right corner, click on the Share button.

2. Set the sharing options, like who can see your video and if they can edit it.

3. Click on Copy link to get a shareable link or choose how you want to share it, like through email or social media.

Think and Tell

Have you ever used the Preview option in any application before finalizing your video?

1 Fill in the Blanks.

a To upload a video, click on tab in the side bar.

b Drag the video to the after uploading.

c Find videos by clicking on and using the Search bar.

d Trim a video by dragging the or .

e To share your video, click on the button in the top right corner.

2 Solve the following crossword using the given hints.

Across

1. The button you click to adjust the visual appearance of your video with different styles.

4. A tool used to cut a video into segments.

6. The button you click to start watching your edited video.

Down

2. To change the size of a video.

3. The section where you upload your own video files

5. The format recommended for downloading videos.

Chapter Checkup

A. Fill in the blanks. Hints

Create a design   Preview   Canvas   Uploads   trim   split

1 The option in Canva lets you upload your own videos, images, and audio files.

2 To start a video project in Canva, you first click on the button on the home page.

3 The feature helps you see how your video will look before finalizing it.

4 You can and your videos using basic editing tools in Canva.

5 The is your workspace where you build and design your video in Canva.

B. Tick () the correct option.

1 What does the Timeline in Canva allow you to control?

a  The colour of the text b  The timing of video elements

c  The size of the canvas d  The type of filters used

2 Which option in Canva helps you add animations to your video?

a  Uploads b  Elements

c  Animate d  Text

3 What file format is recommended when downloading your video from Canva?

a  JPG b  MP4

c  PNG d  GIF

4 To add your own video file to a project in Canva, which option should you use?

a  Elements b  Uploads

c  Video Library d  Timeline

5 What feature helps you focus on specific details of your video while editing?

a  Zoom controls b  Filter options

c  Canvas d  Grid view

C. Who am I?

1 I help you organize the timing of your video elements in Canva.

2 I am the workspace where you build and design your video.

3 I help you add motion to text and graphics in your video.

4 I let you see an overview of all the pages in your video project.

5 I offer a variety of design elements like stickers, shapes, and icons to enhance your video project.

D. Write T for True and F for False.

1 The Timeline in Canva allows you to control when elements appear in your video.

2 The Elements option in Canva is used to add text to your video.

3 You cannot resize or crop videos in Canva.

4 Canva’s Video Library offers a wide range of pre-existing video clips.

5 You can download your finished video directly from Canva.

E. Answer the following questions.

1 What do you mean by video editing?

2 How does the timeline help you control the timing of your video?

3 Write the names of basic video editing tools.

4 Why is the Preview option important in Canva?

5 How can you add text to your video?

F. Apply your learning.

1 Neha is enhancing her Canva video by adding photos. What are the steps she should follow to resize the video clips effectively?

2 Kavita wants to add background music to her Canva video. Where can she find the audio option to do so?

3 Rahul wants to add captions to his Canva video. Which option should he use to add text?

4 Ravi needs to ensure that his video elements appear at the right times. What tool in Canva will help him manage the timing of these elements?

5 Arjun is an artist. He wants to create a drawing using his imagination. Which option can he use to do so?

Fundamentals of Python 7

Introduction to Python

Python is a dynamic programming language that is high-level, interpreted, and focused on code readability

Guido van Rossum, a developer, released it in 1991. Python is one of the world’s most popular and fastest-growing programming languages. It is a sophisticated, adaptable, and user-friendly programming language. It is widely used in many organisations since it supports a variety of programming paradigms. It also manages memory automatically.

Features of Python Language

Following are the features of Python language:

• Free and Open Source: Python is free and open-source software, which means you can download, use, and distribute it without cost.

• High-level Language: Python is a high-level programming language.

• Interpreted: Python is an interpreted language. Unlike C and C++, there are no distinct compilation and execution steps. It can run the application directly from the source code.

• Simple and Easy to Learn: Python is a very simple and easy language, which makes it a popular choice for both students and experienced programmers.

• Platform Independent: Python can be used on a variety of operating systems, including Linux, Windows, Macintosh, Solaris, and others.

• Dynamic Typing: Python defines data types dynamically for the objects according to the value assigned. Also, it supports dynamic data types.

Python Syntax

The rules that define the structure of a language are referred to as syntax.

• Like other programming languages, Python also has symbols, punctuation, and words.

• Python is case-sensitive. This means that ‘nUm,’ ‘Num,’ and ‘num’ are all considered different things in Python.

• Python follows indentation. The spaces at the beginning of a code line are referred to as indentation. Whereas indentation in code is just for readability in other programming languages, it is crucial in Python.

Python Data Types

The type of a variable is specified using Python data types.

The data type specifies the kind of information that will be stored in a variable.

Different kinds of data can be stored in memory. For instance, a person’s address is stored as a string of alphanumeric letters, and his age is stored as a numeric value.

Let us have a look at the various data types available in Python: Data

Int

This data type is used for storing integers (whole numbers), both positive and negative.

Float The float data type is used to store positive and negative numbers with a decimal point.

Strings Python Strings are identified as a contiguous set of characters represented in quotation marks. It can be used to store text-based (collection of letters, words, and sentences) information. Python allows pairs of either single or double quotes.

List A list is an orderly grouping of items. It can include a variety of items, such as numbers, words, or even additional lists. Items in a list are enclosed in square brackets.

Tuple A tuple is similar to a list in which its elements cannot be modified once specified. It is like a predetermined list of items. Items of tuple are enclosed in parentheses.

Dictionary A dictionary is a collection of key-value pairs that are not ordered. It can be used to store and retrieve data, using particular keys. A dictionary functions as a book of definitions. Words serve as keys, and their definitions serve as values. Every word conveys a distinct meaning.

Dictionaries are enclosed by curly braces { } and the individual keys are separated from their values by colons.

Boolean A Boolean is a built-in data type that represents one of two values: True or False.

Boolean data type is often used for making decisions and controlling the flow of a program.

Set A set is an unordered collection of unique elements. It is a data type that allows for the storage of many values while automatically removing duplicates.

Variables

var1 = 5

var2 = –15

b=50.45

name="Anita"

str1 = 'Hello World!'

list = ['Steve', 589, 5.56, 'Elon', 150.2]

tuple = ('Steve', 589, 5.56, 'Elon', 150.2)

Animals = {"lion": "Lions are known as the kings of the jungle", "elephant": "Elephants have a great memory"}

x = True # display the value of x

y = False # display the value of y

favourite_fruit = {"Mango", "Peach", "Kiwi"}

If we need to store something in real life, we need a container or box to do so. The variables in Python represent containers for storing data of various types, such as int, float, string, Boolean, list, tuple, etc.

The reserved memory areas used to hold values in a Python program are known as variables.

Creating Variables

To reserve memory space for a variable or to assign values to variables, you can use the equal sign (=).

The name of the variable is written to the left of the ‘=’ operator, and the value is written to the right.

Example:

Code

ctr = 1000 # Creates an integer variable distance = 1000.0 # Creates a float variable

str1 = "Sunita Sood" # Creates a string variable

Rules for Naming a Variable

• A variable name starts with a letter or the underscore character. It cannot start with a number or any special character like $, (, *, %, etc.

• A variable name can only contain alphanumeric characters.

• Python variable names are case-sensitive, which means str1 and STR1 are two different variables in Python.

• Python keywords cannot be used as variable names.

Printing Python Variables

The print() function can be used to output a Python variable.

Example:

Code Output

ctr = 1000 distance = 1000.0

str1 = "Sunita Sood"

print(ctr)

print(distance)

print(str1)

Multiple Assignments

Sood

You can create several variables in a single statement with Python because it allows you to assign a single value to many variables at once.

Example: Assignment of single value to many variables.

a = b = c = 700 print (a) print (b) print (c)

Example: Assignment of multiple values to multiple variables.

Code Output

x, y, z = 111, 112, "Sunita Sood" print (x) print (y) print (z)

Dynamic Typing

In Python, when you assign a value to a variable, you do not need to define the variable’s type like in other languages. However, you can check the data type of a variable by using the type() function.

Python specifies the kind of variable used during program execution. This concept is known as dynamic typing.

Example: Code

y = [11, 12, 13] # assigning a value to a variable print(type(y))   # y is a list here y = True   # reassigning a value to the ‘y’ print(type(y))   # y is a bool here <class ‘list’> <class ‘bool’>

Do It Yourself 7A

Identify and write valid or invalid for the following variable names. Ctr ctr name1 city:Delhi

name-1

Operators

Operators are predefined symbols that perform operations on one or more operands.

Types of Operators

The Python language supports the following types of operators:

• Arithmetic operators

• Assignment operators

• Comparison operators

• Logical operators

Let us have a look at all the operators one by one.

Arithmetic operators are used with numeric values to perform common mathematical operations. Consider x=10 and y=3:

111

Precedence of Arithmetic Operators in Python

Operator precedence describes the order in which operations are performed. The precedence of arithmetic operators in Python is as follows:

• P—Parenthesis

• E—Exponentiation

• D—Division

• M—Multiplication (multiplication and division have the same precedence)

• A—Addition (addition and subtraction have the same precedence)

• S—Subtraction

Assignment operators are used to assign values to variables.

Consider the variable x and let us assign values to it.

Did You Know?

The ‘#’ operator is used for giving comments in a Python program.

Comparison operators are used to compare two values. Comparison operators are also known as relational operators. Consider x=10 and y=3:

Logical operators are used to combine conditional statements.

Operator Description

Example Output and Returns True, if both the statements are true

x < 5 and x < 10 False or Returns True, if one of the statements is true x < 5 or x < 4 False not Reverse the result, that is, returns False, if the result is true not(x < 5 and x < 10) True

Did You Know?

Python gives more precedence to arithmetic operators than comparison operators. Within comparison operators, every operator has the same precedence order.

Conditional Statements

What will be the output of the following?

• print(10+15/5*6//2)

• print(10>5+3–1) Think and Tell

In real life, there are times when we must make choices, and based on those choices, we determine what to do next. Programming encounters similar scenarios where we must make choices and then carry out the following block of codes in accordance with those choices.

The programming languages use conditional statements that make decisions to control the direction or flow of the program execution. Conditional statements are also known as decision-making statements.

Types of Conditional Statements

In the Python programming language, the types of conditional statements are:

1 The if statement

2 The if-else statement

3 The if-elif-else statement

The if Statement

The simplest statement for making decisions is the if statement. If the condition associated with if is true, then only it will execute a specific statement or block of statements associated with it; otherwise, it will skip the statements. Syntax: if condition:

# statements to execute if condition is true

Did You Know?

Python uses indentation to identify a statement associated with if.

Let us understand this with the help of an example given below.

Code Output

# Python program to illustrate if statement i =10

if(i > 15):

print("10 is greater than 15")

#indented statement print("I am Not in if")

I am Not in if

In the above example, the value of i (10) is not greater than 15. So, the condition is false, and it will not execute the statement associated with the if statement.

Another example:

Code

a = 133

b = 1200

if b > a:

print("b is greater than a")

Output

b is greater than a

In the above example, the value of b is greater than the value of a. So, the condition is true, and thus it will execute the statement associated with if.

Flowchart of if Statement

The if statement alone tells us that if a condition is true, a block of statements will be executed; if the condition is false, the block of statements will not be executed. However, if the condition is false, we may use the else statement in conjunction with the if statement to execute a block of code when the condition is false.

Syntax:

if (condition):

# Executes this block if condition is true

else:

# Executes this block if # condition is false

Flowchart of Python if-else Statement

Let us understand it with the help of an example:

Code Output

i = 220 if (i< 155):

print("i is smaller than 155")

print("I’m in if Block") else:

print("i is greater than 155")

print("I’m in else Block") print("I’m not in if and not in else Block")

i is greater than 155 I’m in else Block I’m not in if and not in else Block

In the above example, after invoking the statement that is not in the block (without spaces), the block of code that follows the else statement is executed since the condition in the if statement is false.

Shorthand if-else Statement

When only one statement is required in both the if and else blocks, this can be used to write the if-else statements on a single line.

Syntax:

statement_when_True if condition else statement_when_False

Let us illustrate this with the help of an example. In the given example, we are printing True if the number is less than 145; otherwise, it will print False.

Program Output

i = 10

print(True) if i< 145 else print(False)

The if-elif-else Statement

Sometimes, we need to evaluate multiple conditions. In such cases, we use the ‘elif’ statement, which stands for ‘else if’. It allows us to check multiple conditions in sequence, and Python checks each condition until one of them is True.

Syntax: if condition_1:   Statement_1

elif condition_2:   Statement_2 .. .. else:   Statement_n

If condition_1 becomes True, Statement_1 will be executed, otherwise, the interpreter moves on to condition_2 and if it becomes True then it will execute Statement_2. This process continues until a True condition is found, otherwise the ‘else’ statement (Statement_n) will be executed if none of the conditions is True.

Code Output

number = int(input("Enter a number: ")) if number > 0:

print("The number is positive.") elif number < 0:

print("The number is negative.") else:

print("The number is zero.")

Iterative Statements

Enter a number: 23

The number is positive.

Iterative statements are also called loops in programming. Loops are useful in Python because they allow you to execute a block of code repeatedly. You will frequently encounter circumstances in which you will need to utilise a piece of code repeatedly but do not want to write the same lines of code several times. Then those repeated sets of statements can be enclosed within a loop.

Python has two primitive loop statements:

• while loop

• for loop

The while Loop

With the while loop, we can execute a set of statements as long as the condition is true.

Syntax: while expression:

statement(s)

Chapter 7 • Fundamentals of Python

Flowchart of while Loop

A block of code consists of all the statements that follow a programming construct and are indented by the same number of character spaces. Python groups statements together with the same indentation. In the while loop, the condition is assessed initially in a Boolean context. If it returns True, the loop body is executed. The expression is then verified again, and if it is still True, the body is executed again, and so on until the expression becomes False. Let us illustrate this with the help of an example.

Code Output

#Python program to print "Hello" 5 times count = 0

while (count < 5):

count = count + 1

print("Hello")

The count variable is considered as a counter for loop to control the iterations. Remember to increment the count variable, or else the loop will continue forever.

Code Output

#Python program to print 1 to 5 count = 0

while (count < 5):   count = count + 1   print(count)

Single Statement while Block

If the while block consists of a single statement, we can define the entire loop in a single line, just like the if block. If there are numerous statements in the loop body block, they can be separated by semicolons (;). Let us illustrate this with the help of an example:

Code Output

# Program to illustrate single statement while block count =0

while(count < 5): count +=1; print("Hello")

Loop Control Statements

Loop control statements change the execution of the statements from their normal sequence. There are two types of loop control statements:

The continue Statement

The Python continue statement returns control to the beginning of the loop. Let us illustrate this with the help of an example:

Code Output

# Python program to print all letters except 'i' and 'o'

i = 0

a = 'This is Python' while i<len(a):

if a[i] == 'i' or a[i] == 'o': i += 1

continue print('Current Letter :', a[i])

i += 1

The break Statement

Current Letter : T

Current Letter : h

Current Letter : s

Current Letter :

Current Letter : s

Current Letter :

Current Letter : P

Current Letter : y

Current Letter : t

Current Letter : h

Current Letter : n

The Python break Statement brings control out of the loop. Let us illustrate this with the help of an example:

Code Output

# Program to break the loop as soon it sees 'e' or 's' i = 0

a = 'This is Python' while i<len(a):

if a[i] == 'e' or a[i] == 's': i += 1

break print('Current Letter :', a[i])

i += 1

The for Loop

Current Letter : T

Current Letter : h

Current Letter : i

The for loop is used to iterate over an iterable like a string, tuple, list, set, or dictionary sequentially. Syntax: for var in iterable: # statements Chapter 7 • Fundamentals of Python

Flowchart of for Loop

• The iterable in this case is a group of items like lists and tuples.

• For each item in an iterable, the indented statements inside the for loops are once again executed. Every time the loop is executed, the variable var is set to the value of the iterable’s subsequent item.

• The Python for loop is used to iterate over an iterable like a string, tuple, list, set, or dictionary sequentially.

Let us illustrate this with the help of an example:

This code employs a for loop to cycle through a list of numbers, printing each number on a new line. The loop assigns each item to the variable ‘i’ and repeats until the entire list has been iterated.

Code Output

# Python program to illustrate iterating over a list numbers = ["1", "2", "3"] for i in numbers:

The range() Function

Python provides range() function to generate a set of numbers within the specified range. This function can be used with loops in Python.

Syntax:

range(start, stop, step)

Here,

start: The starting value of the sequence (default is 0).

stop: The end value of the sequence (not included).

step: The step between numbers in the sequence (default is 1).

We can skip start and step values. In that case Python considers the default values of these two parameters. Let us understand this with an example.

Code Output

#Python Program to print from 9 to 14

i in range(9,15):

Python for Loop with a Step Size

This code generates a series of numbers with a step size of 2, starting from 9 and going up to (but not including) 15, using a for loop and the range() function. The loop uses the print() method to print the value of each number in the series. The numbers 9, 11, and 13 will be displayed in the output.

#Program to print from 9 to 14 with a step value of 2

i in range(9,15,2):

#Program to print even numbers starting from 220 till 230   for i in range(220,232,2):

Solved Examples

Example 1.1

# Python program to reverse a number using while loop Code

n=int(input("Enter a number: "))

rev=0

while(n>0):

dig=n%10

rev=rev*10+dig

n=n//10

print("Reverse of the number:",rev)

Example 1.2

Enter a number: 8709

Reverse of the number: 9078

#Python program to count the number of digits in a number

n=int(input("Enter a number:")) count=0

while(n>0): count=count+1

n=n//10

print("The number of digits in the number are:",count)

Enter a number: 652348

The number of digits in the number are: 6 Chapter 7 • Fundamentals of Python

1 Write a Python program to find the sum of digits in a number.

2 Write a Python program to display the multiplication table of the entered number.

3 Write a Python program to convert metres to centimetres.

Coding Challenge

Geometry Calculator

Create a Python program with a menu that lets the user choose from various options. The program should perform calculations based on the user's choice and show the result. After displaying the result, the program should ask if the user wants to continue or exit.

The available options are:

1 Calculate the area and perimeter of a circle

2 Calculate the area and perimeter of a rectangle

3 Calculate the area and perimeter of a square

Chapter Checkup

A Fill in the blanks.

Hints iterate   indentation  end  dictionary  precedence

1 In Python, defines a block of statements.

2 Operator describes the order in which operations are performed.

3 The for loop in Python is used to over a sequence or other iterable objects.

4 The continue keyword is used to the current iteration in a loop.

5 A is a collection of key-value pairs that are not ordered.

B Tick () the correct option.

1 Among the following, who is the developer of Python programming?

a Guido van Rossum b   Denis Ritchie

c Y.C. Khenderakar d   Mark Zuckerberg

2 List, tuple, and set are the of data types.

a Default Types

b   Binary Types

c Boolean Types d   Sequence

3 What is the name of the operator ** in Python?

a Exponentiation b   Modulus

c Floor division d   Multiplication

4 Conditional statements are also known as statements.

a Loops b   Array

c List d   Decision-making

5 What will be the output of the following Python code? a=7 if a>4: print("Greater")

a Greater b   7

c 4 d   No output

C

Who am I?

1 I am a comparison operator that is used to check the equality of two values.

2 I am one of the conditional statements in Python that allows you to check multiple conditions.

3 I am a statement in Python that ends the execution of a loop.

4 I am a function in Python that is used to generate a set of numbers within the specified range.

5 I am a built-in data type in Python which represents one of two values, True or False.

D Write T for True and F for False.

1 The type() function can be used to get the data type of any object.

2 The % operator returns the quotient.

3 The if statement is the most fundamental decision-making statement.

4 In Python, an else statement comes right after the block after ‘if ’.

5 Loop control statements change the execution of the statements from their normal sequence.

E Answer the following questions.

1 Differentiate between a for loop and a while loop.

2 Differentiate between break and continue statement.

3 What are the different rules for declaring a variable?

4 What is data type? Name the basic data types used in Python.

5 What are conditional statements? Describe the use of if-else.

F Apply your learning.

1 What is the output of the following lines of code? x = False print(type(x))

2 Write a Python program that uses the range function to print all the numbers from 1 to 10.

3 Write a program to calculate the area of equilateral triangle having a side of 7 cm.

4 Write a Python program to get the next number and previous number of a given number.

Strings in Python 8

Strings

A string is a data type that represents a sequence of characters. In Python, strings are enclosed in single quotes (' ') or double quotes (" "). These values can be words, symbols, characters, numbers, or a combination of all these. A string cannot be changed once it has been created because it is an immutable data type. Strings are commonly used for storing and manipulating text data, as well as representing names, addresses, and other types of information that can be represented as text.

There are two types of strings in Python:

• Single-line string

Single-line String

• Multi-line string

A single-line string can be enclosed in either single quotes or double quotes.

Code Output

name1="Mohit"

name2='Mohit'

print(name1)

print(name2)

Multi-line String

Mohit

Mohit

A multi-line string can be enclosed in either three single quotes (‘‘‘ ’’’) or three double quotes (""" """).

Code Output

proverb_1= '''Don't judge a book by its cover. '''

proverb_2= """ Beauty is in the eye of the beholder.

"""

print(proverb_1)

print(proverb_2)

Don’t judge a book by its cover. Beauty is in the eye of the beholder.

The eval() Function

The eval() function evaluates a string expression and returns the result.

Syntax: result = eval(expression)

Code Output

expression = "2 * 3 + 4 / 2" result = eval(expression)

print(result) Using variables within expressions: x = 5 y = 3

expression = "x + y" result = eval(expression) print(result)

Creating a String in Python

In Python, single, double, or even triple quotes can be used to create strings. Let us define a string with the help of a few examples:

Code Output

String1 = 'Welcome to the World of Python'

print("Single Quote String")

print(String1)

# Creating a string using double quotes

String1 = "I am using Python"

print("\n String with double quotes")

print(String1)

# Creating a string with triple quotes

String1 = '''I am using Python and I live in a world of "Python"''

print("\n String with triple quotes")

print(String1)

# Creating triple quotes string with multiple lines

String1 = ‘’’Programmer For Life’’’

print("\n Multiline String")

print(String1)

A single character in Python is just a string of length 1, since there is no such thing as a character data type. Did You Know?

Single Quote String Welcome to the World of Python

String with double quotes I am using Python

String with triple quotes I am using Python and I live in a world of "Python"

Multiline String Programmer For Life

Note that ‘\n’ is an escape character used to create a new line. The text written after ‘\n’ character comes in the new line.

String Manipulation in Python

String manipulation in Python involves various operations to process and modify string data. Python provides a set of string methods to perform these operations. Let us learn about some of the important string operations.

Concatenation

Concatenation means to join two or more strings together to form a single string. Two strings can be concatenated or joined with the plus ‘+’ symbol, which is known as concatenation operator. Let’s understand it with the help of an example:

Code

# concat strings with + str1 = "Welcome to"

str2 = "World of Python"

sentence = str1 + ‘ ‘ + str2

print(sentence)

Replication

Output

Welcome to World of Python

Replication of strings means to repeat a certain string a specified number of times. The replication operation can be performed with the help of the asterisk symbol '*', which is known as the replication operator.

Look at the given example:

Code

str1='hello'

str2='hello'*3

print(str1)

print(str2)

Replacing a String

Output

hello hellohellohello

If you wish to replace a string, just call the replace() function on any string and specify the string you want to replace it with. Look at the following example:

Code Output

sentence = "Welcome to World of Python" print(sentence) print(sentence.replace("Python","Disneyland"))

Finding the Length of a String

Welcome to World of Python

Welcome to World of Disneyland

To find the length of a string, the len() function is used. The len() function returns the number of characters in a string, including spaces, punctuation, and special characters.

Code Output

str = "Python, World!"

length = len(str)

print("The length of the string is:", length)

The length of the string is: 14

Accessing Characters in Python String

The indexing method in Python can be used to access specific characters within a String.

• Through indexing, characters at the beginning of the string can be accessed using positive address references, starting from 0 for the first character, 1 for the next character, 2 for the next to the next character (as shown in the image), and so on.

• Through indexing, characters at the end of the string can be accessed using negative address references, such as –1 for the last character, –2 for the next-to-last character, and so on.

12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1

Let us understand it with the help of an example:

In this example, we will define a string in Python and access its characters using positive and negative indexing. The 0th element will be the first character of the string, whereas the –1th element is the last character of the string.

Code Output

String1 = "Python World"

print("Initial String: ")

print(String1)

# Printing First character

print("\nFirst character of String is: ")

print(String1[0])

print(String1[-12])

# Printing Last character

print("\nLast character of String is: ")

print(String1[-1])

print(String1[11])

# Printing Fifth character

print("\nFifth character of String is: ")

print(String1[4])

print(String1[-8])

String Slicing

Initial String: Python World

First character of String is:

Last character of String is:

Fifth character of String is:

The string slicing function in Python is used to gain access to a selection of characters in the String. A colon (:), known as a "slicing operator", is used to access a part of the string.

• The string provided after slicing includes the character at the start index but not the character at the last index, so keep that in mind while using this method.

• Subsets of strings can be taken using the slice operators ([ ] and [:]) with indexes starting at 0 at the beginning of the string and working their way from -1 at the end.

Let us understand it with the help of an example:

In the following example, we will slice the original string in order to extract a substring. The expression [4:12] indicates that the string will be divided into segments starting at index 4 and continuing through index 11. In string slicing, negative indexing is another option.

Chapter 8

• Strings in Python

Code Output

# Creating a String String1 = "Python World"

print("Initial String: ")

print(String1)

# Printing 4th to 12th character

print("\nSlicing characters from 4-12: ")

print(String1[4:12])

# Printing characters between 4th and 3rd last character

print("\nSlicing characters between 4th and 3rd last character: ")

print(String1[4:-3])

Using In-built String Methods

Initial String: Python World

Slicing characters from 4-12: on World

Slicing characters between 4th and 3rd last character: on Wo

Python provides several in-built methods to change the case of strings. These methods are helpful for formatting and standardising text. Here are some main functions for changing the case of Python strings:

1. upper()

The upper() method converts all lowercase letters in a string to uppercase.

Code Output

str = "python world" result = str.upper() print(result)

2. lower()

The lower() method converts all uppercase letters in a string to lowercase.

Code Output

str = "PYTHON WORLD" result = str.lower() print(result)

3. capitalize()

python world

The capitalize() method converts the first character of a string to uppercase and the rest to lowercase.

Code Output

str = "python world" result = str.capitalize() print(result)

Python world

PYTHON WORLD

4. title()

The title() method converts the first character of each word to uppercase and the rest to lowercase. Words in a string should be separated by whitespace or punctuation marks.

Code Output

str = "welcome to the world of python" result = str.title() print(result)

5. swapcase()

Welcome To The World Of Python

The swapcase() method converts uppercase characters to lowercase and lowercase characters to uppercase.

Code Output

str = "Python World" result = str.swapcase() print(result) pYTHON wORLD

Decision-making Using String Methods

Apart from these text formatting methods in Python, there are some more methods that are used for decision making using strings. These methods can determine whether a string or character is in uppercase, lowercase, title case, or whether it contains digits or alphanumeric characters. Here are some of the main functions for checking the properties of strings:

1. isupper()

The isupper() method returns True if all the alphabetic characters in a string are uppercase. If the string contains no alphabetic characters, the method returns False.

Code Output

str = "PYTHON WORLD" result = str.isupper() print(result)

str = "Python World" result = str.isupper() print(result) True

2. islower()

The islower() method returns True if all the alphabetic characters in a string are lowercase. If the string contains no alphabetic characters, the method returns False.

Code Output

str = "python world" result = str.islower() print(result)

str = "Python World" result = str.islower() print(result) True False

3. istitle()

The istitle() method returns True if a string is title-cased, which means the first character of each word is uppercase and the rest are lowercase.

Code Output

str = "Python World" result = str.istitle() print(result)

str = "python world" result = str.istitle() print(result)

4. isdigit()

The isdigit() method returns True if all the characters in a string are digits.

Code Output

str = "987654321" result = str.isdigit() print(result)

str = "python98765" result = str.isdigit() print(result)

5. isalpha()

The isalpha() method returns True if all the characters in a string are alphabets.

Code Output

str = "Hello" result = str. is alpha() print(result)

str = "987654321" result = str.isalpha() print(result)

6. isalnum()

The isalnum() method returns True if all the characters in a string are alphanumeric (letters and numbers).

Code Output

str = "987654321" result = str.alnum() print(result)

str = "python98765" result = str.isalnum() print(result)

Solved Examples

Example 2.1

#Python program to perform String operations

Code Output

str2 = 'Hello Sunita' print (str2) # Prints complete string print (str2[0]) # Prints first character of the string print (str2[2:5]) # Prints characters starting from 3rd to 5th print (str2[2:]) # Prints string starting from 3rd character print (str2 * 2) # Prints string two times print (str2 + "TEST") # Prints concatenated string

Example 2.2

#Python program to count the number of vowels in a string

‘Hello

Hello SunitaHello Sunita

Hello SunitaTEST

Code Output

string=input("Enter string:")

vowels=0 for i in string:

if(i=='a' or i=='e' or i=='i' or i=='o' or i=='u' or i=='A' or

i=='E' or i=='I' or i=='O' or i=='U'):

vowels=vowels+1

print("Number of vowels are:", vowels)

Example 2.3

Enter string:ritu

Number of vowels are: 2

#Python program to count number of lowercase characters in a string

Code Output

string=input("Enter string:") count=0 for i in string: if(i.islower()): count=count+1

print("The number of lowercase characters is:", count)

Example 2.4

Enter string:Ritu Singh The number of lowercase characters is: 7

#Python program to count the number of words and characters in a string

Code Output

string=input("Enter string: ")

char=0 word=1 for i in string: char=char+1

if(i==' '): word=word+1

print("Number of words in the string:", word) print("Number of characters in the string:", char)

Enter string: Ritu is a good girl

Number of words in the string: 5

Number of characters in the string: 19

Sunita’

1 Write a Python program that accepts a string and calculates the number of digits and letters.

2 Write a Python program to check whether a letter is a vowel or a consonant.

Chapter Checkup

A Fill in the blanks.

Hints single  indexing  concatenate  double  changed

1 In Python, strings are put inside quotes or quotes.

2 Strings in Python are immutable, which means they cannot be once they have been created.

3 The method in Python can be used to access specific characters within a string.

4 The plus ‘+’ symbol is used to two strings in Python.

B Tick () the correct option.

1 Which of the following is the correct way to define a string in Python?

a  string = ‘Hello’

c  Both a and b

b  string = "Hello"

d  None of the above

2 How do you access the last character of a string using negative indexing?

a  string[-0]

c  string[-2]

b  string[-1]

d  string[-3]

3 Which of the following functions is used to replace a part of a string with another string?

a  eval() b  replace() c  slice() d  concat()

4 Which of the following is a multi-line string in Python?

a  ‘’’This is a multi-line string’’’ b  "This is a multi-line string"

c  ‘This is a multi-line string’ d  All of the above

C Who am I?

1 I am a data type in Python that represents a sequence of characters.

2 I am a function that evaluates a string expression and returns the result.

3 I am an operator used to replicate a string multiple times.

4 I am a method of accessing specific characters within a string in Python.

D Write T for True and F for False.

1 Strings in Python can be enclosed in either single quotes or double quotes.

2 The string slicing function includes the character at the last index.

3 The replace() function can modify a string directly.

4 The eval() function can execute a string expression and return its result.

E Answer the following questions.

1 Write the difference between single-line strings and multi-line strings in Python.

2 How does the indexing method work for accessing characters in a string in Python?

3 How can you use the slicing operator to extract a substring in Python?

4 What does it mean that strings in Python are immutable?

F Apply your learning.

1 Write a Python program that concatenates two strings, "Hello" and "World", and prints the result.

2 Using string slicing, extract the substring "Python" from the string "Learning Python is fun!" and print it.

3 Write a Python program to replace the word "fun" with "awesome" in the string "Learning Python is fun!" and print the result.

4 Write a Python program that uses the eval() function to evaluate the string "3 + 4" and print the result.

Lists and Tuples in Python 9

Lists

Lists are a fundamental data type in Python.

It is a collection of various kinds of values. It can hold multiple values in a single variable.

In Python, lists are used to store multiple values simultaneously. Python includes a built-in list type named "list". In lists, items are written within square brackets [ ].

A list can:

• Store different types (integer, float, string, etc.) of elements.

• Store duplicate elements.

• Store the elements in an ordered manner.

Example: mylist = [2, 4, 6, 8, "Python", 10, 10]

Characteristics of Lists

The characteristics of the lists are given below:

• Ordered: In a list, the values or items have a defined order, and this order does not change. If you add new values to a list, they are placed at the end of the list.

• Accessed via the Index: You can access list elements using an index, which starts at 0. Hence, the first element of a list is present at index 0, not 1.

• Allows Duplicate Values: A list can contain duplicate values. Since values are indexed in a list, it can have items with the same value but a different index.

• Mutable: The meaning of mutable is "liable to change". In Python, list items are mutable. It means elements of the list can be modified, individual elements can be replaced, and the order of elements can be changed even after the list has been created.

• Variable Size: Lists can store a variable number of elements, allowing you to store and manage different quantities of data.

Creating a List in Python

In Python, you can create a list by enclosing the values or elements within square brackets [ ], separated by commas. There is no need for a built-in function to create a list.

Syntax: list_name = [element_1, element_2, … , element_n]

Example:

Suppose you need to record the percentage of marks for six students. For this, you can simply create a list.

markslist = [70, 88, 90.2, 75, 68, 59.5]

print(markslist)

Creating a List with Duplicate Elements

[70, 88, 90.2, 75, 68, 59.5]

A list can have duplicate values. Let us see the following example:

Code

list = [3, 4, 9, 3, 8, 9]

print(list)

Creating a List with Mixed Types of Elements

[3, 4, 9, 3, 8, 9]

You can have elements of different data types in a list. They can be of numeric type, string type, Boolean type, etc.

Example: Code

list1 = ["Ankit", 34, False, 55.5, "Mala"]

print(list1)

Accessing Elements of a List

[‘Ankit’, 34, False, 55.5, ‘Mala’]

Indexing is used in Python to access list elements. Suppose there are n number of elements in a list. Therefore, the list indexing will start at 0 for the first element and n-1 for the last element. You can use these index values to access the items in the list. The index must be an integer. Let us see how to access elements in a list. Look at the following image to understand the concept of indexing:

Example:

Print the third and fifth item of the list.

[Hint: The third element has an index 2 and the fifth 4.]

markslist = [70, 88, 90.2, 75, 68, 59.5]

print(markslist[2])

print(markslist[4]) 90.2 68

List Methods

Python has a set of built-in methods that you can use on lists.

append(): This method is used to add an element at the end of the list. An element can be of any type (string, number, object, etc.).

Syntax: list.append(element)

For example, add the item "eggs" to the shopping_list = ["bread", "butter", "milk", "apples"].

Code Output

shopping_list = ["bread", "butter", "milk", "apples"]

shopping_list.append("eggs")

print(shopping_list)

[‘bread’, ‘butter’, ‘milk’, ‘apples’, ‘eggs’]

clear(): This method is used to remove all the elements from the list.

Syntax: list.clear()

For example, remove all elements from the shopping_list = ["bread", "butter", "milk", "apples"].

Code Output

shopping_list = ["bread", "butter", "milk", "apples"]

shopping_list.clear()

print(shopping_list)

count(): This method is used to return the number of the specified element.

Syntax: list.count(value)

For example, to count the number of times the value ‘3’ appears in the list = [3, 4, 9, 3, 8, 9]:

Code Output

list = [3, 4, 9, 3, 8, 9] x=list.count(3) print(x)

2

pop(): This method is used to remove the element at the specified position.

Syntax: list.pop(position)

For example, remove the third element from the list = [3, 4, 9, 3, 8, 9].

[Hint: The third element has an index 2.]

Code Output

list = [3, 4, 9, 3, 8, 9] list.pop(2) print(list)

[3, 4, 3, 8, 9]

Note: If the position is not specified, by default, the pop() method removes the last element from the list.

remove(): This method is used to remove the first occurrence of the specified element.

Syntax: list.remove(element)

For example, remove 3 from the list = [3, 4, 9, 3, 8, 9].

Code

list = [3, 4, 9, 3, 8, 9] list.remove(3) print(list)

[4, 9, 3, 8, 9]

index(): This method is used to find the position of the first occurrence of the specified element. Syntax: list.index(value)

For example, find the first occurrence of the value 9, and return its position in the list = [3, 4, 3, 9, 8, 9]. Code

list = [3, 4, 3, 9, 8, 9] x = list.index(9) print(x)

3

sort(): This method is used to sort the list in ascending order, by default. To sort the list in descending order, the attribute reverse is used. If its value is set to ‘True’, then the list will be sorted in descending order.

Syntax: list.sort()

Example 1: Sort the list = [3, 4, 9, 3, 8, 9] in ascending order.

Code

list = [3, 4, 9, 3, 8, 9] list.sort() print(list)

[3, 3, 4, 8, 9, 9]

Example 2: Sort the list = [3, 4, 9, 3, 8, 9] in descending order.

Code

list = [3, 4, 9, 3, 8, 9] list.sort (reverse=True) print(list)

Solved Examples

Example 3.1

[9, 9, 8, 4, 3, 3]

Create a list of subjects (Maths, English, Science, Hindi, and Computer). Print all subjects in the list, one by one. Ans:

Code

subject_list = ["Maths", "English", "Science", "Hindi", "Computer"] for x in subject_list:   print(x) Maths English Science Hindi Computer

Example 3.2

Sort the list alphabetically:

List [s, u, n, s, c, r, e, e, n]

Ans: Code

list = ["s", "u", "n", "s", "c", "r", "e", "e", "n"] list.sort()

print(list)

Tuples

[‘c’, ‘e’, ‘e’, ‘n’, ‘n’, ‘r’, ‘s’, ‘s’, ‘u’]

A tuple is an ordered, immutable collection of things or values. Tuples are sequences, just like lists, but they cannot be modified, unlike lists. Lists use square brackets, while tuples use parentheses () to enclose the elements. Tuples are faster than lists.

For example, mytuple = (1, 2, 3, 4, 5)

Characteristics of Tuples

The characteristics of tuples are given below:

• Ordered: In a tuple, the values or items have a defined order, and this order does not change.

• Accessed via the Index: The tuple element can be accessed via the index. It means that the tuple index always starts with 0. Hence, the first element of a tuple is present at index 0, not 1

• Immutable: The tuple items are immutable. The meaning of immutable is "unable to be changed". It means that we cannot add, modify, or remove items in a tuple after it has been created.

• Allows Duplicate Values: A tuple can contain duplicate values. Since values are indexed in a tuple, it can have items with the same value and a different index.

Creating a Tuple

In Python, you can create a tuple by placing the values or elements inside the parentheses ( ), separated by commas.

Syntax: tuple_name = (element_1, element_2, … , element_n)

Creating a Tuple with a Single Item

To create a tuple with a single item, you have to add a comma after the item; otherwise, Python will not recognise it as a tuple.

Example: Code

mytuple = ("Delhi",) print(mytuple)

Creating a Tuple with Duplicate Elements

A tuple can contain duplicate elements. Their index values will be different.

Example:

tuple = (3, 4, 9, 6, 4, 9)

print(tuple)

Creating a Tuple with Mixed Elements

A tuple can have elements of mix data type.

Example:

Code

tuple = ("Delhi", 4, 9, "Japan", 4, 9)

print(tuple)

Accessing Elements of a Tuple

(3, 4, 9, 6, 4, 9)

(‘Delhi’, 4, 9, ‘Japan’, 4, 9)

Indexing is used in Python to access tuple elements. You can access a tuple entry using indexing. In Python, tuple indexing starts at 0 for the first element. You can use the index operator [ ] to access an item in a tuple. The index must be an integer. Here is how you can access elements in a tuple:

For example: Print the first item in the tuple.

Code

tuple1 = ("Delhi", "Punjab", "Haryana", "Gujarat")

print(tuple1[0]) Delhi

Tuple Methods

Python has two built-in methods that you can use on tuples.

count(): This method is used to compute the occurrence of a specified value that appears in the tuple.

Syntax: tuple.count(value)

Example: How many times the value 9 appears in the tuple = (3, 4, 9, 6, 4, 9)? Code

tuple = (3, 4, 9, 6, 4, 9)

x = tuple.count(9)

print(x)

2

Index(): This method is used to find the position of the first occurrence of the specified value.

Syntax: tuple.index(value)

Example: Find the first occurrence of the value 9, and return its position in the tuple = (3, 4, 9, 6, 4, 9).

Code Output

tuple = (3, 4, 9, 6, 4, 9)

x= tuple.index(9) print(x)

Deleting Elements of a Tuple

2

As you are aware, the tuple items are immutable. It implies that once a tuple is created, its elements cannot be changed, added to, or removed without creating a new tuple. However, there is a workaround using the steps that follow:

• You can convert the tuple into a list

• Change the list

• Convert the list back into a tuple

Example: Convert the tuple into a list, remove "Haryana", and convert it back into a tuple:

Code Output

tuple1 = ("Delhi", "Punjab", "Haryana", "Gujarat")

x = list(tuple1) x.remove("Haryana")

tuple1 = tuple(x) print(tuple1) mytuple = ("Delhi") print(mytuple)

Solved Examples

Example 3.3

Combine or merge two given tuples.

tuple1 = (1, 3, 5)

tuple2 = (2, 4, 6)

Ans:

Tuple concatenation is used to merge the tuples.

Think and Tell

Are lists and tuples heterogeneous or homogeneous data structures?

Code Output

tuple1 = (1, 3, 5) tuple2 = (2, 4, 6) result_tuple = tuple1 + tuple2 print(result_tuple)

Example 3.4

Multiply the given tuple by 3. tuple1 = (1, 2, 3)

(1, 2, 3, 4, 5, 6)

You can use the ‘*’ operator to multiply the tuple. This feature is known as replicating a tuple.

and Tuples

(‘Delhi’, ‘Punjab’, ‘Gujarat’)

Code Output

tuple1 = (1, 2, 3)

tuple1 = tuple1*3

print(tuple1)

Difference Between Lists and Tuples

(1, 2, 3, 1, 2, 3, 1, 2, 3)

Lists and tuples are both used to store items and organise data. They are a fundamental concept in Python. But they have a major difference. In lists, the elements can be changed after they are defined, while in tuples, the elements cannot be changed at all. In real-life, you might use a shopping list where items can be added, removed, or modified. The tuples can be used to represent days of the week, as these do not change.

S. No. Lists Tuples

1 Lists are mutable. Tuples are immutable.

2 You can easily insert or delete data items in a list. You cannot directly insert or delete data items in a tuple.

3 Lists have several built-in methods. Due to immutability, a tuple does not have many built-in methods.

4 Lists are generally slightly slower than tuples because of their mutability. Tuples are faster than lists.

5 Lists are created using square brackets []. Tuples are created using parentheses ().

6 Example: list1 = [1, 2, 3] Example: tuple1 = (1, 2, 3)

Do It Yourself 9A

1 Create a tuple of vegetables (potato, tomato, brinjal, ginger, garlic). Print all vegetables in the tuple, one by one.

2 Make a list of the things you want to buy and write a Python code that organises the list alphabetically.

Chapter Checkup

A Fill in the blanks.

Hints mutable  faster  unlimited  immutable  reverse

1 A list can contain elements.

2 Tuples are than lists.

3 Lists are .

4 Tuples are .

5 The attribute of sort() method is used to reverse the order of the list.

B Tick () the correct option.

1 The list.pop() function will:

a remove the first element from the list.

b   remove the last element from the list.

c remove both first and last elements. d   not remove any element from the list.

2 Which of the following are true about Python lists?

a There is no limit to the size of a list.

b   All elements in a list must be of the same size.

c A list may contain the same type of objects. d   A list is immutable.

3 List L is given below:

L = [0, 1, 2, 3, 4]

Choose the correct answer to delete the element 3 from the list.

a L.delete(3)

c del L[2]

4 Which of the following is mutable?

b   L.remove(3)

d   L.pop(3)

a String b   List

c Tuple d   Set

5 What will be the output of the given code?

tuple = (1, 8, 7, 5, 4, 8, 5)

x = tuple.count(5) print(x)

C Who am I?

1 I am a method that helps to sort a list.

2 I am a collection of values which is ordered and unchangeable.

3 I am a dynamic and change-oriented collection of values.

4 I am a method that helps to add an element at the end of the list.

5 I am an operator that helps to replicate a tuple.

D Write T for True and F for False.

1 The sort() function is used to reverse the order of the list.

2 You cannot directly insert or delete data items in a tuple.

3 Lists are immutable.

4 The list allows duplicate values.

5 Lists cannot store different types of elements.

E Answer the following questions.

1 Explain any three characteristics of a list.

2 Write a code to create a tuple with a single element.

3 Differentiate between pop() and remove() with a suitable example.

4 Write three differences between list and tuple.

5 Discuss any three characteristics of a tuple.

1 Write the code to convert the given list L to tuple: L = [1, 5, 8, 9, 15]

2 Write a code to create a list with single element.

3 Write a code to create a tuple T with the given data: 9, ‘Ram’, 7, 5, ‘Hema’

4 Add a student’s name, "Sushma", at the end of the given list: Stu_list = ["Lata", "Rama", "Ankit", "Vishal"]

5 Create a list of strings and access the elements using index.

More on HTML 10

What Is HTML?

HTML stands for HyperText Markup Language. HTML is a markup language used to design web pages. It defines the structure of a web page and tells the web browser how and where to display the content of the web page. A web page is a document placed on the World Wide Web (WWW) as a part of a website.

The term ‘hypertext’ is a combination of two words ‘hyper,’ which means beyond, and ‘text,’ which means written words. The main goal of hypertext is to go beyond the linear reading process and navigate to the desired location on the web with the help of interconnected web pages.

The term ‘markup language’ refers to a language which creates layout of web pages and applies formatting on them. It makes the objects on the web page like text, image, audio, etc. more interactive, and it also enriches the look and feel of the web pages.

To create a web page in HTML, you need two main things:

• A Text Editor: Text editor is software used to write the code of HTML documents. Some of the popular text editors are Notepad, Notepad++, Sublime Text, etc.

• A Web Browser: A web browser is used to access and view web pages. Examples of web browsers are Google Chrome, Apple Safari, Microsoft Edge, Opera, Mozilla Firefox, etc.

Basics of HTML

An HTML document consists of HTML tags, elements, and attributes.

Tags

Did You Know?

A tag is a basic building block of an HTML document that specifies how the content is displayed on the web page. HTML provides several built-in tags. Each of these tags has a specific purpose. For example, the <p> tag is used to create a paragraph in a web page. Each tag has a name which is enclosed in angle brackets < and >. For example, <html>, <body>, <hr>, etc., are some tags in HTML.

Most of the tags in HTML have opening and closing tags. Opening tag is the name of the tag enclosed in the angle brackets. Whereas, the closing tag has a forward slash in the beginning of the tag name and is enclosed in angle brackets. For example,

<html> is the opening tag.

</html> is the closing tag.

The effect of a tag is restricted only to its closing tag. Between opening and closing tags, content is placed.

The first web page was developed by Tim Berners-Lee, a British scientist, in 1991.

Elements

The combination of opening tag, content and closing tag is known as element. For example, the paragraph element is as follows:

<p> I am a paragraph. </p>

There are two types of elements in HTML which are as follows:

• Container Elements: Container elements contain other elements or text within them. They have both an opening tag and a closing tag to enclose their content.

Examples: <html></html>, <head></head>, <body></body>.

• Empty Elements: Empty elements, also known as void elements or self-closing elements, do not contain any content. They do not require a closing tag.

Examples: <br>, <hr>, <img>.

Attribute

An attribute provides additional information about an HTML element and modifies its behaviour. Attributes are always placed inside the opening tags of HTML elements. The syntax to add an attribute is as follows: <element attribute=”value”>Content</element>

Where,

• Element: The HTML element to which the attribute belongs.

• Attribute: The name of the attribute.

• Value: The value assigned to the attribute.

For example,

<p align = “right”> I am a paragraph with right alignment </p> Here, align is the attribute of <p> element.

Structure of an HTML Document

Did You Know?

Multiple attributes can be used in an element.

The structure of an HTML document is divided into two main parts: the head and the body. <html> <head>

<title> Title of the web page</title> </head> <body>

Body of the web page </body> </html>

Head Body

Think and Tell

How are tags and attributes different?

The head contains information about the document, such as the title. The title appears on the title bar or tab of the web browser.

The body contains the content of the web page, such as text, images, and videos. The content of the body is displayed in the browser window.

HTML document structure has four tags to describe the document structure, which are as follows:

1 The <html> and </html> tags enclose the entire document.

2 The <head> and </head> tags enclose the head section of the document.

3 The <title> and </title> tags enclose the title of the document.

4 The <body> and </body> tags enclose the body section of the document.

Basic Tags of HTML

Some of the basic tags of HTML are as follows:

Tag Description

<h1> to <h6> Used to create headings and subheadings on a web page. <h1> is the biggest heading and <h6> is the lowest heading

<h1> Heading 1 </h1>

<h2> Heading 2 </h2>

<h3> Heading 3 </h3>

<h4> Heading 4 </h4>

<h5> Heading 5 </h5>

<h6> Heading 6 </h6>

Heading 1

Heading 2

Heading 3

Heading 4

Heading 5

Heading 6

<sub> Used to lower the text below the baseline H2<sub>2</sub>O H2O

<sup> Used to raise the text above the baseline A<sup>2</sup> A2

<b> Used to make the text bold

<b> Bold </b> Bold

<i> Used to make the text italic <i> Italic </i> Italic

<em> Used to emphasise text

<em> Emphasised </em> Emphasised

<a> Used to create a hyperlink <a href = ”www.google.com”>

Home </a> Home

<p> Used to create a paragraph <p> I am a paragraph </p> I am a paragraph

Let’s create a web page using some of these tags:

<html> <head>

<title> Text Formatting Example </title> </head> <body>

<h1> Welcome to My Web Page </h1>

Code

<p> This is a simple paragraph with some <em> emphasised </em> text. We can also use superscript and subscript: </p>

<p> The chemical formula for water is H<sub>2</sub>O, and the famous equation is E = mc<sup>2</sup>. </p>

<p> Feel free to explore the content on this page. Thank you for visiting! </p> </body> </html>

Output

Welcome to My Web Page

This is a simple paragraph with some emphasised text. We can also use superscript and subscript.

The chemical formula for water is H2O, and the famous equation is E = mc2

Feel free to explore the content on this page. Thank you for visiting!

Do It Yourself 10A

1 Write any three examples of container elements of HTML.

2 Write the name of the tag used for:

a   Making the text bold

b   Making a paragraph

c   Making the text italic

Understanding CSS

Cascading Style Sheets (CSS) is a language used to style the HTML elements. It allows us to change the look and feel of the web pages.

Selectors

CSS uses selectors to target HTML elements. Selectors can target elements by tag name, class, ID, attribute, and more. For example,

body { font-family: sans-serif; background-color: blue;

}

.highlight { color: red;

}

Here, .highlight is the class selector which can be used in HTML tag with the help of the class attribute.

Properties and Values

CSS is used in a property-value pair. The colon (:) sign is used to separate the property from a value. CSS properties define the styles that are to be applied to the selected elements, and values specify the settings for those properties. For example:

selector { property: value; } p{ font-size: 24px; }

There are several properties of CSS. Let us discuss some of them in the following table:

Property Description

color Sets the colour of the text.

Example

color: blue background-color Sets the background colour of the HTML element. background-color: red font-family Sets the font family of the text.

font-family: cambria font-size Sets the size of the text.

font-size: xx-small

Note: x-small, small, medium, large, x-large, xx-large can also be used as values.

font-weight Sets the weight or thickness of the text. font-weight: bold

Note: lighter, or any number can also be used

padding Sets the space around the content of the element. padding: 40px

margin Sets the space around the element itself. margin: 20px border Specifies the border around the element. border: 2px border-radius Specifies the radius of the corners of the element border. border-radius: 5px

opacity Specifies the transparency of the element. opacity: 50 text-align Aligns the text horizontally within a box. text-align: centre box-sizing Controls how the sizing of an element is calculated. There are two possible values for this property: content-box and border-box.

box-sizing: border-box

How to Use CSS in a Web Page

CSS can be used in three ways in a web page which are as follows:

1 Inline CSS: It allows us to apply style to a particular element on a web page with the help of the style attribute. For example, <p style=”color: red; font-size: 15px;”>This is a paragraph</p>

2 Internal CSS: It allows us to apply style to the whole web page with the help of <style> element.

Code Output

<head> <style> p { color: red; font-size: 15px; } </style> </head> <body>

<p>This is a paragraph </p>

<p>This is another paragraph </p> </body>

This is a paragraph

This is another paragraph

3 External CSS: It allows us to style multiple pages with the help of <link> element.

Code Output

<head> <link rel=”stylesheet” href=”style.css”>

</head> <body>

<p>This is a paragraph </p> </body>

The style.css file would contain the following CSS: p { color: red; font-size: 15px; }

This is a paragraph.

Let us use some of these CSS properties, that we have learnt in the previous section, in the following web page:

Code

<html> <head>

<title> Text Formatting Example </title> <style> body{ background-color:lightgreen; } h1{ color: red; } </style> </head> <body>

<h1> Welcome to My Web Page </h1>

<p> This is a simple paragraph with some <em>emphasised</em> text. We can also use superscript and subscript: </p>

<p> The chemical formula for water is H<sub>2</sub>O, and the famous equation is E = mc<sup>2</sup>. </p> <p> Feel free to explore the content on this page. Thank you for visiting! </p> </body> </html>

Welcome to My Web Page

This is a simple paragraph with some emphasised text. We can also use superscript and subscript. The chemical formula for water is H20, and the famous equation is E = mc2 Feel free to explore the content on this page. Thank you for visiting!

Here, in this web page, the background colour is changed and the colour of the heading is also changed.

Chapter Checkup

A Fill in the blanks.

Hints <sub>  HTML  inline  element

1 is a markup language used to design web pages.

2 The combination of opening tag, content, and closing tag is known as

3 The tag is used to raise the text below the baseline.

4 The CSS allows us to apply style on a particular element on a web page with the help of style attribute.

B Tick () the correct option.

1 What is the need of a text editor while creating web pages?

a To write the code of web pages

c   Both a and b

2 The effect of a tag is restricted only up to its tag.

a opening

c   the end of the web page

b   To view the web pages

d   None of these

b   closing

d   All of these

3 Which of the following elements is used to enclose the title of the web page?

a <title> and </title>

c   <head> and </head>

b   <body> and </body>

d   <h1> and </h1>

4 Which of the following CSS properties is used to set the space around the content of the element?

a margin

c   border

C Who am I?

1 I am an HTML tag that is used to emphasise text.

2 I am a sign that is used to separate a CSS property from its value.

3 I am a method to apply CSS to all the web pages of a website simultaneously.

4 I am used to specify the transparency of the element.

b   padding

d   opacity

D Write T for True and F for False.

1 HTML stands for Hypertext Making Language.

2 CSS is used in a property-value pair.

3 The <a> tag is also known as anchor tag.

4 The <sub> tag is used to raise the text above the baseline.

E Answer the following questions.

1 What is the meaning of the term ‘markup language’?

2 Write the syntax to define an attribute with a tag and explain each part.

3 What is the difference between padding and margin properties of CSS?

4 What is the role of selectors?

F Apply your learning.

1 Write the HTML code to display the following output on a web page: a3 − b3 Factorisation: (a − b) × (a2 + ab + b2)

2 Write the CSS code to create a box using <div> tag with the following specifications: Height = 400px Width = 500px

Border size = 5px

Border colour = grey

Creating Forms in HTML 11

In this chapter, you will study the most interactive and essential element of web development, i.e., HTML forms. Forms are used to collect information from users, such as their names, email addresses, and hobbies. In this chapter, you will learn to create forms and understand how they work.

What Are HTML Forms?

HTML forms are commonly used when websites need to gather information from users. For example, if someone wants to buy a bag online, they would first fill their address details in one part of the form and then enter their payment information in another part to complete the purchase. An HTML <form> element is used to create fields where users can provide information in an interactive way. It includes fields where users can type text, numbers, email addresses, and passwords, and indicate choices like selecting check boxes or clicking buttons.

Form Structure

In HTML, the structure of a form is how you organise and align the various elements that make up the form. A basic form consists of several elements. Let us learn about these elements and options.

The <form> Element

The <form> element is a container for all form elements. It helps define where the form begins and ends on a web page.

Example: <form> <-- Form elements --> </form>

The <input> Element

The <input> element is used to create various fields to collect different types of information from users, such as text, email addresses, passwords, and more. The <label> element is used to attach a text with the input fields. Some common types of input fields are:

1 Text Input: It is used to take textual information from the user like name, age, roll number, etc. Use type="text" attribute:

Example:

Code Output

<label for="first_name">First Name:</label> <input type="text" id="first_name" name="first_name">

2 Email Input: It is used to take the email address as information from the user. It verifies the format of the email address, which means you must enter the email address in the correct format. It shows a message if you enter an incorrect email. It also gives suggestions of email addresses that you have used earlier in the web browser.  Use type="email" attribute:

Example:

Code

<label for="email">Email:</label>

<input type="email" id="email" name="email">

Output

3 Password Input: It is used to take sensitive information like passwords, bank account numbers, etc., from the user. The characters you entered in this field appear in the form of stars or dots. An eye icon also appears in this field which allows you to view the text in readable form. Use type="password" attribute:

Example:

Code Output

<label for="password">Password:</label>

<input type="password" id="password" name="password">

4 Date Input: It is used to take date as input from the user. It displays a calendar to select the date. Use the type="date" attribute:

Example:

Code

<label for="dob">Date of Birth:</label>

<input type="date" id="dob" name="dob" required>

Output

5 Radio Buttons: The Radio button option allows users to select one option from a list. Use the type="radio" attribute:

Example:

Code Output

<label>Gender:</label>

<input type="radio" id="male" name="gender" value="male">

<label for="male">Male</label>

<input type="radio" id="female" name="gender" value="female">

<label for="female">Female</label>

<input type="radio" id="other" name="gender" value="other">

<label for="other">Other</label>

6 Check Boxes: The check box option allows users to select multiple options from a list. Use the type="checkbox" attribute:

Example:

Code Output

<label>Interests:</label>

<input type="checkbox" id="sports" name="interests" value="sports">

<label for="sports">Sports</label>

<input type="checkbox" id="music" name="interests" value="music">

<label for="music">Music</label>

<input type="checkbox" id="movies" name="interests" value="movies">

<label for="movies">Movies</label>

The <textarea> Element

The <textarea> element is used for long text input, such as comments or messages: Example:

Code Output

<label for="address">Address:</label>

<textarea id="address" name="address" rows="4" required>

The <button> Element

Did You Know?

How is a text input field different from a password input box?

The <button> element is used to create buttons within forms. You can use it to perform any action on the form. The type attribute is a must to use with the <button> element. It takes any one value out of button, submit, and reset values.

Example:

Code

<button type="button"> Login </button> <button type="button"> Cancel </button>

The <select> Element

The <select> element is used to create drop-down menus. The <option> element is used in combination with the <select> element to create items in the drop-down menu.

Example:

Code

<label for="course">Course:</label>

<select id="course" name="course" required> <option value="math">Mathematics</option> <option value="science">Science</option> <option value="history">History</option> <option value="english">English</option> </select>

Think and Tell

Output

Imagine you are designing a website for a local library. The librarian wants to use an HTML form to allow users to request the issuing of books. Think about the various form elements you would include in this form.

Creating and Displaying a Form

Use the following code to create a form:

<html> <head>

<title>Student Details Form</title> </head> <body>

<h1>Student Details</h1> <form>

<label for="first_name">First Name:</label>

Code

<input type="text" id="first_name" name="first_name" required><br><br>

<label for="last_name">Last Name:</label>

<input type="text" id="last_name" name="last_name" required><br><br>

<label for="dob">Date of Birth:</label> <input type="date" id="dob" name="dob" required><br><br>

Code

<label for="email">Email:</label>

<input type="email" id="email" name="email" required><br><br>

<label for="phone">Phone Number:</label>

<input type="tel" id="phone" name="phone" required><br><br>

<label for="address">Address:</label> <textarea id="address" name="address" rows="4" required></textarea><br><br>

<label for="course">Course:</label>

<select id="course" name="course" required> <option value="math">Mathematics</option> <option value="science">Science</option> <option value="history">History</option> <option value="english">English</option> </select><br><br>

<label for="gender">Gender:</label>

<input type="radio" id="male" name="gender" value="male" required> <label for="male">Male</label> <input type="radio" id="female" name="gender" value="female" required> <label for="female">Female</label> <input type="radio" id="other" name="gender" value="other" required> <label for="other">Other</label><br><br>

<button type="submit" value="Submit">Submit</button> </form> </body> </html>

Output

Form Attributes

Forms can have various attributes to control the behaviour of a form:

• Action: Specifies the URL to which form data will be submitted.

• Method: Specifies the HyperText Transfer Protocol (HTTP) method to be used (either "GET" or "POST"). GET is better for submitting non-sensitive information, whereas POST is used to submit sensitive information.

• Name: Assigns a name to the form for easy identification.

• Target: Specifies where to display the response after form submission (e.g., in the same window or in a new one). It takes any one value from the _blank, _self, _parent and _top values.

Here is an example of a form with attributes:

<form action="submit_student_details.php" method="post" target="_blank">

Did You Know?

HTML forms not only collect user data but can also be used for interactive quizzes, surveys, and feedback on websites. They are versatile tools for engaging with online visitors.

The form action is set to ‘submit_student_details.php’, which is where you can process the form data on the server side.

The form method is set to ‘POST’, signifying the HTTP method used.

Form Validation

Form validation is crucial to ensure that users provide the correct type of information. HTML introduced built-in form validation, using attributes like required, min, max, and pattern.

For example:

<label for="age">Age:</label>

<input type="number" id="age" name="age" required min="18" max="99">

The required attribute makes the field mandatory, and min and max specify the acceptable value ranges. The pattern attribute can be used to enforce a specific format such as a valid email address.

Setting Properties of a Form Using Internal CSS

Setting properties of a form using internal CSS is also known as embedded CSS or inline CSS. You can make your HTML forms look attractive and arrange them on your web page by using the <style> element. This <style> element is placed in the <head> section of your HTML document.

Steps to set properties of a form using internal CSS are:

1 Open an HTML Document: Start by creating a standard HTML document structure, including the <!DOCTYPE html>, <html>, <head>, and <body> elements.

2 Include the <style> Element: Inside the <head> section of your HTML document, include a <style> element. This element is where you will define the CSS rules for styling your form elements.

3 Select the Form Element: To target the form you want to style, use the form selector. For example, to style all forms in your document, you can use form {}. To style a specific form, you can use an ID or class selector like #myForm {}.

4 Define CSS Properties: Within the selected form CSS block, you can define various CSS properties to control the appearance of the form. Common properties include width, margin, padding, background-color, border, border-radius, font-size, color, and many more. You can style form elements individually or collectively.

5 Style Form Elements: Inside a form block, you can target specific form elements such as labels, input fields, buttons, and other related elements. Use CSS selectors such as label {}, input[type="text"] {}, and input[type="submit"] {} to style these elements individually.

6 Save and Apply: When you have defined your internal CSS rules, save the HTML document. When you load the HTML document in a web browser, the CSS styles you have defined will be applied to the form elements.

Code

<html> <head>

<title>Form Styling</title> <style>

/* Internal CSS styles for the form */ form { width: 400px; /* Set the width of the form. */ margin: 0 auto; /* Center-align the form. */ padding: 50px; /* Add some padding for spacing. */ background-color: #f2f2f2; /* Set the background colour.*/ border: 1px solid #ccc; /* Add a border. */

}

/* Style for form labels */ label { display: block; /* Display labels as block elements for better spacing. */ margin-bottom: 10px; /* Add some space between labels */ font-weight: bold; /* Make labels bold. */

}

/* Style for form input fields */ input[type="text"], input[type="email"] { width: 100%; /* Set input fields to 100% width. */ padding: 10px; /* Add padding for input fields. */ margin-bottom: 15px; /* Add space between input fields. */ border: 1px solid #ccc; /* Add a border to input fields. */ }

/* Style for the submit button */ input[type="submit"] { background-color: #007bff; /* Set a background colour for the button. */ color: #fff; /* Set text color to white. */ padding: 10px 20px; /* Add padding for the button. */ border-radius: 3px; /* Add rounded corners to the button. */ }

</style> </head> <body> <form> <label for="name">Name:</label> <input type="text" id="name" name="name"> <label for="email">Email:</label> <input type="email" id="email" name="email"> <button type="submit" value="Submit">Submit</button> </form> </body> </html>

Do It Yourself 11A

1 Who am I?

a I am a button that allows users to select one option from a list.

b I am a form attribute that specifies the URL to which the form data will be submitted.

c I am an HTML element that makes a form look attractive, and I am placed in the <head> section of the HTML document.

2 Answer the following questions.

a Explain the ‘method’ attribute of a form.

b What is the use of radio buttons in an HTML form?

Chapter Checkup

A Fill in the blanks.

HTML forms can be styled extensively using CSS to match website design and branding for creating visually appealing and cohesive user interfaces. Did You Know?

1 HTML is used to create a space where users can provide information by using various interactive options.

2 The element is used for long text input, such as comments or messages.

3 The type attribute is used for radio buttons, allowing users to select one option from a list.

4 The attribute makes a field mandatory in an HTML form.

5 Setting properties of a form using internal CSS is also known as CSS.

B Tick () the correct option.

1 Which of the following HTML elements is used to create a container for form elements?

a <input> b   <form>

c <label> d   <select>

2 Which of the following input types is used for collecting the name of a student?

a email b   text

c password d   radio

3 Which of the following elements helps create a drop-down menu in HTML forms?

a <select>

c <textarea>

4 Which attribute can be used to apply a specific format?

a required

b   <input>

d   <button>

b   specific

c validate d   pattern

5 What is the purpose of the <button> element in HTML forms?

a To display text b   To create hyperlinks

c To submit the form d   To add images

C Write T for True and F for False.

1 Form validation is crucial to ensure that users provide correct information.

2 The <input> element can collect various types of input, including text, email addresses, and passwords.

3 Check boxes allow users to select only one option from a list.

4 The ‘action’ attribute in a <form> element specifies where the form data will be submitted.

5 HTML introduced in-built form validation, using attributes like ‘required’ and ‘min’.

D Answer the following questions.

1 What is the primary purpose of the HTML <form> element in web development?

2 What is the purpose of form validation in HTML? Name the attributes that support form validation.

3 How can internal CSS (embedded) be used to style HTML forms?

4 Name the various attributes that control the behaviour of a form.

5 What is the <input> element? Explain any two <input> fields with their syntax.

E Apply your learning.

1 Create a simple HTML form for receiving parents’ feedback on a school event. Include fields for the student and parent names, class, section, email address, and comments. Apply form validation to ensure that all fields are filled correctly. Use internal CSS to style the form. Customise the background colour, font styles, and appearance of the ‘Submit’ button on the form.

2 Imagine that you are conducting a survey about students’ favourite school subjects. Design an HTML form with radio buttons for subjects such as Mathematics, Science, History, and English. Allow the students to select their favourite subject and submit their choice.

3 Create a basic HTML form for an ice-cream parlour where customers can indicate their preferred ice-cream flavours. The HTML form should include check boxes with these options: chocolate, vanilla, choco-chip, strawberry, and butterscotch. Ensure that users can select multiple flavours and provide a ‘Submit’ button at the end to complete the submission process.

Inserting Multimedia in HTML 12

Multimedia elements like images, links, audio, and video are used to enhance the user experience on a web page. They are used to make the content more informative. Let us learn how to insert different types of multimedia in HTML.

Adding Images

The <img> tag of HTML allows us to add images to the web page. The attributes of the <img> tag are as follows:

Attribute

Description

Alt Used to specify the alternate text which appears only if the specified image is not loaded due to some reason.

Height Used to specify the height of the image.

Src Used to specify the path of the image.

Width Used to specify the width of the image.

Apart from src, all attributes are optional to use with the <img> tag. Height and width of the image can also be set with the height and width properties of CSS.

Let us create a web page to display images of famous Indian mathematicians with information about them:

Code

<html> <head>

<title>Famous Indian Mathematicians</title> <style> body { font-family: sans-serif; margin: 0; padding: 0; box-sizing: border-box; } h1 { background-color: lightgreen; color: green; text-align: center; padding: 1em; } .main {

display: flex; justify-content: space-around; flex-wrap: wrap; padding: 20px; }

.mathematician-card { border: 1px solid #ddd; border-radius: 8px; margin: 10px; padding: 15px; width: 300px; box-shadow: 0 4px 8px; }

.mathematician-card img { max-width: 100%; border-radius: 4px; }

</style> </head> <body>

<h1>Famous Indian Mathematicians</h1>

<div class = "main">

<div class="mathematician-card">

<img src="ramanujan.jpg" alt="Srinivasa Ramanujan">

<h2>Srinivasa Ramanujan</h2>

<p>Contributions: Number Theory, Mathematical Analysis</p> </div>

<div class="mathematician-card">

<img src="shakuntala-devi.jpg" alt="Shakuntala Devi">

<h2>Shakuntala Devi</h2>

<p>Contributions: Mental Calculation, Author of Mathematics Books</p> </div>

<div class="mathematician-card">

<img src="abhay-ashtekar.jpg" alt="Abhay Ashtekar">

<h2>Abhay Ashtekar</h2>

<p>Contributions: Quantum Gravity, Loop Quantum Gravity</p> </div> </div> </body> </html>

While creating this web page, place the images with the same names at the same location where the web page is saved.

Creating Links

The <a> tag is used to create links in HTML. A link, also known as hyperlink, is a text with the functionality to navigate you to some other web page of the website. The <a> tag is also known as anchor tag. This tag helps us to interlink several web pages of a website, even we can link other websites too. The attributes of the <a> tag are as follows:

Attribute Description

href

It takes the URL of the web page that will open when the link is clicked. download It allows a file to download when the link is clicked. It does not take any value.

We can arrange the links with the help of <nav> tag. The <nav> tag allows us to create a set of links.

Let us create a navigation bar with the help of <a> and <nav> tags.

Code

<html> <head> <title>Home Page</title> <style>

h1 { background-color: purple; color: white; text-align: center; padding: 1em; } nav { background-color: grey; overflow: hidden; }

Srinivasa Ramanujan Contribution: Number Theory, Mathematical Analysis
Shakuntala Devi Contribution: Mental Calulation, Author of Mathematics Books
Abhay Ashtekar Contribution: Quantum Gravity, Loop, Quantum Gravity

Code

nav a { float: left; display: block; color: white; text-align: center; padding: 14px 16px; text-decoration: none; }

nav a:hover { background-color: olive; color: white; } </style> </head> <body> <h1>Navigation</h1> <nav>

<a href="https://uolo.com/index.html">Home</a>

<a href="https://uolo.com/about-us.html">About Us</a>

<a href="https://uolo.com/request-demo.html">Contact</a> </nav> </body> </html> Output

When we hover over the links, the colour of the background of the link is changed.

1 Write one or two lines of code for the following: a To embed ‘flower.jpg’ image on a web page

b To create a link with the text ‘Flower’ for downloading ‘flower.jpg’ image

2 Write the CSS code to set the border of an image as 10px.

Adding Audio

HTML provides the <audio> tag to insert audio files to a web page. The <source> tag is used with the <audio> tag to specify the path of the audio file. There can be more than one <source> tag inside the <audio> tag. The browser chooses any one <source> tag at a time. Currently HTML supports .mp3, .wav, and .ogg audio formats.

Attributes of the <audio> tag are as follows:

Attribute Description

Autoplay It specifies that the audio will start playing as soon as the web is loaded in the web browser. Controls It specifies that audio controls should be displayed (such as a play/pause button etc).

Loop It specifies that the audio will start over again, every time it is completed.

Muted It specifies that the audio output should be muted.

Src It specifies the URL of the audio file.

Except src attribute, all attributes do not take any value. They are simply written in the opening tag.

Let’s create a web page to add audio file:

Code

<html> <head>

<title> Adding Audio </title> </head> <body>

<h1>Let’s Play Music</h1> <audio controls loop> <source src="music.mp3"> </audio> </body>

</html>

Output

The audio file is added to the web page with controls. You can pause the audio, increase/decrease the volume of sound, forward/reverse audio, etc.

Adding Video

Similar to audio, HTML allows us to add video to a web page using the <video> tag. The <source> tag is used with the <video> tag to specify the path of the video file. There can be more than one <source> tag inside the <video> tag. The browser chooses any one <source> tag at a time. Currently HTML supports .mp4, .webm, and .ogg video formats.

The attributes of the <video> tag are as follows:

Attribute

Description

autoplay It specifies that the video will start playing as soon as the web is loaded in the web browser. controls It specifies that video controls should be displayed (such as a play/pause button etc). height It specifies the height of the video player.

loop It specifies that the video will start over again, every time it is completed. muted It specifies that the audio output of the video should be muted. src It specifies the URL of the video file. width It specifies the width of the video player.

Except src, height, and width attributes, all attributes do not take any value. They are simply written in the opening tag.

Let’s create a web page to add a video:

Code

<html> <head> <style> video { border: 5px groove darkblue; padding: 30px; width: auto; height: auto; } </style> <title> Adding Video </title> </head> <body> <h1>Let’s Play Video</h1> <video controls> <source src="video.mp4"> </video> </body> </html>

Output

Let’s Play Video

The video is displayed on the web page. You can pause the video, increase/decrease the volume of sound, forward/reverse the video, view the video on full screen, etc.

Discuss!

What will happen if the specified audio/video is not found at the specified path?

1 Match the following questions.

CSS Sets the background colour of the HTML element.

background-color

Aligns the text horizontally within a box.

margin Allows us to change the look and feel of the web pages.

text-align Sets the space around the element itself.

2 Write the names of any three attributes of the <audio> tag.

Coding Challenge

Take photos of any four national symbols of India and create a web page to display them. The name of each national symbol should appear at the top of the photo. Photos should work as hyperlinks, and when the user clicks on any photo, a web page appears containing the larger photo of it.

Chapter Checkup

A Fill in the blanks.

Hints controls  audio  images  URL

1 The <img> tag allows us to add to the web page.

2 The href attribute in the <a> tag takes the of the web page that will open when the link is clicked.

3 The <audio> tag in HTML provides the functionality to insert files in a web page.

4 The controls attribute in the <video> tag specifies that video should be displayed.

B Tick () the correct option.

1 Which of the following attributes of the <img> tag is used to specify the path of the image? a alt b   src c width d   height

BHARAT

2 Which attribute of the <audio> tag specifies that the audio will start playing as soon as the web page is loaded? a controls b   loop c autoplay d   muted

3 The <a> tag is also known as: a image tag b   source tag c anchor tag d   video tag

4 Which of the following video formats is supported by HTML? a mp4 b   avi c mkv d   mov

C Who am I?

1 I am a tag used to create links in HTML.

2 I am a tag used to embed audio content in a web page.

3 I am a tag used to embed video content in a web page.

4 I am an attribute of the <audio> tag that specifies which audio controls should be displayed.

D Write T for True and F for False.

1 The alt attribute in the <img> tag specifies the URL of the image file.

2 The loop attribute in the <audio> tag specifies that the audio will start over again every time it is completed.

3 The <nav> tag is used to create a set of links in HTML.

4 The width and height attributes of the <img> tag are required attributes.

E Answer the following questions.

1 Explain the purpose of the alt attribute in the <img> tag.

2 How can you specify multiple audio sources in an <audio> tag?

3 What is the function of the <nav> tag in HTML?

4 Describe how the controls attribute in the <audio> and <video> tags enhances the user experience.

F Apply your learning.

1 Create an HTML snippet to display an image of the scientist Srinivasa Ramanujan with a width of 300 pixels and a height of 400 pixels.

2 Create a hyperlink that directs the user to Wikipedia’s main page when clicked.

3 Write HTML code to embed an audio file named "example.mp3" with controls enabled.

4 Write HTML code to display an image and a hyperlink to download the image file when clicked.

A. Fill in the blanks.

1 A is a way to connect computers using communication devices so that they can exchange data and resources with each other.

2 is the term used to describe the ethical and responsible use of technology.

3 is the name of a famous cryptocurrency.

4 The option offers a wide range of design elements, including photos, videos, stickers, shapes, and icons.

B. Tick () the correct option.

1 occurs when the same piece of data exists in multiple places.

a  Data redundancy

c  Data centralisation

a  Number

c  Date

b  Data inconsistency

d  Data recovery

2 data types are used to store a numeric value in a field column.

b  Character

d  Time

3 apps are programs you install on your phone to make whatever you want to do more fun.

a  Web

c  Mobile

C. Write T for True and F for False.

b  Desktop

d  None of these

1 Video editing involves arranging, modifying, and enhancing video clips to create a project.

2 Cyber ethics may conflict with people’s desire for being anonymous online.

3 A blockchain is controlled by a single central authority.

4 Google Drive is an example of a gaming app. Test Paper 1 (Based on Chapters 1 to 6)

D. Answer the following questions.

1 What does NIC mean?

2 What is a blockchain?

3 Describe the key role of a DBMS.

4 Mention some apps based on their usage.

E. Apply your learning.

1 Richa is confused between a hub and a switch. Help her by explaining each concept.

2 You receive a message that says that you have won a free vacation that can be accessed through a given link. Should you trust that message and click the link?

3 Anuj wants to know the difference between RDBMS and OODBMS. Explain it to him.

4 Kashika has installed an app on her phone that was not loaded in the phone already when she bought it. What type of app has she downloaded?

Test Paper 2

A. Fill in the blanks.

1 The rules that define the structure of a language are referred to as

2 A single-line string can be enclosed in either quotes or quotes.

3 A can hold multiple values in a single variable.

4 A is used to access and view web pages.

B. Tick () the correct option.

1 What is the name of the operator // in Python?

a  Exponentiation b  Modulus

c  Floor division d  Multiplication

2 is used to lower the text below the baseline.

a  Superscript b  Subscript

c  Emphasise d  Bold

3 Which of the following HTML elements is used to create a container for form elements?

a  <input> b  <form>

c  <label> d  <select>

4 specifies that the video will start over again, every time it is completed.

a  height b  loop

c  muted d  controls

C. Write T for True and F for False.

1 Operators are predefined symbols that perform operations on one or more operands.

2 The eval() function evaluates a string expression and returns the result.

3 The margin sets the space around the content of the element.

4 The <source> tag is used with the <audio> tag to specify the path of the audio file.

D. Answer the following questions.

1 What are the different types of conditional statements?

2 How can you access elements of a list?

3 What are some attributes that can control the behaviour of a form?

4 What are the attributes of an image tag?

E. Apply your learning.

1 Write a Python program that concatenates two strings, “Good” and “Morning”, and prints the result.

2 Write a code to create a tuple T with the given data: 7, ‘Alia’, 7, 4, ‘Jiya’

3 Write a program to calculate the area of an equilateral triangle with a side length of 10 cm.

Natural Language Processing

Natural Language Processing (NLP) is a domain of AI that enables computers to understand human language and generate appropriate responses when we interact with them.

It allows computers to talk to us in a way that feels natural to us.

Popular examples of NLP applications include Google Assistant, Siri, Alexa, Google Translate, etc.

Applications of Natural Language Processing

Natural Language Processing (NLP) has several key applications across different domains. Here are some of the common applications:

Language Translation: NLP is used extensively in translation applications like Google Translate, where it processes and translates text from one language to another, preserving context and meaning.

Sentiment Analysis: NLP techniques analyse text data to determine the sentiment or opinion expressed. This is used in social media monitoring, customer review analysis, and market research to gauge public opinion and sentiment towards products or brands.

Chatbots and Virtual Assistants: NLP powers chatbots and virtual assistants like Siri, Alexa, and chat interfaces on websites. These systems understand and generate human-like responses to users’ queries, providing information and assistance, and help in performing tasks.

Information Extraction: NLP is used to extract structured information from unstructured text sources such as documents, articles, and emails. This includes named entity recognition (identifying names of people, organisations, and locations) and relationship extraction (identifying connections between entities), which aids in tasks like summarisation and knowledge base construction.

About the Book

Uolo has introduced a comprehensive program, Hexa, for grades 1 to 8, to empower young minds with the knowledge and the skills they need to thrive in the digital age. From the basics of how computers function to the tools that shape our digital landscape, this series opens the door to a world of endless possibilities. This series will build a strong foundation, helping shape the next generation of digital citizens and innovators. It aims to demystify the world of computer science, making it accessible and engaging for young learners, while preparing them for future academic and professional pursuits in the field.

Special Features

• AI Annexures: To offer a basic understanding of specific domains of Artificial Intelligence.

• Discuss: A multi-faceted probing question, related to the concept, that arouses curiosity.

• Think and Tell: Analysis, reflection, and text-to-self connection based prompts for discussion in class.

• Did You Know? Interesting facts related to the application of a concept.

• Do It Yourself: Short exercises between the chapter to pause and assess comprehension.

• Chapter Checkup: Chapter-end practice exercises aligned to different levels of Bloom's Taxonomy.

About Uolo

Uolo partners with K-12 schools to bring technology-based learning programs. We believe pedagogy and technology must come together to deliver scalable learning experiences that generate measurable outcomes. Uolo is trusted by over 15,000+ schools across India, South East Asia, and the Middle East.

Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.