Professional Documents
Culture Documents
11 SM Ip
11 SM Ip
SUBJECT CO-ORDINATION BY
CONTENT TEAM
2 Introduction to Python 25
TOTAL - 70
What is Computer?
Computer is an advanced electronic device that takes raw data as input from the user and processes these data
under the control of set of instructions (called program) and gives the result (output) and saves output for the
future use. It can process both numerical and non-numerical (arithmetic and logical) calculations.
nput (Data):
Input is the raw information entered into a computer from the input devices. It is the collection of letters,
numbers, images etc.
Computer System
All of the components of a computer system can be summarized with the simple equations. COMPUTER
SYSTEM = HARDWARE + SOFTWARE+ USER
• Hardware = Internal Devices + Peripheral Devices
All physical parts of the computer (or everything that we can touch) are known as Hardware.
• Software = Programs
Software gives “intelligence” to the computer.
• USER = Person, who operates computer.
Generation of computer:
First Generation (1940-56):
The first generation computers used vaccum tubes & machine language was used for giving the instructions.
These computer were large in size & their programming was difficult task. The electricity consumption was
very high. Some computers of this generation are ENIAC, EDVAC, EDSAC & UNIVAC-1.
Second Generation(1956-63):
In 2nd generation computers, vaccum tubes were replaced by transistors. They required only 1/10 of power
required by tubes. This generation computers generated less heat & were reliable. The first operating system
developed in this generation.
The Third Generation(1964-71):
The 3rd generation computers replaced transistors with Integrated circuit known as chip. From Small scale
integrated circuits which had 10 transistors per chip, technology developed to MSI circuits with 100 transistors
per chip. These computers were smaller, faster & more reliable. High level languages invented in this
generation.
The fourth Generation(1972- present):
LSI & VLSI were used in this generation. As a result microprocessors came into existence. The computers
using this technology known to be Micro Computers. High capacity hard disk were invented. There is great
development in data communication.
The Fifth Generation (Present & Beyond):
Fifth generation computing devices, based on artificial intelligence, are still in development, though there are
some applications, such as voice recognition, that are being used today. The use of parallel processing and
superconductors is helping to make artificial intelligence a reality. Quantum computation and molecular and
nanotechnology will radically change the face of computers in years to come.
ARCHITECTURE OF COMPUTER
Input Devices: Those devices which help to enter data into computer system. Eg. Keyboad, Mouse,
Touchscreen, Barcode Reader, Scanner, MICR, OMR etc.
Output Devices: Those devices which help to display the processed information. Eg. Monitor, Printer, Plotter,
Projector
CENTRAL PROCESSING UNIT (CPU)
The main component to make a computer operate is the computer chip or microprocessor. This is referred to as
the Central Processing Unit (CPU) and is housed in the computer case. Together, they are also called the CPU.
It performs arithmetic and logic operations. The CPU (Central Processing Unit) is the device that interprets and
executes instructions.
Memory: It facilitates the remembrance power to computer system. It refers to the physical devices used to
store programs (sequences of instructions) or data (e.g. program state information) on a temporary or
permanent basis for use in a computer or other digital electronic device. The term primary memory is used for
the information in physical systems which are fast (i.e. RAM), as a distinction from secondary memory, which
are physical devices for program and data storage which are slow to access but offer higher memory capacity.
Primary memory stored on secondary memory is called virtual memory. Primary Memory can be categorized
as Volatile Memory & Non-Volatile Memory.
Volatile memory(RAM)
Volatile memory is computer memory that requires power to maintain the stored information. Most modern
semiconductor volatile memory is either Static RAM or dynamic RAM.
SRAM retains its contents as long as the power is connected and is easy to interface to but uses six transistors
per bit.
Non Volatile Memory (ROM)
Non-volatile memory is computer memory that can retain the stored information even when not powered.
Examples of non-volatile memory are flash memory and ROM/PROM/EPROM/EEPROM memory (used for
firmware such as boot programs).
Cache Memory:
Cache memory is random access memory (RAM) that a computer microprocessor can access more quickly
than it can access regular RAM. As the microprocessor processes data, it looks first in the cache memory and if
it finds the data there (from a previous reading of data), it does not have to do the more time-consuming
reading of data from larger memory. It is of two types- L1 cache is on the same chip as the microprocessor. L2
is usually a separate static RAM (SRAM) chip.
Secondary Memory:
A. Hard Disk (Local Disk)
B. Optical Disks: CD-R, CD-RW, DVD-R, DVD-RW
C. Pen Drive
D. Floppy Disks
F. Memory Cards
G. External Hard Disk
H. Blu Ray Disk
Units of Memory:
The smallest unit is bit, which mean either 0 or 1.
1 bit = 0 or 1
1 Byte = 8 bit
1 Nibble = 4 bit
1 Kilo Byte = 1024 Byte= 210 Byte
1 Mega Byte = 1024 KB= 210 KB
1 Gega Byte = 1024 MB= 210 MB
1 Tera Byte = 1024 GB= 210 GB
1 Peta Byte =1024 TB= 210 TB
1 Exa Byte =1024 PB= 210 PB
1 Zetta Byte = 1024 EB= 210 EB
1 Yotta Byte = 1024 ZB= 210 ZB
Software
Software, simply are the computer programs. The instructions given to the computer in the form of a program
is called Software. Software is the set of programs, which are used for different purposes. All the programs
used in computer to perform specific task is called Software.
Types of software
1. System software:
a) Operating System Software
DOS, Windows XP, Windows Vista, Unix/Linux, MAC/OS X etc.
b) Utility Software
Windows Explorer (File/Folder Management), Compression Tool, Anti-Virus Utilities, Disk Defragmentation,
Disk Clean, BackUp, WinZip, WinRAR etc…
c) Language Processors
Compiler, Interpreter and Assembler
2. Application software:
a) Package Software/General Purpose software
Ms. Office 2003, Ms. Office 2007, Macromedia (Dreamweaver, Flash, Freehand), Adobe (PageMaker,
PhotoShop)
● It is an easy to learn, playful language with powerful and distinctive object oriented language (OOP)
features.
● Python is a case-sensitive language (Uppercase and Lowercase letters are treated differently)
ADVANTAGES OF PYTHON
● Cross-platform language
LIMITATIONS of Python
● INTERACTIVE MODE
● SCRIPT MODE
Comments enclosed in triple (""") or triple apostrophe(' ' ') are called docstrings. We can use either triple-
apostrophe ar triple quotes(""") to write docstrings.
PYTHON CHARACTER SET
A set of valid characters recognized by python. Python uses the traditional ASCII character set. The latest
version recognizes the Unicode character set. The ASCII character set is a subset of the Unicode character set.
• Letters :- A-Z , a-z
• Digits:- 0-9
• Special symbols :- Special symbol available over keyboard
• White spaces:- blank space, tab, carriage return, new line form feed
• Other characters:- Unicode
TOKENS
Smallest individual unit in a program is called a token.
They are:
● Keywords
● Identifiers
● Literals
● Punctuators
● Operators
KEYWORDS: Keywords are the words that convey a special meaning to the language compiler/interpreter.
They are reserved for special purpose and must not be used as normal identifier names.
IDENTIFIERS: Identifiers are the fundamental building blocks of a program which are used to identify a
variable, function name, class name, module name or any object.
RULES OF WRITING AN IDENTIFIER
● Python is a case sensitive programming language that is uppercase letters (capital letters) and lowercase
letters (small letters) are treated differently.
eg. Marks and marks are two different identifiers in Python.
LITERALS:
Literals are data items that have a fixed value. Python allows several kind of literals:
• Numeric Literals:• Int (signed integers) :Positive or
Negative whole numbers with no decimal point Eg.
10, -96, 1234, 0
• Floating point/Real values :float represent real
numbers and are written with a decimal point dividing
the integer and fractional part.Eg 2.0,54.7,-12.0,-
0.075, .4
• Complex (complex numbers) : a+bj , where
String Literal
String literal is a sequence of characters
surrounded by quotes (single or double or
triple)
String literals can be written in either single
quote ‘ ’ or double quote “ ”
ESCAPE SEQUENCES / Non-graphic characters
PUNCTUATORS: Punctuators are certain symbols which are used in the programming languages to organize
programming sentence and structures, and indicate the rhythm and emphasis of expressions, statements,and
program structure.
‘ “ # \ ( ) [] {} @ , : . ` =
OPERATORS: Operators are tokens that trigger some computation/ action when applied to variables and other
objects in an expression.
UNARY OPERATORS:
Unary + , Unary - ,~ Bitwise complement , not logical negation
BINARY OPERATORS:
ARITHMETIC OPERATORS: +,-,*,/,%,//,**
AUGMENTED ASSIGNMENT OPERATORS: = , +=,-=,*=,/=,%=,//=,**=
RELATIONAL OPERATORS: >,<,>=,<=,==,!=
LOGICAL OPERATORS: and , or, not
MEMBERSHIP OPERATORS: in, not in
IDENTITY OPERATORS: is, is not
BITWISE OPERATORS: &(Bitwise AND), ^(Bitwise XOR), |(Bitwise OR)
DATA TYPES : The kind of data for handling the data used in a program code is the data type.
• Complex numbers are in the form of X+Yj , where X is a real part and Y is imaginary part. We know, in mathematic
NOTE:- The index (also called subscript) is the numbered position of a letter in the string.
In python, indices begin from 0,1,2,…. upto (length-1) in the forward direction and -1,-2,-
3,….. (-length) in the backward direction. where length is the length of the string.
DATA TYPE: working with STRING examples
Python allows to have two string types:
1) Single line strings (Basic strings) Text
enclosed in single quote ‘India’ or in double
quotes “Bharat” are normally single line
strings i.e. they must terminate in one line.
2) Multiline strings Text spread across multiple lines as one single string. Two ways of
treating multiline strings:-
i)By adding a backslash at the end of normal (ii) By typing the text in triple quotation or
single quote/double quote strings. apostrophe mark (No backslash needed at
the end of line)
VARIABLES
Variable is a name (Named Labels) given to
a memory location that refers to a value and
whose values can be used and processed
during program run. Python is a type infer
language that means you don't need to
specify the datatype of variable. Python
automatically get variable datatype
depending upon the value assigned to the
variable.
VARIABLE INTERNALS
id of an object (Identity) The id of an object is generally the memory location of the object. Although id is
implementation dependent but in most implementations it returns the memory location of the object. id() is a
built-in function that returns the id of an object.
Consider, the following code
INPUT through input() function and OUTPUT through print() statement
To take input from the user, input() function is used. input() function takes values in string data type. Syntax of
input Function
input()
To print/display the contents on the console(monitor screen), print() function is used.
Syntax of print Function
print(expression/variable)
sep and end parameters of print() function.
sep is the separator parameter which separates the strings given in print function. The default separator (in the
absence of sep) is a space ‘ ’.
end parameter denotes the end character to be given at the last of the print() functions data/content.
DYNAMIC TYPING
OPERATORS IN PYTHON
ARITHMETIC OPERATORS :
1) BINARY OPERATOR: requires two values(or operands) to calculate a final answer. A + B , where A
and B are Operands and + is the Operator.
2) UNARY OPERATOR : operators that act on one operand. -A , where A is the single Operand and - is
the Unary Operator
Unary +
If a=5 then +a means 5
If a=0 then +a means 0
If a=-4 then +a means -4
Unary –
If a=5 then –a means -5
If a=0 then –a means 0
If a=-4 then –a means 4
Augmented assignment operator
RELATIONAL OPERATORS
Relational Operators are used to compare the values of Left Hand Side (LHS) and Right Hand Side (RHS) of
the relational operator. Relational Operators always return Boolean value True or False
IDENTITY OPERATOR ( is , is not)
Is, is not are the operators which compares two objects in terms of their memory locations which is their
corresponding identity (id)
not operator
OPERATOR PRECEDENCE
EXPRESSION: It is referred as a valid combination of operators and atoms. An expression is composed of one
or more operations.
Types of Expressions
Debugging
Due to errors, a program may not execute or may generate wrong output. :
i) Syntax errors
Like any programming language, Python has rules that determine how a program is to be written. This is
called syntax. If any syntax error is present, the interpreter shows error message(s) and stops the execution
there.
ii) Logical errors
A logical error/bug (called semantic error) does not stop execution but the program behaves incorrectly and
produces undesired /wrong output. Since the program interprets successfully even when logical errors are
present in it, it is sometimes difficult to identify these errors.
iii) Runtime errors
A runtime error causes abnormal termination of program while it is executing. Runtime error is when the
statement is correct syntactically, but the interpreter can not execute it.
The process of identifying and removing logical errors and runtime errors is called debugging. We need
to debug a program so that is can run successfully and generate the desired output.
CONTROL STATEMENTS
TYPES OF STATEMENTS in Python
Statements are the instructions given to computer to perform any kind of action viz. data movements,
making decision, repeating actions
Statements form the smallest executable unit within a program.
1) Empty statement/ null operation statement –
Statement which does nothing. It is as follows: e.g. pass
2) Simple statement (Single statement) –
Any single executable statement is a simple statement.
a=2
print(a)
3) Compound statement –
A group of statements executed as a unit is a compound statement. A compound statement has:
(i)a header line which begins with a keyword and ends with a colon.
(ii) a body consisting of one or more Python statements, each indented inside the header line. All the
statements are at the same level of indentation.
FLOW OF CONTROL
In a program, statement may be executed sequentially, selectively or iteratively.
Every program language provides or supports the following Types of constructs :
1) Sequence
2) Selection/Conditional/Decisional
🡪if, if-else, if-elif , nested-if
3) Iteration/Looping
🡪 for loop,while loop
1. SEQUENCE CONSTRUCT / SEQUENTIAL FLOW OF CONTROL
• Sequence construct means statement are executed
sequentially.
• It represents the default flow of statements.
• Every program begins with the first statement of the
program. When the final statement of the program is
executed, the program is done.
2. SELECTION / DECISIONAL / CONDITIONAL CONSTRUCT or SELECTION FLOW OF
CONTROL
The Selection construct means the execution of
statement(s) depending upon a condition-test.
• If a condition evaluates to true, a course-of-action(a set
of statements) is followed otherwise another course-of-
action (a different set of statements).
• It helps in making decision about which set-of-
statements is to be executed.
There are three types of decision making statement.
1. if statements
If statement must be provided with a condition.
If the condition is True, the indented body / block gets executed.
If the condition is False, then the control doesn’t execute the if body/block
2. if-else statements
3. Nested if-else statement
CHAPTER 7
FLOW OF CONTROL
Control statements are used to control the flow of execution depending upon the specified condition/logic.
There are three types of control statements.
1. Decision Making Statements
2. Iteration Statements (Loops)
3. Jump Statements (break, continue, pass)
Decision Making Statement Decision making statement used to control the flow of execution of program
depending upon condition. There are three types of decision-making statement.
1. if statements
2. if-else statements
3. Nested if-else statement
Decision Making Statement
1. if statements
An if statement is a programming conditional statement that, if proved true, performs a function or
displays information.
1. if statements
Using logical operator in if statement
x=1
y=2
if(x==1 and y==2):
print(‘condition matching the criteria')
Output :-
condition matching the criteria
-----------------------------------------------------------
a=100
if not(a == 20):
print('a is not equal to 20')
Output :-
a is not equal to 20
2. if-else Statements
If-else statement executes some code if the test expression is true (nonzero) and some
1. While Loop
It is used to execute a block of statement as long as a given condition is true. And when the condition become
false, the control will come out of the loop. The condition is checked every time at the beginning of the loop.
Syntax
while (condition):
statement
[statements]
e.g.
x=1
while (x <= 4):
print(x)
x=x+1
2. For Loop
The for statement is used to iterate over a range of values or a sequence. The loop is executed for each item in
the range. The values can be numeric, string, list, or tuple. When all the items in the range are exhausted, the
statements within loop are not executed and Python interpreter starts executing the statements immediately
following the for loop. While using for loop, we should know in advance the number of times the loop will
execute.
for <control-variable> in <sequence/items in range>:
<statements inside body of the loop>
Program to print even numbers in a given sequence using for loop.
numbers = [1,2,3,4,5,6,7,8,9,10]
for num in numbers:
if (num % 2) == 0:
print(num,'is an even Number')
Output:
2 is an even Number
4 is an even Number
6 is an even Number
8 is an even Number
10 is an even Number
3. Jump Statements
Jump statements are used to transfer the program's control from one location to another. Means these are used
to alter the flow of a loop like - to skip a part of a loop or terminate a loop.
There are three types of jump statements used in python.
1.break 2.continue 3.pass
2.continue :- It is used to skip all the remaining statements in the loop and move controls back to the top of the
loop.
Output
n
t
The end
3. pass Statement :-This statement does nothing. It can be used when a statement is required syntactically but
the program requires no action.
Use in loop
while True:
pass # Busy-wait for keyboard interrupt (Ctrl+C)
Chapter 8
Lists
It is a collections of items and each item has its own index value. Index of first item is 0 and the last item is n-
1.Here n is number of items in a list.
Indexing of list
Creating a list
Lists are enclosed in square brackets [ ] and each item is
separated by a comma.
• LONG LIST
L = [1,2,3,44,55,66,77,88,99,4,3,5,6,7,88,100,300
12,13,14,56,78]
• NESTED LIST
L = [1,2,4,[100,200,300], 20]
The above code will create List L with 5 elements because it will
count [100,200,300] as one element. Now L[3] is list of 3
elements
To print if we write : L[1] it will display 2 and to print 200 we
have to write L[3][1] i.e. of 3rd index print 2nd value
Initializing a list
Passing value in list while declaring list is initializing of a list
e.g.
list1 = [‘English', ‘Hindi', 1997, 2000]
list2 = [11, 22, 33, 44, 55 ]
list3 = ["a", "b", "c", "d"]
Joining List
Joining the 2 list is very easy, we can use (+) to join 2 or
more list
Fruits=[“apple”,”mango”,”grapes”]
Veg=[“spinach”,”carrot”,”potato”]
Fveg = Fruits + Veg
Fveg # [“apple”,”mango”,”grapes”,
“spinach”,”carrot”,”potato”]
Note: you can only add list with another list not
with int, float, complex, or string type.
Slicing of A List
List elements can be accessed in subparts.
e.g.
list =['I','N','D','I','A']
print(list[0:3])
print(list[3:])
print(list[:])
Output
['I', 'N', 'D']
['I', 'A']
['I', 'N', 'D', 'I', 'A']
Append Method
append() method is used to add an Item to a List.
e.g.
list=[1,2]
print('list before append', list)
list.append(3)
print('list after append', list)
Output
('list before append', [1, 2])
('list after append', [1, 2, 3])
Extend() method
This function is also used for adding multiple items. With extend we can add only “list” to any list. Single
value cannot be added using extend().
For example
>>> subject1=["physics","chemistry","cs"]
>>> subject2=["english","maths"]
>>> subject1.extend(subject2)
>>> subject1
['physics', 'chemistry', 'cs', 'english', 'maths']
Note: here subject1 will add the contents of subject2 in it without
effecting subject2
append() allows to add only 1 items to a list, extend() can add multiple
items to a list.
>>> m1=[1,2,3,4]
>>> m2=[100,200]
>>> m1.append(5)
>>> m1
[1, 2, 3, 4, 5]
>>> m1.append(6,7)
>>> L1.remove(5)
>>> L1
[1, 3, 7, 9, 11, 3, 7]
>>> L1.remove(3)
>>> L1
[1, 7, 9, 11, 3, 7]
>>> L1.remove(10)
Traceback (most recent call last):
File "<pyshell#26>", line 1, in <module>
L1.remove(10)
Value Error: list.remove(x): x not in list
Important methods and functions of List
Index Method
This function is used to get the index of first matched item from the list. It returns index value of item to
search.
For example
>>> L1=[10,20,30,40,50,20]
>>> L1.index(20)
1 # item first matched at index 1
Note: if we pass any element which is not in the list then index
function will return an error: Value Error: n is not in the list
>>> L1.index(100) #Error
Insert Method
This function is used to add elements to list like append() and extend(). However both append() and extend()
insert the element at the end of the list. But insert() allows us to add new elements anywhere in the list i.e. at
position of our choice.
ListObject.insert(Position,item)
>>> L1=[10,20,30,40,50]
>>> L1
[10, 20, 30, 40, 50]
>>> L1.insert(3,35)
>>> L1
Clear Method
This function removes all the items from the list and the list becomes empty list.
List.clear()
>>> L1=[10,20,30,40,50]
>>> L1.clear()
>>> L1
[]
Note: unlike ‘del listname’ statement, clear( ) will removes only the elements and not the list. After clear( ) the
list object still exists as an empty list.
Count Method
This function returns the count of the item that you passed as an argument. If the given item is not in the list, it
returns zero.
>>> L1=[10,20,30,40,20,30,100]
>>> L1.count(20)
2
>>> L1.count(40)
1
>>> L1.count(11)
0
Reverse method
This function reverses the items in the list. This is done i place i.e. It wil not create a new list . The syntax to
use reverse() is:
>>> L1=[10,20,30,40,20,30,100]
>>> L1.reverse()
>>> L1
[100, 30, 20, 40, 30, 20, 10]
>>> L2=[11,22,33]
>>> L3=L2.reverse() #it will not return any value
>>> L3 # empty
[]
Sort Method
This function sorts the items of the list, by default increasing order. This is done «in place» i.e. It does not
create new list.
>>> L1=[10,1,7,20,8,9,2]
>>> L1.sort()
>>> L1
[1, 2, 7, 8, 9, 10, 20]
>>> L2=['g','e','a','c','b','d']
>>> L2.sort()
>>> L2
['a', 'b', 'c', 'd', 'e', 'g']
>>> L1.sort(reverse=True) # for descending order
>>>L1
[20, 10, 9, 8, 7, 2, 1]
Chapter 9
Dictionaries
Dictionary in Python holds data items in key-value pairs and Items are enclosed in curly brackets { }. dictionaries permit
faster access to data. Every key is separated from its value using a colon (:) sign. The key value pairs of a dictionary can
be accessed using the key. Keys are usually of string type and their values can be of any data type. In order to access
any value in the dictionary, we have to specify its key in square brackets [ ].
#create a dictionary
>>> print(dict1)
>>> print(dict1['Price(kg)'])
Creating a dictionary
Dict1 = {} # empty dictionary
DaysInMonth={"Jan":31,"Feb":28,"Mar":31,"Apr":31, "May":31,"Jun":30,"Jul":31,"Aug":31
"Sep":30,"Oct":31,"Nov":30,"Dec":31}
Accessing elements of Dictionary
To access Dictionary elements we need the “key” >>>mydict={'empno':1,'name':'Shivam','dept':'sales','salary':25000}
>>> mydict['salary']
25000
Traversing a Dictionary
Python allows to apply “for” loop to traverse every element of dictionary based on their “key”. For loop will get every
key of dictionary and we can access every element based on their key.
mydict={'empno':1,'name':'Shivam','dept':'sales','salary':25000}
print(key,'=',mydict[key])
Popitem() : it will remove the last dictionary item are return key,value.
max() : this function return highest value in dictionary, this will work only if all the values in dictionary is of
numeric type
min() : this function return highest value in dictionary, this will work only if all the values in dictionary is of
numeric type.
sorted() : this function is used to sort the key or value of dictionary in either ascending or descending order. By
default it will sort the keys.
Program to create dictionary for storing employee names and salary and access them
COMPUTER SYSTEM
(a) Figure
Hide Answer
Hide Answer
Hide Answer
Hide Answer
Hide Answer
Hide Answer
(a) (+ , – , * , / )
Answer
Q.8 Personal computers use no. of chips mounted on a main circuit board. The main board is known as-
(a) Chip
(b) Motherboard
(c) Masterboard
(d) Fastboard
Hide Answer
(b) Motherboard
Q.9 Which of the following are the sub units that make the CPU?
(a) ALU
Hide Answer
Q.10 Which units in computer are capable of performing arithmetic & Logical operations?
(a) Memory
(b) ALU
(c) Control Unit
Hide Answer
(b) ALU
(a) Printer
(b) Keyboard
(c) Mouse
Show Answer
Hide Answer
Q.13 What is the responsibility of the logical unit in the CPU of a computer?
Hide Answer
(a) Keyboard
(b) Printer
(c) Mouse
(d) Scanner
Hide Answer
(c) Mouse
(a) Keyboard
(b) Printer
(c) Monitor
(d) Speaker
Answer: Keyboard
(a) Keyboard
(b) Mouse
(c) OMR
(d) Speaker
Answer
(d) Speaker
Q.17 When we work on any document on PC, it is stored temporarily in______ memory
(a) RAM
(b) ROM
(c) CPU
(d) CD-ROM
Answer a RAM
(a) Megabyte
(b) Bit
(c) Byte
Answer
INPUT UNIT :
Input unit has following function:
Input unit takes a data instruction from the user for further processing.
We know that computer understand machine language. Input unit converts the data to the machine language
(machine readable form)
They are various types of input devices are available like keyboard, scanner, mouse, touch screen devices, etc.
CENTRAL PROCESSING UNIT:
CPU i.e. Central processing unit is responsible for performing all tasks of computer. CPU is like a heart of
computer.CPU consists of 3 units:
Primary memory
Control unit
Arithmetic logic unit
ALU:
Arithmetic and logical unit responsible for performing all arithmetic operation like addition, subtraction,
multiplication and division .It also responsible for conduct merging, sorting like all sorting techniques .All the
calculations of the data perform by ALU.
Control unit:
Control unit is used to control the signals. Control unit receives the instruction, data, and information from
input devices and converts it into control signals.
Primary memory:
There are two types of primary memory
RAM
ROM
RAM:
RAM means random access memory.
It is a volatile storage.
The data stored in RAM temporary.
RAM stores the data of active task.
ROM :
ROM mans read only memory.
The data stored in ROM is permanent.
It cannot be erased during the power cut off.
It is a non volatile memory.
OUTPUT UNIT:
An output device is one of the components of computer. output devices is responsible to convert machine code
into the human readable form. Monitor, printer etc. are output devices. The output given by the computer can
be in any type like text, graphics, audio, video etc
1.) Name the software required to make a computer functional. Write down its two primary services?
Ans: To make a computer functional operating system is required. The two services of primary services:
1) Operating system provides services for building and running the application.
2) Operating system provide user interface to the user for enable interaction between computer and user.
2.) How does the computer understand a program written in high level language?
Ans: Computer understands only machine level language (0 and 1). High level language is a simple English
type language written in some symmetric format. To convert high level language into machine language there
is need of compiler which can be understood by computer.
3.) Why is the execution time of the machine code less than that of source code?
Ans: We know that computer readable language is machine language. So there is no need to convert machine
language whereas Source codes are written in high level language. So there is need to convert it into machine
language first. Hence, the execution time of machine language is less than source code.
9.) Differentiate between proprietary software and freeware software. Name two software for each type.
Ans:
14.) Identify the category (system, application, programming tool) of the following software:
a) Compiler
b) Assembler
c) Ubuntu
d) Text editor
Ans:
a) Compiler – Programming tool
b) Assembler – Programming tool
c) Ubuntu – System
d) Text editor – Application
TOPIC – 1
SOFTWARE
Question 1:
Name any two popular word processing software.
Answer:
Two popular word processing software are :
1. OO-writer
2. MS-word
Question 2:
Expand OS.
Answer:
OS stands for Operating System.
Question 3:
Name the categories in which the software are classified.
Answer:
Software are classified into following two categories :
1. System software
2. Application software
Question 4:
Name the various categories of system software.
Answer:
System software are divided into following two categories :
1. Operating system
2. Language processor
Question 5:
Expand DBMS.
Answer:
DBMS stands for Data Base Management System.
Question 6:
What is the full form of DTP
Answer:
DTP stands for Desk Top Publishing.
Question 7:
Expand IOCS.
Answer:
IOCS stands for Input-Output Control System.
Question 8:
Write the name of the part of machine level instruction, which tells the central processor what has to be done.
Answer:
Operation code.
Question 9:
A system program that combines the separately compiled modules of a program into a form suitable for
execution.
Answer:
Linking loader.
Question 10:
Which system software does the job of merging the records from two files into one ?
Answer:
Utility program.
Question 11:
A computer cannot “boot” if it does not have the____.
Answer:
Operating system.
Question 12:
Write the name of the system program that sets up an executable program in the main memory ready for
execution.
Answer:
Loader.
Question 11:
What do you mean by bug ?
Answer:
A bug is logical error in a program.
Question 1:
Define Software. Give its types.
Answer:
Software represents the set of programs that controls the operation of a computer system and utilizes hardware.
Software are of two types :
1. System Software
2. Application Software.
Question 2:
What is system software ? What are its components ?
Answer:
System Software : The software which controls the internal operations of the computer and creates an interface
with software and hardware is known as system software.
The system softwares can be divided into two categories :
1. Operating system
2. Language processors
Question 3:
What do you mean by operating system ?
Answer:
Operating System is a software program which manages the hardware and software resources and links them.
It creates an interface between hardware and software. It is a bridge between the hardware and the software.
Question 4:
What do you mean by graphics software ?
Answer:
Graphics software is the application software which can manipulate images, known as graphics software. The
graphics software can incorporate images, text, sound, animation and video sequence.
Question 5:
Name the various categories of application software.
Answer:
Application software can be divided into following three categories :
1. Packages
2. Utilities
3. Customized Software
Question 6:
Name the major categories of packages.
Answer:
Following are the major categories of packages :
Question 7:
Explain utility program.
Answer:
A program that performs a specific task related to the management of computer functions, resources, or files as
password protection, memory management, virus protection, and file compression.
Question 8:
Give examples of utility programs.
Answer:
some examples of utility programs are :
1. Virus scanners
2. Disk defragmenters
3. Encryption utilities
4. Backup software
Question 1:
Explain operating system and utility system software.
Answer:
Operating systems are essential for running a computer. However, as part of the operating system, there are
often other programs which are not essential to the running of the computer. These are known as utilities. If
they were not there, they would not affect the working of the computer. 3
Question 2:
How does the application software and operating system work together ?
Answer:
When we use a program, it sends commands to the computer. But the computer is just a heap of nuts and bolts
and computer chips. It can’t understand the commands by itself. So the operating system catches the
commands and tells the computer what you want it to do.
Question 3:
What are open source software ? Give its examples.
Answer:
Open source software is that computer software whose source code is made available with a license in which
the copyright holder provides the rights to read, change and distribute the software for any purpose. For
example : Linux, Unix etc.
Question 4:
What are the criteria of software development industry to consider a software as open source software ?
Answer:
For a software to be considered as open source software it should meet certain criteria, they are :
Question 5:
What are Freeware ? Give its examples.
Answer:
It generally refers to the software which re available for use at no cost or for an optional fee to avail all the
functions of the software. For example : WordPad, Paint, Notepad etc.
Question 6:
What are Shareware ? Give its examples.
Answer:
It is that software which is made available with
a right to redistribute copies. It is also known as “Try Before You Buy.” For example : wondershare,
Kaspersky antivirus etc.
Question 7:
What are Proprietary Software ? Give its examples.
Answer:
It is a software which is owned by an individual or a company. Their source code is always kept secret. For
example : Microsoft windows, adobe flash player etc.
Question 1:
What are the functions of a file system ?
Answer:
The major functions of a file system are given below :
1. It provides file naming freedom to the users and permits controlled sharing of files.
2. It provides long and short term storage of files.
3. It provides security against loss of information due to system failure.
4. It also provides file recovery modules, if required. [1 mark for each point]
Question 2:
Define following with examples :
1. Word processing packages
2. Spreadsheet packages
3. DBMS packages.
1. Word processing packages : It is a software package that processes textual matter created to a right to
redistribute copies. It is also known as “Try Before You Buy.” For example : wondershare, Kaspersky
antivirus etc.
organize an error free document. Some popular word processing packages are Wordstar, MS- WORD,
Word Perfect, Softword etc.
2. Spreadsheets packages : It is a software package that accepts data in a tabular form i.e., in rows and
columns and allows the user to manipulate, calculate, edit and analyze the data in the required manner.
Some popular spreadsheet packages are, LOTUS 1-2-3, MS-Excel and Quattro Pro.
3. Data base management software (DBMS)
packages : A DBMS package is a software package which manages the different database with home
bulk information in the form of data. It can manage, add, delete and modify the database. Examples :
FoxPro, FOXBase, SYBase, Dbase IV & MS-Access etc.
TOPIC-2
Operating System(OS)
Question 1:
Expand the term ROM-BIOS.
Answer:
ROM-BIOS stands for Read Only Memory-Basic Input Output System.
Question 2:
What do you mean by POST ?
Answer:
POST—Power On Self-Test.
Question 3:
What are executable files ?
Answer:
Executable files are those files that can directly be executed by the command processor. The files with
extension, exe or com are known as executable files.
Question 4:
Expand GUI.
Answer:
GUI stands for Graphical User Interface.
Question 5:
Why GUI is used ?
Answer:
GUI is used as an interaction between software and the user.
Question 6:
Does MS-Windows provides GUI ?
Answer:
Yes, MS-Windows provides GUI.
Question 7:
What is MS-DOS ?
Answer:
MS-DOS stands for Microsoft Disk Operating System. It is a Command User Interface (CUI), single user
multi-tasking operating system.
Question 8:
What is considered as a file manager in Windows 98?
Answer:
Windows Explorer is considered as a file manager in Windows 98.
Question 9:
What happens to the files when they are deleted ?
Answer:
When files are deleted, they move to Recycle Bin.
Question 1:
Define Operating system. Give the names of any three operating systems.
Answer:
Operating System is defined as a collection of programs that coordinates the operations of computer hardware
and software. It acts as a bridge or interface between man and machine. Operating system is a system software
which is mandatory for all computer systems to operate. It is a general purpose software. Some commonly
used operating systems are Windows, BOSS etc.
Question 2:
Explain I/O System Management
Answer:
I/O system hides the peculiarities of specific hardware devices from the user. Only the device driver knows the
peculiarities of the specific device to which it is assigned.
Question 3:
Name some of the icons available on windows.
Answer:
Some of the icons available on windows are:
1. Application icons
2. Shortcut icons
3. Documents icons
4. Disk-Drive icons.
Question 4:
What is the difference between MS-Windows and MS-DOS ?
Answer:
MS-WINDOWS is a GUI (Graphic User Interface), single user multitasking operating system.
Whereas, MS-DOS is a CUI (Command User Interface) single user multi-tasking operating system.
MS-Windows is more user friendly in comparison to MS-DOS.
Question 1:
Write the objectives of operating system.
Answer:
(a) To hide details of hardware by creating abstraction : An abstraction is software that hides lower level
details and provides a set of higher- level functions.
(b) To allocate resources to processes (manage resources) : An operating system controls how processes (the
active agents) may access resources (passive entities).
(c) Provide a pleasant and effective user interface : The user interacts with the operating systems through the
user interface and usually interested in the “look and feel” of the operating system.
Question 2:
Write the general goals of scheduling.
Answer:
(a) Fairness
(b) Policy enforcement
(c) Efficiency
(d) Response time
(e) Turnaround time
(f) Throughput
Question 3:
Explain real-time operating system.
Or
Write a short note on real-time operating system.
Or
Write a short note on RTOS.
Answer:
A real-time operating system (RTOS) is an i operating system that guarantees a certain capability within a
specified time constraint. For example, an operating system might be designed to ensure that a certain object
was available for a robot on an assembly line.
Question 4:
Explain multi-user operating system.
Or
Write a short note on multi user operating system.
Answer:
It is the type of operating system that allows many users to take the advantage of computer’s resources
simultaneously.
For example : UNIX, VMS etc.
Question 5:
Explain single user operating system.
Or
Write a short note on single user operating system.
Answer:As it is clear from the name single user operating system is designed for one user to effectively use a
computer at a time.
For example : Windows 2007, Windows 8 etc.
Question 6:
What is an operating system and how are they classified on the basis of interaction ?
Answer:
Operating System is defined as a collection of programs that coordinates the operations of computer hardware
and software. It acts as a
bridge or interface between man and machine. Operating system is a system software which is mandatory for
all computer systems to operate. It is a general purpose software. On the basis of interaction, operating systems
are divided in two types :
Question 7:
Give any three advantages of windows.
Answer:
The three advantages of windows are as follows :
1. Microsoft has made several advancements and changes that have made it much easier to use operating
system, and although arguably it may not be the easiest operating system, it is still easier than Linux.
2. Because of the large amount of Microsoft windows users, there is a much larger selection of available
software programs, utilities, and games for windows.
3. Microsoft windows includes its own help section, has vast amount of available online documentation
and help, as well as books on each of the versions of windows.
Question 8:
Give three disadvantages of Windows.
Answer:
The three disadvantages of windows are as follows :
1. Microsoft Windows can run between $ 50.00 – $150.00 US dollars per each license copy.
2. Although Microsoft Windows has made great improvements in reliability over the last few versions of
Windows, it still cannot match the reliability of Linux.
3. Although Windows does have software programs, utilities, and games for free, the majority of the
programs will cost anywhere between $20.00 – $200.00+ US dollars per copy.
Question 9:
Explain Bharat Operating System Solutions.
Answer:
Bharat Operating System Solutions (BOSS) is a free and open source computer operating system developed by
the National Resource Centre for Free/Open Source Software (NRCFOSS) of India. This software is also
known by the acronym BOSS GNU/Linux or simply BOSS Linux. The latest version of this operating system,
BOSS GNU/Linux Version 5.0, was released in August 2013. This software package has been described as
“India’s own PC operating system” the most meaningful product to come out of the Indian software industry in
decades and a work that a government department has done The software has also been endorsed by the
Government of India for adoption and implementation on a national scale.
Question 10:
Explain Android.
Answer:
1. Android is a Linux-based operating system for mobile devices such as smartphones and tablet
computers. It is developed by the Open Handset Alliance, led by Google, and other companies.
2. Google purchased the initial developer of the software, Android Inc., in 2005. The unveiling of the
Android distribution in 2007 was announced with the founding of the Open Handset Alliance, a
consortium of 86 hardware, software, and telecommunication companies devoted to advancing open
standards for mobile devices. Google releases the Android code as open-source, under the Apache
License. The Android Open Source Project (AOSP) is tasked with the maintenance and further
development of Android.
3. The first phone of lun on the Android OS was the HTC Dream which was launched on 22nd October
2008.
Question 1:
Explain process management.
Or
What do you mean by processor management of operating system ?
Answer:
The operating system manages many kinds of activities ranging from user programs to system programs like
printer spooler, name servers, file server etc. Each of these activities is encapsulated in a process. A process
includes the complete execution context (code, data, PC, registers, OS resources in use etc.).
The five major activities of an operating system in regard to processor management are :
1. Keep track of which part of memory are currently being used and by whom.
2. Decide which process are loaded into the memory when memory space becomes available.
3. Allocate and deallocate memory spaces as needed.
FLOW OF CONTROL
QUESTIONS
1.Find the output of the following program segments:
for i in range(20,30,2):
print(i)
The output will be:
20
22
24
26
28
The output is 12
3. Give output for Python program to show the working of range() function
print(range(15))
print(list(range(15)))
print(list(range(4, 9)))
print(list(range(5, 25, 4)))
output:-
range(0, 15)
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
[4, 5, 6, 7, 8]
[5, 9, 13, 17, 21]
output:-
i is greater than 15
i'm in else Block
i'm not in if and not in else Block
output:-
i is 20
Lists
Case study based Questions
Q.1. Attempt any 5 questions from this section. Choose the best possible option.
Suppose a list is given as
Example = [‘h’,’e’,’l’,’l’,’o’]
a) [‘h’,’e’,’l’,’l’,’o’]
b) [’e’,’l’,’l’,’o’]
c) [’l’,’l’,’o’]
d) [’l’, ’o’]
Which function will delete all the elements of the list ?
a) del
b) drop()
c) clear()
d) remove()
What will be the output for the following code:
print(Example+”2”)
a) [‘h’,’e’,’l’,’l’,’o’,’2’]
b) [‘h’,’e’,’l’,’l’,’o’,2]
c) [‘h’,’e’,’l’,’l’,’o’‘h’,’e’,’l’,’l’,’o’]
d) None of these
Q.2. Lalit is a game programmer and he is designing a game where he has to use different python
functions as much as possible. Apart from other things, following functionalities are to be
implemented in the game.
(1) He is simulating a dice where random number generation is required.
2) Since the program becomes too lengthy, Lalit wants a separate section where he can store all the functions
used in the game program.
Lalit is feeling difficulty in implementing the above functionalities. Help him by giving answers following
questions:
b) randomise
c) randint
d) math
MCQs
1. What is the output of the following list operation
aList = [10, 20, 30, 40, 50, 60, 70, 80]
print(aList[2:5])
print(aList[:4])
print(aList[3:])
a) [20, 30, 40, 50]
[10, 20, 30, 40]
[30, 40, 50, 60, 70, 80]
b) [30, 40, 50]
[10, 20, 30, 40]
[40, 50, 60, 70, 80]
sampleList.append(60)
print(sampleList)
a) [10, 20, 30, 40, 50, 60]
[10, 20, 30, 40, 50, 60]
b) [10, 20, 30, 40, 50, 60]
[10, 20, 30, 40, 50, 60, 60]
8. What is the output of the following code?
a) []
b) list index out of range.
c) [10, 20]
a)False
b) True
2. What is the output of the following code
student = {
"name": "Emma",
"class": 9,
"marks": 75
}
a) del student
b) del student[0:2]
c) student.clear()
4. Select correct ways to create an empty dictionary
a) sampleDict = {}
b) sampleDict = dict()
c) sampleDict = dict{}
5. Items are accessed by their position in a dictionary and All the keys in a dictionary must be of the same type.
a) True
b) False
6. Select all correct ways to copy a dictionary in Python
a) dict2 = dict1.copy()
b) dict2 = dict(dict1)
c) dict2 = dict1
7. What is the output of the following dictionary operation
a) True
b) False
10. Select the correct way to access the value of a history subject
sampleDict = {
"class":{
"student":{
"name":"Mike",
"marks":{
"physics":70,
"history":80
}
}
}
}
a) sampleDict['class']['student']['marks']['history']
b) sampleDict['class']['student']['marks'][1]
c) sampleDict['class'][0]['marks']['history']
11. Select the correct ways to get the value of marks key.
student = {
"name": "Emma",
"class": 9,
"marks": 75
}
a) m = student.get(2)
b) m = student.get('marks')
c) m = student[2])
d) m = student['marks'])
12. What is the output of the following dictionary operation
a)KeyError: ‘age’
b)None
13. What is the output of the following
sampleDict = dict([
('first', 1),
('second', 2),
('third', 3)
])
print(sampleDict)
student = {
"name": "Emma",
"class": 9,
"marks": 75
}
a) student.pop("marks")
b) del student["marks"]
c) student.remove("marks")
d) student.popitem("marks")
EMERGING TRENDS
Computers have been around for quite some time now. New technologies and initiatives
emerge with each passing day. In order to understand the existing technologies and have a
better view of the developments around us, we must keep an eye on the emerging trends.
Many new technologies are introduced almost every day. Some of these do not succeed and
fade away over time. Some of these new technologies prosper and persist over time, gaining
attention from users. Emerging trends are the state-of-the-art technologies, which gain
popularity and set a new trend among users. In this chapter, we will learn about some
emerging trends that will make a huge impact (in the future) on digital economy and
interaction in digital societies.
ARTIFICIAL INTELLIGENCE (AI)
Have you ever wondered how maps in your smartphone are able to guide you to take the
fastest route to your destination by analysing real time data, such as traffic congestion? On
uploading a photo on a social networking site, has it ever happened that your friends in the
photograph were recognised and tagged automatically? These are some of the examples of
application of Artificial Intelligence. The intelligent digital personal assistants like Siri,
Google Now, Cortana, Alexa are all powered by AI. Artificial Intelligence endeavours to
simulate the natural intelligence of human beings into machines, thus making them behave
intelligently. An intelligent machine is supposed to imitate some of the cognitive functions of
humans like learning, decision- making and problem solving. In order to make machines
perform tasks with minimum human intervention, they are programmed to create a
knowledge base and make decisions based on it. AI system can also learn from past
experiences or outcomes to make new decisions.
Machine Learning
BIG DATA
With technology making an inroad into almost every sphere of our lives, data is being
produced at a colossal rate. Today, there are over a billion Internet users, and a majority
of the world’s web traffic is coming from smartphones. Figure 2.8 shows that at the
current pace, around
2.5 quintillion bytes of data are created each day, and the pace is increasing with the
continuous evolution of the Internet of Things (IoT). This results in the generation of data sets
of enormous volume and complexity called Big Data. Such data cannot be processed and
analysed using traditional data processing tools as the data is not only voluminous,
but also unstructured like our posts, instant messages and chats, photographs that we
share through various sites, our tweets, blog articles, news items, opinion polls and their
comments, audio/video chats, etc. Big data not only represents voluminous data, it also
involves various challenges like integration, storage, analysis, searching, processing,
transfer, querying and visualisation of such data. Big data sometimes hold rich information
and knowledge which is of high business value, and therefore there is a keen effort in
developing software and methods to process and analyse big data.
Characteristics of Big Data
Big data exhibits following five characteristics shown in Figure 2.9, that distinguish it
from traditional data.
(A) Volume
The most prominent characteristic of big data is its enormous size. If a particular data set
is of such large size that it is difficult to process it with traditional DBMS tools, it can be
termed as big data.
(B) Velocity
It represents the rate at which the data under consideration is being generated and
stored. Big data has an exponentially higher rate of generation than traditional data sets.
(C) Variety
It asserts that a data set has varied data, such as structured, semi-structured and
unstructured data. Some examples are text, images, videos, web pages and so on.
(D) Veracity
Big data can be sometimes inconsistent, biased, noisy or there can be abnormality in the
data or issues with the data collection methods. Veracity refers to the trustworthiness
of the data because processing such incorrect data can give wrong results or mislead the
interpretations.
(E) Value
Big data is not only just a big pile of data, but also possess to have hidden patterns and
useful knowledge which can be of high business value. But as there is cost of investment of
resources in processing big data, we should make a preliminary enquiry to see the
potential of the big data in terms of value discovery or else our efforts could be in vain.
Data Analytics
Data analytics is the process of examining data sets in order to draw conclusions about
the information they contain, with the aid of specialised systems and software.
Data analytics technologies and techniques are becoming popular day-by-day. They
are used in commercial industries to enable organisations to make more informed
business decisions. In the field of science and technology, it can be useful for researchers to
verify or disprove scientific models, theories and hypotheses. Pandas is a library of the
programming language Python that can be used as a tool to make data analysis much
simpler.
Smart Cities
With rapid urbanisation, the load on our cities is increasing day-by-day, and there are
challenges in management of resources like land water, waste, air pollution, health and
sanitation, traffic congestions, public safety and security, besides the overall city
infrastructures including road, rail, bridge, electricity, subways, disaster management,
sports facilities, etc. These challenges are forcing many city planners around the world to
look for smarter ways to manage them and make cities sustainable and livable.
The idea of a smart city makes use of computer and communication technology
along with IoT, WoT to manage and distribute resources efficiently. The smart building
shown here uses sensors to detect earthquake tremors and then warn nearby buildings so
that they can prepare themselves accordingly. The smart bridge uses wireless sensors t o
detect any loose bolt, cable or crack. It alerts concerned authorities through SMS. The
smart tunnel also uses wireless sensors to detect any leakage or congestion in the tunnel.
This information can be sent as wireless signals across the network of sensor nodes to a
centralized computer for further analysis.
Every sphere of life in a city like transportation systems, power plants, water supply
networks, waste management, law enforcement, information systems, schools, libraries,
hospitals and other community services work in unison to optimize the efficiency of city
operations and services.
CLOUD COMPUTING
Cloud computing is an emerging trend in the field of information technology, where
computer-based services are delivered over the Internet or the cloud, for the case
of their accessibility form any where using any smart device. The services comprise software,
hardware (servers), databases, storage, etc. These resources are provided by companies
called cloud service providers and usually charge on pay per use basis, like the way we
pay for electricity usage. We already use cloud services while storing our pictures and files
as backup on Internet, or host a website on the Internet. Through cloud computing, a user
can run a bigger application or process a large amount of data without having the required
storage or processing power on their personal computer as long as they are connected to the
Internet. Besides other numerous features, cloud computing offers cost-effective, on-
demand resources. A user can avail need-based resources from the cloud at a very
reasonable cost.
Cloud Services
A better way to understand the cloud is to interpret everything as a service. A service
corresponds to any facility provided by the cloud. There are three standard models to
categorise different computing services delivered through cloud as shown in Figure
2.12. These are Infrastructure as a Service (IaaS), Platform as a Service (PaaS), and
Software as a Service (SaaS).
(A) Infrastructure as a Service (IaaS)
The IaaS providers can offer different kinds of computing infrastructure, such as servers,
virtual machines (VM), storage and backup facility, network components,
operating systems or any other hardware or software. Using IaaS from the cloud, a user
can use the hardware infrastructure located at a remote location to configure, deploy and
execute any software application on that cloud infrastructure. They can outsource the
hardware and software on demand basis and pay as per the usage, thereby they can
save the cost of software, hardware and other infrastructures as well as the cost of
setting up, maintenance and security.
(B) Platform as a Service (PaaS)
Through this service, a user can install and execute an application without worrying
about the underlying infrastructure and their setup. That is, PaaS provides a platform or
environment to develop, test, and deliver software applications. Suppose we have developed
a web application using MySQL and Python. To run this application online, we can avail a pre-
configured Apache server from cloud having MySQL and Python pre- installed. Thus, we are
not required to install MySQL and Python on the cloud, nor do we need to configure the
web server (Apache, nginx). In PaaS, the user has complete control over the deployed
application and its configuration. It provides a deployment environment for developers at a
much reduced cost lessening the complexity of buying and managing the underlying
hardware and software.
(C) Software as a Service (SaaS)
SaaS provides on-demand access to application software, usually requiring a licensing or
subscription by the user. While using Google doc, Microsoft Office 365, Drop Box, etc., to
edit a document online, we use SaaS from cloud. A user is not concerned about
installation or configuration of the software application as long as the required
software is accessible. Like PaaS, a user is provided access to the required configuration
settings of the application software, that they are using at present.
In all of the above standard service models, a user can use on-demand infrastructure or
platform or software and is usually charged as per the usage, thereby eliminating the
need of a huge investment upfront for a new or evolving organisation. In order to utilise
and harness the benefits of cloud computing, Government of India has embarked upon an
ambitious initiative — ‘GI Cloud’ which has been named as ‘MeghRaj’ (https://
cloud.gov.in).
GRID COMPUTING
A grid is a computer network of geographically dispersed and heterogeneous
computational resources as shown in Figure 2.13. Unlike cloud, whose primary focus is to
provide services, a grid is more application specific and creates a sense of a virtual
supercomputer
with an enormous processing power and storage. The constituent resources are called nodes.
These different nodes temporarily come together to solve a single large task and to reach a
common goal.
Nowadays, countless computational nodes ranging from hand-held mobile devices
to personal computers and workstations are connected to Local Area Network (LAN) or
Internet. Therefore, it is economically feasible to reuse or utilise their resources like
memory as well as processing power. The grid provides an opportunity to solve
computationally intense scientific and research problems without actually procuring a
costly hardware. Grid can be of two types— (i) Data grid, used to manage large and
distributed data having the required multi-user access, and (ii) CPU or Processor grid,
where processing is moved from one PC to another as needed or a large task is divided
into subtasks, and allotted to
various nodes for parallel processing.
Grid computing is different from IaaS cloud service. In case of IaaS cloud service,
there is a service provider who rents the required infrastructure to the users. Whereas in
grid computing, multiple computing nodes join together to solve a common
computational problem.
To set up a grid, by connecting numerous nodes in terms of data as well as CPU, a
middleware is required to implement the distributed processor architecture. The Globus
toolkit (http://toolkit.globus.org/toolkit) is one such software toolkit used for building
grids, and it is as open source. It includes software for security, resource management,
Data management, communication, fault detection, etc.
BLOCKCHAINS
Traditionally, we perform digital transactions by storing data in a centralised database and the
transactions performed are updated one by one on the database. That is how the ticket booking
websites or banks operate. However, since all the data is stored on a central location, there are
chances of data being hacked or lost. The blockchain technology works on the concept of
decentralised and shareddatabase where each computer has a copy of the database. A block can be
thought as a secured chunk of data or valid transaction. Each block has some data called its header,
which is visible to every other node, while only the owner has access to the private data of the
block. Such blocks form a chain called blockchain as shown in Figure 2.14. We can define
blockchain as a system that allows a group of connected computers to maintain a single updated and
secure ledger. Each computer or node that participates in the blockchain receives a full copy of the
database. It maintains an ‘append only’ open ledger which is updated only after all the nodes within
the network authenticate the transaction. Safety and security of the transactions are ensured because
all the members in the network keep a copy of the blockchain and so it is not possible for a single
member of the network to make changes or alter data.
The most popular application of blockchains technology is in digital currency. However, due to
its decentralised nature with openness and security, blockchains are being seen as one of the
ways to ensure transparency, accountability and efficiency in business as well as in governance
systems.
For example, in healthcare, better data sharing between healthcare providers would result in a higher
probability of accurate diagnosis, more effective treatments, and the overall increased ability of healthcare
organisations to deliver cost-effective care. Another potential application can be for land registration
records, to avoid various disputes arising out of land ownership claims and encroachments. A
blockchain based voting system can solve the problem of vote alterations and other issues. Since
everything gets stored in the ledger, voting can become more transparent and authentic. The blockchain
technology can be used in diverse sectors, such as banking, media, telecom, travel and hospitality and
other areas.
SUMMARY
• Artificial Intelligence endeavours to simulate the natural intelligence of human beings into
machines thus making them intelligent.
• Machine learning comprises of algorithms that use data to learn on their own and make
predictions.
• Natural language processing (NLP) facilitates communicating with intelligent systems using a
natural language.
• Virtual reality allows a user to look at, explore, and interact with the virtual surroundings, just like
one can do in the real world.
• The superimposition of computer-generated perceptual information over the existing physical
surroundings is called augmented reality.
• Robotics can be defined as the science primarily associated with the design, fabrication, theory, and
application of robots.
• Big data holds rich information and knowledge which can be of high business value. Five
characteristics of big data are: Volume, Velocity, Variety, Veracity, and Value.
• Data analytics is the process of examining data sets in order to draw conclusions about the information
PAGE 1
they contain.
• The Internet of Things (IoT) is a network of devices that have an embedded hardware and software to
communicate (connect and exchange data) with other devices on the same network.
• A sensor is a device that takes input from the physical environment and uses built-in computing
resources to perform predefined functions upon detection of specific input and then processes data
before passing it on.
• Cloud computing allows resources located at remote locations to be made available to anyone
anywhere. Cloud services can be Infrastructure as a Service (IaaS), Platform as a Service (PaaS), and
Software as a Service (SaaS).
• Block chair technology uses a shared data base of chaired blocks where copies of data base exist on
multiple computers.
STUDY MATERIAL
CLASS XI SESSION2022-23
INFORMATICS PRACTICES
CHAPTER- DATABASE CONCEPT
Introduction- “Database is actually a collection of interrelated data so that it can be used by various applications.
Need and advantages of database over traditional files
• Database facilitates centralized storing
• Reduces Data inconsistency
• Reduces data redundancy
• Sharing of data is possible
• It gives protection to the data
• It enforce standards
Some of the Popular database softwares are- MySQL (open Source)
✔ ORACLE Database
✔ MS SQL Server
✔ MariaDB
Relational Database
A database where data are organized in the form of tables (rows and columns)
Terminologies in RDBMS
PAGE 2
Relation
Tables in Relational Database
Eg:Employee
Columns in a Relation
Eg: No,Name,Salary,Zone,Age,Grade,Dept
Records/Rows in a relation
Eg:1,mukul,30000,west,28,A,10
PAGE 3
Candidate key=primary key + alternate key
Alternate key=candidate key-primary key
A non-key attribute which is used to set relationship between 2 tables .The values of the
foreign key are derived from the primary key of another table
Foreign key is also known as Referential Integrity constraint
✔ Check yourself
PAGE 4
Data Types:
For Numbers – INT , INT(Value)
For Decimal Numbers – FLOAT(M,N)
For String/Text – CHAR(N), VARCHAR(N)
For Date – DATE
Differences between Char & Varchar
Char Varchar
It is an abbreviation for characters.
It accept fixed length text .
CREATING DATABASE:
CREATE DATABASE [IF NOT EXISTS] DATABASENAME
Note: IF NO EXISTS will attempt to create database only if the given name database not
exists. If command is executed without it and database already exists, then error message
‘database already exists’ will come
Example:
Create Database mydata1;
Create Database if not exists mydata1;
OPENING DATABASE
To start working in any database it must be opened by USE command.
USE databasename;
Example: Use mydata1;
GETTING LIST OF ALL DATABSES
To get the list of all created database –
PAGE 5
Show databases;
REMOVING DATABSES
To remove already existing database
DROP DATABASE databasename
Example: Drop database mydata1
CREATING TABLE Create Table Tablename(colname datatype(size), colname2 datatype(size),…);
Example: Create table emp(empno int, name varchar(20), dept varchar(20), salary int)
VIEWING TABLE STRUCTURE
MySQL allows us to get the structure of table like list of columns, data type, size and key
information of table using DESC / DESCRIBE command
Example: DESC emp;
DDL Command- ALTER
ALTER TABLE command allows us to perform the following operations:
▪ Adding new column in existing table
▪ Dropping existing column from table
▪ Modifying column definition in table
▪ Changing the name of column
▪ Adding or dropping constraint after table creation.
ALTER TABLE - ADD Column
To add a column in a table, use the following syntax:
ALTER TABLE table_name ADD column_name datatype;
Example: ALTER TABLE Customers ADD Email varchar(255);
ALTER TABLE - DROP COLUMN
To delete a column in a table, use the following syntax
ALTER TABLE table_name DROP COLUMN column_name;
Example: ALTER TABLE Customers DROP COLUMN Email;
ALTER TABLE - ALTER/MODIFY COLUMN
To change the data type of a column in a table, use the following syntax:
ALTER TABLE table_name ALTER COLUMN column_name datatype;
Example: ALTER TABLE Emp modify Name Varchar(40);
ALTER TABLE Emp change Name EName varchar(40)
SQL PRIMARY KEY on CREATE TABLE
PAGE 6
The following SQL creates a PRIMARY KEY on the "ID" column when the "Persons" table is
created:
SQL PRIMARY KEY on ALTER TABLE
To create a PRIMARY KEY constraint on the "empno" column when the table is already
created, use the following SQL:
Create table emp(empno int primary key, name varchar(20), dept varchar(20), salary int)
ALTER TABLE- ADDING CONSTRAINT
ALTER TABLE Persons ADD PRIMARY KEY (ID);
ALTER TABLE Persons ADD CONSTRAINT PK_Person PRIMARY KEY (ID,LastName);
DROP a PRIMARY KEY Constraint
To drop a PRIMARY KEY constraint, use the following SQL:
ALTER TABLE Persons DROP PRIMARY KEY;
ALTER TABLE Persons DROP CONSTRAINT PK_Person;
DROPPING TABLE
DROP TABLE[IF EXISTS] tablename
Example:
▪ Drop Table emp;
▪ Drop table if exists emp;
DATA QUERY COMMANDS
SELECT COMMAND
Select statement allows to send queries to table and fetch the desired record. Select can be
used to select both horizontal and vertical subset.
Syntax:- Select * / columnnames FROM tablename [ where condition ]
Selecting all record and all columns
Select * from emp;
Selecting desired columns
Select empno, name from emp;
The SQL LIKE Operator
The LIKE operator is used in a WHERE clause to search for a specified pattern in a column.
There are two wildcards often used in conjunction with the LIKE operator:
● The percent sign (%) represents zero, one, or multiple characters
● The underscore sign (_) represents one, single character
PAGE 7
The percent sign and the underscore can also be used in combinations!
LIKE Syntax
SELECT column1, column2, ...FROM table_name WHERE columnN LIKE pattern;
Here are some examples showing different LIKE operators with '%' and '_' wildcards:
LIKE Operator Description
WHERE CustomerName LIKE 'a%' Finds any values that start with "a"
WHERE CustomerName LIKE '%a' Finds any values that end with "a"
WHERE CustomerName LIKE '%or%' Finds any values that have "or" in any position
WHERE CustomerName LIKE '_r%' Finds any values that have "r" in the second position
WHERE CustomerName LIKE 'a_%' Finds any values that start with "a" and are at least
2 characters in length
WHERE CustomerName LIKE 'a__%' Finds any values that start with "a" and are at least
3 characters in length
WHERE ContactName LIKE 'a%o' Finds any values that start with "a" and ends with"o"
The SQL BETWEEN Operator
The BETWEEN operator selects values within a given range. The values can be numbers,
text, or dates. The BETWEEN operator is inclusive: begin and end values are included.
BETWEEN Syntax
SELECT column_name(s)
FROM table_nameWHERE column_name BETWEEN value1 AND value2;
BETWEEN Example
The following SQL statement selects all products with a price between 10 and 20:
SELECT * FROM ProductsWHERE Price BETWEEN 10 AND 20;
NOT BETWEEN Example
To display the products outside the range of the previous example, use NOT BETWEEN:
SELECT * FROM Products WHERE Price NOT BETWEEN 10 AND 20;
SELECT * FROM Orders WHERE OrderDate NOT BETWEEN '1996-07-01' AND '1996-07-
31';
The SQL IN Operator
The IN operator allows you to specify multiple values in a WHERE clause.
The IN operator is a shorthand for multiple OR conditions.
IN Syntax
PAGE 8
SELECT column_name(s) FROM table_name WHERE column_name IN (value1, value2,
...);
IN Operator Examples
The following SQL statement selects all customers that are located in "Germany", "France" or
"UK":
SELECT * FROM Customers WHERE Country IN ('Germany', 'France', 'UK');
The following SQL statement selects all customers that are NOT located in "Germany",
"France" or "UK":
SELECT * FROM Customers WHERE Country NOT IN ('Germany', 'France', 'UK');
The SQL ORDER BY Keyword
The ORDER BY keyword is used to sort the result-set in ascending or descending order.
The ORDER BY keyword sorts the records in ascending order by default. To sort the records
in descending order, use the DESC keyword.
ORDER BY Syntax
SELECT column1, column2 FROM table_name ORDER BY column1[ ASC|DESC];
ORDER BY Example
The following SQL statement selects all customers from the "Customers" table, sorted by the
"Country" column:
SELECT * FROM Customers ORDER BY Country;
ORDER BY DESC Example
The following SQL statement selects all customers from the "Customers" table, sorted
DESCENDING by the "Country" column:
SELECT * FROM Customers ORDER BY Country DESC;
DISTINCT Clause: returns records without repetition (Distinct records)
mysql> SELECT DISTINCT DeptId FROM EMPLOYEE;
UPDATE Command: make changes in the value(s) of one or more columns of existing
records in a table.
SYNTAX:
UPDATE table_name SET attribute1 = value1, attribute2 = value2, ...
[WHERE condition];
NOTE: If we miss the where clause in the UPDATE statement then the Marks of all
the records will be changed to 65.
PAGE 9
DELETE Command:
DELETE statement is used to delete/remove one or more records from a table.
DELETE FROM table_name WHERE condition;
Question
1. Identify the DDL and DML command from the following.
CREATE TABLE, INSERT …INTO, DELETE FROM, ALTER TABLE
ANSWER DDL: CREATE TABLE, ALTER TABLE DML: INSERT ...INTO, DELETE FROM
CCT Based Question:
2. Tejasvi Sethi, a car dealer has stored the details of all cars in her showroom in a table called CARMARKET.
The table CARMARKET has attributes CARCODE which is aprimary key, CARNAME, COMPANY,
COLOR, COST (in lakh rupees) of the car and DOM which is the Date of Manufacture of the car.
Answer any four questions based on the table CARMARKET from the below mentioned questions.
Table: CARMARKET
CARCODE CARNAME COMPANY COLOR COST DOM
C01 BALENO SUZUKI BLUE 5.90 2019-11-07
CO2 INDIGO TATA SILVER 12.90 2020-10-15
C03 GLC MERCEDES WHITE 62.38 2020-01-20
C04 A6 AUDI RED 58.55 2018-12-29
C05 INNOVA TOYOTA BLACK 32.82 2017-11-10
C06 WAGON-R SUZUKI WHITE 12.11 2016-11-11
C07 BREZZA SUZUKI GOLDEN 9.80 2016-10-03
Choose the correct SQL query to do the following (for parts 1 to 4)
i. Display the carname along with the charges rounded off to 1 digit afterdecimal place.
a. Select carname,round(cost) from carmarket;
b. Select carname,round.cost(1) from carmarket;
c. Select carname,round.cost() from carmarket;
d. Select carname, round(cost,1) from carmarket;
CORRECT ANSWER – d
ii. Display the carname, color and position of the character ‘E’ in the color ofall the cars.
PAGE
10
a. select carname,color from carmarket where color like “%E%”;
b. select carname,color,instr(color,’E’) from carmarket;
c. select carname,color from carmarket where color = “%E%”;
d. select carname,color,substr(color,1,’E’) from carmarket;
CORRECT ANSWER – b
iii. Display the carname ,name of the company in lower case of all cars whoseyear (of dom) is 2020.
a. select carname,lcase(company) from carmarket where year(dom) = 2020;
b. select carname,lcase(company) from carmarket where yearof(dom) like’2020%’;
c. select carname,lower(company) from carmarket where dom from’2020-01-01′ to ‘2020-
12-31’;
d. select carname,lower(company) from carmarket where yearfrom(dom) =2020;
CORRECT ANSWER – a
iii. Which of the following SQL Query will fetch ID of those issued books whichhave not been
returned?
a.SELECT BookID from StuLibrary where BookID is NULL;
b.SELECT BookID from StuLibrary where StuID is NULL;
c.SELECT BookID from StuLibrary where Issued_date is NULL;
d. SELECT BookID from StuLibrary where Return_date is NULL;
v. Which of the following SQL Query will display dates on which number ofissued books is greater
than 5?
PAGE
12
a.SELECT Issued_date from StuLibrary GROUP BY Issued_datewhere COUNT(*)>5;
b.SELECT Issued_date from StuLibrary GROUP BY Return_datehaving count(*)>5
c.SELECT Issued_date from StuLibrary GROUP BY Issued_datehaving count(*)>5
d. SELECT Issued_date from StuLibrary GROUP BY Return_datewhere COUNT(*)>5
Solutions:
I. d) Both Query ii) and iii) will display the desired data.
II. c) BookID,Issued_date
III. d) SELECT BookID from StuLibrary where Return_date is NULL;
IV. c) StuAadhar
V. c) SELECT Issued_date from StuLibrary GROUP BY Issued_datehaving count(*)>5
3.What is the difference between cardinality and degree?.
Ans. Degree - The number of attributes or columns in a relation is called the Degree of the relation.
Cardinality - The number of tuples/ rows in a relation is called the Cardinality of the relation.
4. Differentiate between WHERE and HAVING clause.
Ans. WHERE clause is used to select particular rows that satisfy a condition whereas HAVING clause is used in
connection with the aggregate function, GROUP BY clause.
For ex. – select * from student where marks > 85;
This statement shall display the records for all the students who have scored more than 85 marks.
On the contrary, the statement – select * from student group by stream having marks > 85; shall display the records
of all the students grouped together on the basis of stream but only for those students who have scored marks more
than 85.
5. What do you mean by domain of an attribute in DBMS? Explain with an example.
Ans. Domain of an attribute is the set of values from which a value may come in a column. E.g. Domain of section
field may be (A,B,C,D).
6. Choose appropriate answer with respect to the following code snippet.
PAGE
13
i) 30 ii) 1 iii) 3 iv) 4
Ans. iii) 3
7. Suppose your school management has decided to conduct cricket matches between students of class XI and Class
XII. Students of each class are asked to join any one of the four teams — Team Titan, Team Rockers, Team Magnet
and Team Hurricane. During summer vacations, various matches will be conducted between these teams. Help your
sports teacher to do the following:
a) Create a database “Sports”.
Ans.:create database sports;
use sports;
b) Create a table “TEAM” with following considerations:
i) It should have a column TeamID for storing an integer value between 1 to 9, which refers to unique identification
of a team.
ii) Each TeamID should have its associated name (TeamName), which should be a string of length not less than 10
characters.
Ans.:create table team
(teamid int(1),
teamname varchar(10));
c) Using table level constraint, make TeamID as primary key.
Ans.:alter table team add primary key (teamid);
d) Show the structure of the table TEAM using SQL command.
Ans.:desc team;
8. Differentiate between the following commands:
a) ALTER and UPDATE b) DELETE and DROP
Alter Update
This command is used to modify the table structure. This command is used to modify the table contents.
It will add, modify or drop any column or constraints. It will set new values to the already exists values in a tabl
Example: Example:
alter table emp add column remarks varchar(20); update emp set sal=5000 where empno=1256;
Delete Drop
PAGE
14
Delete is used to remove the rows from the table. Drop is used to deleting a table.
Example: Example:
delete from emp where empno=1245; drop table emp;
9. What are the different divisions of SQL and commands? Give examples.
Ans: SQL commands can be divided into following categories –
(i) Data Definition Language (DDL) Commands. e.g. CREATE TABLE, ALTER TABLE, DROP TABLE etc.
(ii) Data Manipulation Language (DML) Commands. e.g. INSERT INTO, DELETE FROM, UPDATE, SELECT
etc.
(iii) Transaction Control Language (TCL) Commands.e.g. ROLLBACK, COMMIT, SAVEPOINT etc
10. How to view the structures of the table made by you?
Ans: By using DESC <TableName> command. e.g.
mysql>DESC Employee;
11. There is a column HOBBY in a Table CONTACTS. The following two statements are giving different outputs.
What may be the possible reason ?
a.SELECT COUNT(*) FROM CONTACTS;
b.SELECT COUNT(HOBBY)FROM CONTACTS;
Ans. The column hobby may have NULL values, when we give count(colname) it ignores null values while count(*)
will count all duplicate and NULL values. therefore two statements may give different values.
12. Kunal has entered the following SQL command on Table ‘STUDENT’ that has TotalMarks as one of the
columns.
SELECT COUNT (*) FROM STUDENT; The output displayed is 20.
Then, Kunal enters the following command :
SELECT COUNT (*) FROM STUDENT WHERE TotalMarks <100; The output displayed is 15.
Then, Kunal enters the following command :
SELECT COUNT (*) FROM STUDENT WHERE TotalMarks >= 100;
Ans. Yes , as no of records =20 , students scoring <100 = 15. ; hence the students scoring greater than equal to 100
will be 20-15 =5. As all the three statements mentioned use count(*) as the count function.He predicts the output of
the above query as 5. Do you agree with Kunal ? Give reason for your answer.
MCQ based on SQL
1. Which is/are correct statements about primary key of a table?
A. Primary keys can contain NULL values B. Primary keys cannot contain NULL values.
PAGE
15
C. A table can have only one primary key with single or multiple fields
D. A table can have multiple primary keys with single or multiple fields
Answer: B and C
2. In existing table, ALTER TABLE statement is used to
A. Add columns B. Add constraints C. Delete columns D. All of the above
Answer: D
3. In a table, a column contains duplicate value, if you want to list all different value only, then which
SQL clause is used?
A. SQL DISTINCT
B. SQL UNIQUE
C. SQL BETWEEN
D. SQL Exists
Answer: A
4. What does the abbreviation DBMS stand for?
A. Data Borrowing and Movement Software.
B. Database Management System.
C. Digital Base Mapping System.
D. Database Manipulation Software.
Answer: B
5. A row of relation generally referred to as .......................... and column of a relation is ...................
A. Domain & Attribute
B. Attribute & Domain
C. Tuple & Attribute
D. Attribute & Tuple
Answer: C
6. A relation has 45 tuples & 5 attributes, what will be the Degree & Cardinality of that relation?
A. Degree 5, Cardinality 45
B. Degree 45, Cardinality 5
C. Degree 50, Cardinality 45
D. Degree 50, Cardinality 225
Answer: A
7. Which of the following statement removes database including its related components?
PAGE
16
A. DROP DATABASE
B. DELETE DATABASE
C. REMOVE DATABASE
D. None of the mentioned
41
Answer: A
8. Which is a valid CREATE TABLE statement?
A. Create table emp add(id integer(3));
B. Create table emp (id integers(3));
C. Create table emp modified (id integer(3));
D. Create table emp (id integer(3));
Answer: D
9. Which operator defines a range of values that the column values must fall in?
A. In
B. Like
C. Between
D. Is
Answer: C
10. We use ............... operator with select for condition based on pattern matching.
A. In
B. Like
C. Between
D. Is
Answer: B
11. To display the detail of employee having “e” in their name in descending order of salary the correct
SQL statement is :
A. SELECT * FROM emp WHERE ename LIKE “e%” ORDER BY SAL ;
B. SELECT * FROM emp ORDER BY SAL DESCWHERE ename LIKE “%e%”;
C. SELECT * FROM emp WHERE ename LIKE “%e%” ORDER BY DESCSAL;
D. SELECT * FROM emp WHERE ename LIKE “%e%” ORDER BY SAL DESC;
PAGE
17
Answer: D
12. How can you insert a new row into the “STORE” table.
A. INSERT ROW (1,”RAM” )INTO STORE;
B. INSERT VALUES(1,”RAM”) INTO STORE;
C. INSERT INTO (1,”RAM” )STORE;
D. INSERT INTO STORE VALUES (1,”RAM”);
Answer: D
13. The statement in SQL which allows to change the definition of a table is:
(A) Alter
(B) Update
(C) Create
(D) Select
Answer: A
14. Which of the following SQL commands is used to retrieve data?
(A) Delete
(B) Select
(C) Join
42
(D) Insert
Answer: B
15. Which operator is used to compare a value to a specified list of values?
(A) ANY
(B) BETWEEN
(C) All
(D) IN
Answer: D
Table: SPORTS
SCode SportName Noofplayers CoachName
S001 Cricket 21 Rahul Dravid
S002 Football 25 Roshan Lal
S003 Hockey 40 Sardar Singh
S004 Cricket 19 Chetan Sharma
PAGE
20
S005 Archery 12 Limba Ram
S006 Shooting 17 Deepika Kumari
1. Identify the attribute best suitable to be declared as a primary key
A. CoachName B. Noofplayers C. SportName D. SCode
Answer: D
2. What will be the degree and cardinality of the SPORTS table.
A. Degree: 4 Cardinality: 4 B. Degree: 4 Cardinality: 6
C. Degree: 4 Cardinality: 7 D. Degree: 7 Cardinality: 7
Answer: B
3. Which of the following command will be used to describe the structure of the table.
A. DESC SPORTS B. DESCRIBE SPORTS C. Both A and B D. None of the
Above
Answer: C
4. Sahil wants to delete the column coachname.Which command will he use from the following:
A. DELETE Coachname FROM SPORTS; B. ALTER Coachname FROM SPORTS;
C. ALTER TABLE SPORTS DROP Coachname; D. DELETE Coachname FROM SPORTS;
Answer: C
MCQ
1.Single Line comments in Python begin with …… symbol.
a) #
b) %
c) ;
d) “
Ans)a) #
2.The extension of Python file is given as –
a) .ppt
b ) .py
c) .pdoc
d).ppp
Ans) b ) .py
3.Which of the following is an invalid statement ?
PAGE
21
a) I=J=K=50
b) I,J,K=50,60,70
c) I J K =50 60 70
d) I_J_K=70
Ans) c)I J K =50 60 70
6.Shivi has written the following program but she is not getting the desired result .Why ? a=input(“enter a number”)
b=input(“enter 2nd Number”)
c=a+b
print(c)
a) wrong coding
b) type casting problem
c) formula of sum is incorrect
d) none
Ans) b) type casting problem
7.The given program has an error , find out the correct option with line number.
10=a #Line 1
b=45 #Line 2
a+b=c #Line 3
print( c ) #Line 4
PAGE
22
Error in line number …
a) 1 b) 2 c) 3 d) 1 & 3
Ans) d) 1 & 3
8.What will be the output of the following code
print( ‘H’ in ‘Hello’)
a) Hello
b ) hello
c ) true
d ) None
Ans) c ) true
9.Slicing is used to retrieve a …… of values .
a) Subset
b) 2 values
c) big values
d)All of these
Ans) a) Subset
10.An identifier must be a keyword of Python
a) True
b ) False
Ans) b ) False
11.What do we use to define a block of code in Python language?
a) Key
b) Brackets
c) Indentation
d) None of these
Ans) c) Indentation
12.What is the answer to this expression, 22 % 3 is?
a) 7
b) 1
c) 0
d) 5
Ans) b) 1
PAGE
23
13.What error occurs when you execute the following Python code snippet?
apple = mango
a)SyntaxError
b)NameError
c)ValueError
d) TypeError
Ans) b)NameError
Short Answer Type Questions
1.Python is an interpreted language‟. What does it mean to you?
Ans- It means that the Python installation interprets and executes the code line by line at a time.
2. What does a cross platform language mean?
Ans- it means a language can run equally on variety of platforms-Windows, Linux/UNIX, Macintosh,
Supercomputers, Smart phones etc.
3. Python is a Free and Open Source language. What do you understand by this feature?
Ans- It means Python is freely available without any cost. Its source code is also available. One can modify,
improve/extend an open source software.
4. In how many ways, can you work in Python?
Ans-In two ways we can work in Python- (i) Interactive mode (ii) Script Mode
5. What is the difference between Interactive mode and Script Mode in Python?
Ans- In interactive mode, one command can run at a time and commands are not saved. Whereas in Script mode, we
can save all the commands in the form of a program file and can see output of all lines together.
Competency Based Questions
1. Which of the following are not valid strings in Python?
(a)”Hello” (b) „Hello‟ (c)”Hello‟ (d) „Hello” (e) {Hello}
Ans- String (c) , (d) and (e ) are not valid strings.
PYTHON FUNDAMENTALS
Very Short answer Type Questions
1. What is None literal in Python?
Ans: Python has one special literal, which is None. The None literal is used to indicate absence of value. It is also
used to indicate the end of lists in Python. It means “There is nothing here”.
2. What is the error in following code: x, y =7 ?
Ans: The following error comes - 'int' object is not iterable. Which means an integer object i.e. cannot be repeated for
x and y. one more integer object is required after 7.
PAGE
24
3. what will the following code do: a=b=18 ?
Ans: This code will assign 18 to a and b both.
4. Following code is creating problem X = 0281, find reason.
Ans: 0281 is an invalid token.
5. Find the error in the following code:
(a) temp=90 (b) a=12 (c) print(“x=”x)
print temp b=a+b
print( a And b)
(d) a, b, c=2, 8, 4 (e) x = 23 (f) else = 21-4
print(a, b, c) 4=x
c, b, a = a, b, c
print(a; b; c)
Ans: (a) Missing parentheses in call to 'print'.
(b) Name „b‟ is not defined.
(c) Invalid Syntax.
(d) Invalid Syntax in second print statement.
(e) can't assign to literal in second line.
(f) Invalid Syntax.
6 Find the error in the following code:
(a) y = x +5 (b) a=input(“Value: “)
print(x,y) b = a/2
print( a, b)
Ans: (a) Name 'x' is not defined.
(b) Unsupported operand type(s) for /: 'str' and 'int'.
Short Answer Type Questions
1. What is the difference between a keyword and an identifier?
Ans: Difference between Keyword and Identifier: Every language has keywords and identifiers, which are only
understood by its compiler. Keywords are predefined reserved words, which possess special meaning. An identifier
is a unique name given to a particular variable, function or label of class in the program.
2. What are literals in Python? How many types of Literals allowed in Python?
Ans: Literals: Python comes with some built-in objects. Some are used so often that Python has a quick way to make
these objects, called literals. The literals include the string, Unicode string, integer, float, long, list, tuple and
dictionary types
PAGE
25
3. How many types of sequences are supported in Python?
Ans: Three Types of Sequences are supported in python: (i) String (ii) List (iii) Tuple
4. What factors guide the choice of identifiers in program?
Ans: (i) An identifier must start with a letter or underscore followed by any number of digits and/or letters.
(ii) No reserved word or standard identifier should be used.
(iii) No special character (Other than underscore) should be included in the identifier.
5. What is the difference between an expression and a statement in Python?
Ans: A statement is an instruction that the Python interpreter can execute. We have only seen the assignment
statement so far. Some other kinds of statements that we‟ll see shortly are while statements, forstatements, if
statements, and import statements. (There are other kinds too!)
An expression is a combination of values, variables, operators, and calls to functions. Expressions need to be
evaluated. If you ask Python to print an expression, the interpreter evaluates the expression and displays the result.
6. What is block/code block/suit in Python?
Ans: Sometimes a group of statements is part of another statement of function. Such a group of one or more
statements is called block or code-block or suit in python. e.g.
PAGE
26
(e) “Namaste
(f) “I liked „Harry Potter‟ very much”
Ans: (a) Correct
(b) Correct
(c) Incorrect
(d) Correct
(e) Incorrect
(f) Correct
4 What is the error in following Python program with one statement?
print(“My name is : “, name)
suggest a solution
Ans: Error is : “name 'name' is not defined”. And the solution is to declare the variable-name before this statement.
Ans: Output: Hari , you are 18 now but You will be 19 next year.
7. Predict output:
Ans: Output: 4 6 8
8. WAP to print the area of circle when radius of the circle is given by user.
Ans:
PAGE
27
9. WAP to print the volume of a cylinder when radius and height of the cylinder is given by user.
Ans:
DATA HANDLING
Very Short answer Type Questions
1. Identify the data types of the following values given bellow –
3, 3j, 13.0, “12‟,”14”, 2+0j,19, [1,2,3],(3,4,5)
Ans: 3 – int 3j – complex 13.0 – float “12‟ – string “14” – string 2+0j – complex 19 – int
[1,2,3] – list (3,4,5) – tuple
2. What will be the output of the following
(a)12/4 (b)14//14 (c)14%4 (d) 14.0/4 (e) 14.0//4 (f)14.0%4
Ans: (a) 3.0 (b) 1 (c) 2 (d) 3.5 (e) 3.0 (f) 2.0
3. What will be the output of the following ?
Ans:
4
4.25
1
4
4. What will be the output of the following ?
(a)87//5 (b)(87//5.0) == (87//5) (c) 87//5.0 (d) 17%5.0
PAGE
28
Ans: (a) 17 (b) True (c) 17.0 (d) 2.0
5. int(„a‟) produces error. Why?
Ans: This is because „a‟ is an invalid literal for int() with base 10.
6. Write following expressions in Python.
Ans:
(a) (b*b*h)/3
(b) d=math.sqrt(pow(x2-x1,2)+pow(y2-y1,2))
(c) x1=((-b) + math.sqrt((b*b)-(4*a*c)))/(2*a) x2=((-b) - math.sqrt((b*b)-(4*a*c)))/(2*a)
(d) pow(a,n) * pow(a,m) = pow(a,m+n)
Short Answer Type Questions
1. What are data types? What are Python‟s built-in core data types?
Ans: Every value in Python has a datatype. Since everything is an object in Python programming, data types are
actually classes and variables are instance (object) of these classes. There are various data types in Python. Some of
the important types are listed below.
(i) Numbers (ii) String (iii) List (iv) Tuple (v) Dictionary
2. Which data types of Python handle Numbers?
Ans: It is cleared by name that Number data types are used to store numeric value in Python. The Numbers in Python
have following core data types:
(i) Integers a. Integers (signed) b. Booleans (ii) Floating-Point Numbers (iii) Complex Numbers
3. Why is Boolean considered a subtype of Integers?
Ans: Because Boolean Values False and True behave like the values 0 and 1, respectively. So Boolean type is a
subtype of plain integers.
4. What do you understand by term „immutable‟?
Ans: Immutable types are those data types that can never change their value in place. In Python the following types
are immutable:
(i) integers (ii) floating-point numbers (iii) Booleans (iv) Strings (v) Tuples
5. What will be the output of the following code? Why?
(a) 13 or len(13) (b) len(13) or 13
Ans: (a) 13 (b) TypeError: object of type 'int' has no len().
6. What are mutable and immutable types in Python? List both of them.
Ans: Mutable types means those data types whose values can be changed at the time of execution. They are as
follows:
PAGE
29
Lists Dictionaries Sets
Immutable types are those data types that can never change their value in place. In Python the following types are
immutable:
integers floating-point numbers Booleans Strings Tuples
7. What are augmented assignment operators? How are they useful?
Ans: An augmented assignment is generally used to replace a statement where an operator takes a variable as one of
its arguments and then assigns the result back to the same variable. A simple example is x += 1 which is expanded to
x = x + (1). Similar constructions are often available for various binary operators. They are helpful in making the
source code small.
Skill Based Questions
1. WAP to calculate compound simple interest after taking the principle, rate and time.
Ans:
3. WAP to take two numbers and check that the first number is fully divisible by second number or not.
Ans:
PAGE
30
Ans: -2
6561
5. What will be the output of the following?
Ans: 4.0
6. WAP to take value of x,y,z from the user and calculate the equation 4x4+3y3+9z2+6 π
Ans:
7. WAP to take the temperatures of all 7 days of the week and displays the average temperature of that week.
Ans:
2. What are loops in Python? How many types of loop are there in Python?
PAGE
31
Ans: Loops are iteration constructs in Python. Iteration means repetition of a set of statements depending upon a
condition test. Loops has three basic elements within it to repeat the statements Initialization (Start)
Check Condition (Stop)
Updation (Step)
Python provide two types of loop
(i) Conditional Loop while( (Condition based loop)
(ii) Counting loop for (loop for a given number of times).
EMERGING TRENDS
Question 1: List some of the cloud-based services that you are using at present.
Answer 1:
Platform as a Service (PaaS) –
It is use for performing Online Coding.
Infrastructure as a Service (IaaS) –
It is a web services. Ex. Amazon web service
Software as a Service (SaaS) –
SaaS is web based software. Ex . Google map
Question 2: What do you understand by the Internet of Things? List some of its potential applications.
Answer 2:
Internet of things are related with the human, object, things, animals, car, door, etc. The all things, objects, or living
things are immerse with sensor, software, hardware or network for exchanging a data between other devices via
same network. With the help of IOT now we can convert our all daily appliances to smart appliances.
List some of its potential applications:
Health care (patient monitoring system, hand sanitizations)
Industry (Facility management, quality control)
Domestic appliances (Automatic power off/on control , door locker)
Agriculture (smart farm by using IOT sensor)
Transportation (Vehicle tracking)
PAGE
32
Answer 3:
a) Cloud computing:
Cloud computing is a service which is used to send data over the internet or cloud.
Simply, cloud is a service provider. There are so many Cloud Service Provider Companies are there. Some of them
provide free service and some are paid. We can also stored the the data in our cloud.
Basically, internet and cloud is somewhat same. There are three types of cloud services are there:
SaaS: Software as a service provides services via internet for distribution. With the help of Saas an independent
one can interacts with the other clients for administrate the application.
Paas: With the help of Platform as a service we can able to perform developing running, debugging like coding
operation. Paas is generally used for online coding.
Iaas: Infrastructure as service provide a web service throughout the internet . Example: Amazon web service
b) Big data and its Characteristics:
As a name suggest it is about huge data manipulation including both structured and unstructured. By using big data
we can increase the quality of a data, optimize the data, and manipulate data easily. We know that, in todays, we are
all exchanging a data through mobile via internet. In result, the large volume of data is generated and it may be
critical also. This data is known as big data. The unstructured data like social media post, chat massages, images, etc.
with big volume are very fluently managed by the specialized tools of big data.
Following are the characteristics of big data:
1) Volume:
We know that the big data itself is huge in size. Volume of a big data is related with the size of data
2) Velocity:
The velocity of big data is directly related with how much data is created And getting structured in a stroke from
different sources.
3) Verity:
When we browsing, searching or do internet surfing. At that we are dealing with different types of data like music,
images, text, videos etc. Some of them are structured, semi structured or unstructured. Big data can daily with
different type of verities of data.
4) Veracity:
It is defined a correctness of data. The data which will be stored, it must be meaningful. Because interpreting
incorrect data may cause wrong result.
Question 5. Differentiate between cloud computing and grid computing with suitable examples.
Answer 5:
In cloud computing, resources are used In grid computing, resources are used in
in centralized pattern collaborative pattern
Question 6. Justify the following statement: “Storage of data is cost-effective and time saving in cloud computing.”
Answer 6:
PAGE
34
While working on internet or any system, we create different types of files and folders, etc. This data is stored in
our local hard disk. But now a days the volume of data are increased day by day. At the time our local hard disks
and a primary storage is not sufficient for storage. And when you go for purchasing external memory or external disk
for storing a data, it requires lot of money. When this type of situation occurs, to overcome the situation we can use
cloud computing. In cloud computing we have to just purchase a service not storage. So it will be effective
than previous. In cloud computing we just need internet service and revenant data. Hence storage data is cost
effective and time saving in cloud computing.
Question9: A company interested in cloud computing is looking for a provider who offers a set of basic services,
such as virtual server provisioning and on demand storage that can be combined into a platform for deploying and
running customized applications. What type of cloud computing model fits these requirements?
1. a) Platform as a Service
2. b) Software as a Service
3. c) Application as a Service
4. d) Infrastructure as a Service
Answer 9: “Infrastructure as a service” provides a platform for deploying and running customized application.
Question10. If the government plans to make a smart school by applying IoT concepts, how can each of the
following be implemented in order to transform a school into IoT-enabled smart school?
1. a) e-textbooks
2. b) Smart boards
3. c) Online Tests
PAGE
35
4. d) Wifi sensors on classrooms doors
5. e) Sensors in buses to monitor their location
6. f) Wearables (watches or smart belts) for attendance monitoring.
Answer 10:
e-textbooks : By using IOT we can available digital book to student for get access from anytime and anywhere.
Smart boards: With the help of IOT we can make a school board work like a tablet. Instead of chalk we can use
wireless pen and our hand as a duster.
Online Tests: We can take test virtually. And observe the student via camera and facial We can also check the
answer digitally.
Wifi sensors on classrooms doors: With the help of IOT we can make our door smart. For example, whenever the
student enters in classroom, automatically his/her attendance noted.
Sensors in buses to monitor their location: for the safety purpose of student w can track the student via GPS sensor
which is monitarized by their parents.
Wearables (watches or smart belts) for attendance monitoring: with the help of wireless sensor, we can track the
attendance of students through their watches. Whenever the student enters in classroom the attendance will get
marked.
Question 11. Five friends plan to try a startup. However, they have a limited budget and limited computer
infrastructure. How can they avail the benefits of cloud services to launch their startup?
Answer 11:
Cloud service applies charges only for service no for storage and resource. Once we purchase any service, it will be
for a lifetime. And we can store a large amount of data into it. Infrastructure as a service is a best service for a startup
plans
Question 12. Governments provide various scholarships to students of different classes. Prepare a report on how
blockchain technology can be used to promote accountability, transparency and efficiency in distribution of
scholarships?
Answer 12:
The blockchain technology works on the concept of decentralised and shared databases where each computer has a
copy of the database. So if the Government avails this technology then all the scholarship applicants will have a view
access to other applicants’ applications. So in this way there will be transparency in distribution of scholarships
because they can view on what basis the Government is giving scholarships.
PAGE
36
Answer 13:
IOT is a internet of thing which is related with things like object which we will use daily. And WoT is web of things
which is responsible to connect those IOT things to the web and communicate with the help of various devices like
sensor.
Column A Column B
Answer 14:
Q.1 Kripali is executing the following query but it is giving error, Help her to correct the same. 1
1 Select ecode ename sal from employee;
Q.1 Write the full form of AR and write in one sentence about AR? 1
8
Q.1 __________provides a platform or environment to develop, test and delivers software 1
9 application.
Q.2 Name the technology works on the concept of decentralized and shared database. 1
0
Q.21 Differentiate between CHAR and VARCHAR Datatypes. 1
PART A
SECTION II
Two case studies questions. Each case study has 4 case-based subparts.
Attempt any 4 out of the 5 subparts.
Answer question 22-23 based on the table EMPL given below
Q22 a) Display EmpNo and EName of all employees from the table empl. 1
b) Display employee name, salary, and department number who are not getting commission 1
from table empl.
c) Display employee number, name, sal*12 as Annual salary whose commission is NULL from 1
table empl.
d)Give degree and cardinality of the above table. 1
e)Display the details of all employee whose annual salary is between 25000 to 40000 1
Q23. a) Using SQL statements in MySQL, create the Database Name: Univ also write a query to 1
open the database Univ.
Answer parts b), c), d) on the basis of the structure table job.
Name of ColumnType
Job_ID Integer(4)
Job_des Varchar(30)
Alloc_on Date
Due_on Date
Emp_id Integer(4)
PAGE
39
b) Create a table Job with the specification given above. 1
c) Identify the primary and alternate key. 1
d) Insert 2 records into the table Job. 1
e) How will you enlist the name of database and the tables in a database? 1
PART B
SECTION-I
Short answer questions of 2 marks each in which two questions have internal options.
Q24. Explain Where and ORDER BY clause with proper examples. 2
Q.25 What are the different divisions of SQL commands? Give example 2
Q. What is the error in following code. Rewrite the correct code and underline the correction. 2
26. Weather = ’raining’
If weather = ’sunny’
print(‘wear sunblock’)
elif weather = ’snow’:
print(‘Going skiing’)
else:
print(“None of the above’)
Q29. a) Identify the different types of following python literals and place them in correct type. 1
23.789 “TRUE” 1232 False
1
b) What are comments? Why do we use comments in Python Programming?
Explain with Example.
OR 2
Write a Python Program which input five numbers and display their average.
Q30. What do you mean by FOSS? Give two examples of any two FOSS. 2
OR
What do you mean by Proprietary Software? Give examples of any two Proprietary Software.
Q 31. Siyahas discarded old, broken and malfunctioning Hard Disk without taking care to delete 2
data. Is it harmful in respect of security concern ? Justify your answer.
PAGE
40
Q 32 Write the output of the following: 2
L=[10,20,30,40], L1=[500,600] , L2=[35,45]
L1.extend(L2)
L.insert(25,2)
print (L1+L2)
print(L1)
print(L.index(30))
print (L2*2)
Q 33. a) How is clear( ) function different from del Statement? 1
b) What is the output produced by the following code – d1={5:[6,7,8],”a”: 1
[1,2,3]} print(d1.keys())
print(d1.values( ))
PART B
SECTION II
Long answer questions of 3 marks each in which one question has question has internal
option.
Q 34. a) How Primary Memory is different from Secondary Memory? Explain at least 4 differences. 2
b) What is Big Data? Name its 3 characteristics.
1
Q 35. Find out the output: sampleList = [10, 20, 30, 40, 50] 3
print(sampleList[-2])
print(sampleList[-4:-1])
OR
L=["Hello",[6,7,8],3,"Riya"]
Consider the above list and answer the following
print(L[3:])
print(L[::2])
print(L[1:2])
print(L[1][1])
Q 36. Consider the “Sales” table in mysql: 3
b) Which of the following command(s) will display all sales whose date of joining is after
31st March 2018.
i. Select * from Sales where dateofjoin>=”31-03-2018”;
ii. Select * from Sales where dojoin>=”2018-03-31”;
iii. Select * from Sales where dojoin>”2018-03-31”;
PAGE
41
iv. Select * from Sales where dojoin>”2018/03/31”;
c) Write a sql query to display the name of the oldest employee first then 2nd oldest and so
on.
Q 37. Give the output of the following queries based on the table mentioned in previous 3
question.
a) select Area, Ename as Employee, amount *0.01 as PF from Sales where
Area=”East” OR Area=”West;
b) select Ename, amount from sales where amount between 5000 and 7000;
c) select * from sales where dojoin>”2019-12-15” OR dojoin<”2017-09-29”;
PART B
SECTION III
Very long answer questions of 5 marks each in which one question has question has
internal option.
Q 38. WAP to create a dictionary named year whose keys are month names and values are their 5
corresponding number of days and display the dictionary (Use any iteration statement)
OR
WAP that repeatedly asks the user to enter product names and prices. Store all of them in a
dictionary whose keys are product names and values are prices. And also write a code to
search an item from the dictionary.
39. Suppose your school management has decided to conduct cricket matches between students of 5
class XI and Class XII. Students of each class are asked to join any one of the four teams —
Team Titan, Team Rockers, Team Magnet and Team Hurricane.
During summer vacations, various matches will be conducted between these teams.
Help your sports teacher to do the following(Using SQL)
OR
*****
****
***
**
*
PAGE
43
Q.2 The Central Processing Unit (CPU) consists of: 1
a)input, output and processing
b) control unit, primary storage & secondary storage
c) control unit, arithmetic-logic unit, primary storage
d) control unit, processing, primary storage
Q.3 An Antivirus software is an example of 1
a) Application Software b) System software
c) Utility software d) None of these
Q.4 First time, Integrated Circuits (ICs) are related to ____________ generation of 1
computers?
A) First generation B) Second generation
C) Third generation D) Fourth generation
Q.5 RAM and ROM are the types of____ memory. 1
Q.6 Start with the list[8,9,10]. Do the following using list functions - 1
Remove the first entry from the list.
Q.7 What will the following code do? 1
a=b=18
Q.8 Shyam wants to store 75.5, Help him to choose the correct data type in Python. 1
Q.9 The mode of Python gives instant result of typed statement. 1
(a) Interactive mode (b) Script mode
(c) Combination of interactive and script modes (d) All of these
Q.10 The number of tuples in a relation are called____________. 1
Q.11 Riddhi is executing the following query but it is giving error, Help her to correct the 1
same.
Select id name from employee;
Q.12 ___________SQL command is used to open database. 1
Q.13 Name two DDL commands. 1
Q.14 Out of these, which of the following is not an advantage of SQL. 1
a) Easy to use
b) portable
c) slow speed
d) No coding required
Q.15 Out of the following which is not the naming rule of SQL table 1
a) should begin with a number
b) name can either be upper or lower case letters.
Q.16 What does IoT stand for? 1
Q.17 _________________comprises of algorithm that use data to learn on their own and 1
make predictions.
Q.18 Robotics can be defined as the science associated with the ___________,_________ , 1
theory and application of robots.
Q.19 __________provides a platform or environment to develop, test and delivers software 1
application.
Q.20 Name the technology works on the concept of decentralized and shared database. 1
PAGE
44
Q.21 Differentiate between CHAR and VARCHAR Datatypes. 1
PART A
SECTION II
Two case studies questions. Each case study has 4 case-based subparts.
Attempt any 4 out of the 5 subparts.
Q22 a)Display EmpNo and EName of all employees from the table empl. 1
b)Display employee name, salary, and department number who are not getting 1
commission from table empl.
c)Display employee number, name, sal*12 as Annual salary whose commission is 1
NULL from table empl.
d)Give degree and cardinality of the above table. 1
e)Display the details of all employee whose annual salary is between 25000 to 40000 1
Q23. a)Using SQL statements in MySQL, create the Database Name: Univ also write a 1
query to open the database Univ.
Answer parts b), c), d) on the basis of the structure table job.
Name of ColumnType
Job_IDInteger(4)
Job_desVarchar(30)
Alloc_on Date
Due_on Date
Emp_idInteger(4)
b)Create a table Job with the specification given above. 1
c)Identify the primary and alternate key. 1
d)Insert 4 records into the table Job. 1
e)How will you enlist the name of database and the tables in a database? 1
PART B
SECTION-I
Short answer questions of 2 marks each in which two questions have internal
options.
Q24. Explain Where and ORDER BY clause with proper examples. 2
PAGE
45
Q.25 What are the different divisions of SQL commands? Give example 2
Q. What is the error in following code. Rewrite the correct code and underline the 2
26. correction.
Weather=’raining’
If weather=’sunny’
print(‘wear sunblock’) elif
weather=’snow’:
print(‘Going skiing’) else:
print(“None of the above’)
Q 27. Write the corresponding Python assignment statement. 2
c) Assign 10 to a variable height and 20 to a variable weight.
d) Assign the sum of height and weight to a variable total.
Q28. (Attempt any 2) 2
What will be the output of the following ?
e) print(17//4)
f) print(17/4)
g) print(14%4)
h) 14.0//4
Q29. c) Identify the different types of following python literals and place them in correct 1
type.
23.789 “TRUE”
1232
False 1
d) What are comments? Why do we use comments in Python Programming?
Explain with Example.
OR 2
Write a Python Program which input five numbers and display their average.
Q30. What do you mean by FOSS? Give two examples of any two FOSS. 2
OR
What do you mean by Proprietary Software? Give examples of any two Proprietary
Software.
Q 31. Siyahas discarded old, broken and malfunctioning Hard Disk without taking care to 2
delete data. Is it harmful in respect of security concern ? Justify your answer.
Q 32 Write the output of the following: 2
L=[10,20,30,40], L1=[500,600] , L2=[35,45]
L1.extend(L2)
L.insert(25,2)
print (L1+L2)
print (L1) print
(L.index(30))
print (L2*2)
Q 33. c) How is clear() function different from del Statement? 1
d) What is the output produced by the following code – d1={5: 1
[6,7,8],”a”:[1,2,3]} print(d1.keys())
print(d1.values())
PAGE
46
PART B
SECTION II
Long answer questions of 3 marks each in which one question has question has
internal option.
Q 34. c) How Primary Memory is different from Secondary Memory? Explain at least 4 2
differences.
d) What is Big Data? Name its 3 characteristics. 1
OR
L=["Hello",[6,7,8],3,"Riya"]
Consider the above list and answer the
following print(L[3:]) print(L[::2]) print(L[1:2])
print(L[1][1])
Q 36. Consider the “Sales” table in mysql: 3
Ecode Ename Address dojoin Amount Area
100 Amit Delhi 2017/09/29 5000.90 East
101 Sushant Gurgaon 2018/01/01 7000.75 East
102 Priya Noida 2018/04/25 3450.45 West
103 Mohit Delhi 2018/11/03 6000.50 North
104 Priyanshi Delhi 2019/12/15 8000.62 North
d) To display the employee name and amount for east area.
e) Which of the following command(s) will display all sales whose date of joining is
after 31st March 2018.
i. Select * from Sales where dateofjoin>=”31-03-2018”;
ii. Select * from Sales where dojoin>=”2018-03-31”;
iii. Select * from Sales where dojoin>”2018-03-31”;
iv. Select * from Sales where dojoin>”2018/03/31”;
f) Write a sql query to display the name of the oldest employee first then 2nd oldest
and so on.
Q 37. Give the output of the following queries based on the table mentioned in previous 3
question.
d) select Area, Ename as Employee, amount *0.01 as PF from Sales where
Area=”East” OR Area=”West;
e) select Ename, amount from sales where amount between 5000 and 7000;
f) select * from sales where dojoin>”2019-12-15” OR dojoin<”2017-09-29”;
PART B
SECTION III
Very long answer questions of 5 marks each in which one question has question has
internal option.
Q 38. WAP to create a dictionary named year whose keys are month names and values are their 5
corresponding number of days and display the dictionary (Use While loop)
PAGE
47
OR
WAP that repeatedly asks the user to enter product names and prices. Store all of them
in a dictionary whose keys are product names and values are prices. And also write a
code to search an item from the dictionary.
Q 39. Suppose your school management has decided to conduct cricket matches between 5
students of class XI and Class XII. Students of each class are asked to join any one of
the four teams — Team Titan, Team Rockers, Team Magnet and Team Hurricane.
During summer vacations, various matches will be conducted between these teams.
Help your sports teacher to do the following(Using SQL)
c) Create a database “Sports”.
d) Create a table “TEAM” with following considerations:
• It should have a column TeamID for storing an integer value between 1 to 9,
which refers to unique identification of a team.
• Each TeamID should have its associated name (TeamName), which should be a
string of length not less than 10 characters.
f) Show the structure of the table TEAM using SQL command.
g) As per the preferences of the students four teams were formed as given below.
Insert these four rows in TEAM table:
Row 1: (1, Team Titan)
Row 2: (2, Team Rockers)
Row 3: (3, Team Magnet)
Row 4: (4, Team Hurricane)
h) Show the contents of the table TEAM.
Q 40. Write a Python Program to print following Pattern using print statement (using loops) 5
*
**
***
****
*****
OR
55555
4444
333
22
1
PART A
SECTION I
Attempt any 15 questions from 21 questions
1 What is the smallest unit of memory? 1
(a) bit (b) byte (c) Nibble (d) KB
Ans: (a) bit
2 Use of transistors started in ...................... 1
(a) First Generation
(b) Second Generation
(c) Third Generation
(d) Fourth Generation
Ans: (b) Second Generation
3 CPU is combination of ................ 1
(a) Input and CU
(b) ALU and CU
(c) Input and Output
(d) ALU and Input
Ans: ALU and CU
4 What is the correct order? 1
(a) Bytes>KB>MB>TB
(b) GB>MB>KB>Bytes
(c) MB>Bytes>KB>Bit
(d) KB>GB>Byts>MB
PAGE
49
5 Washing Machine is example of 1
(a) Single User OS
(b) Multi User OS
(c) Real Time OS
(d) Embeded OS
PAGE
50
14 Which function is used to print all the keys of dictionary? 1
(a) Values()
(b) Keys()
(c) Items()
(d) None of these
PAGE
51
Ans: (b) keys()
15 Which of the followings is DDL command : 1
(a) insert
(b) select
(c) create
(d) delete
Ans: (c) create
16 What is missing in following query: 1
Insert into employee ……….. (‘e01’, ‘Satya’, ‘Bombay’);
Ans: values
17 A table may contain more than one primary keys. (True/False) 1
Ans: False
18 The column of a table that points to the primary is : 1
(a) Primary Key
(b) Foreign Key
(c) Candidate Key
(d) Alternate Key
Ans: (b) Foreign key
19 MySQL is a ………… 1
(a) RDBMS
(b) DBMS
(c) Database
(d) Table
Ans: (a) RDBMS
20 In Like % and _ are : 1
(a) Clauses
(b) Commands
(c) Wild Cards
(d) All of these
Ans: (c) Wild Cards
21 Alphanumeric values are supported by which data type? 1
(a) CHAR
(b) DATE
(c) VARCHAR
(d) INTEGER
SECTION II
Both the case study based questions (22 & 23 ) are compulsory. Attempt any four sub parts from
each question. Each sub question carries 1 mark .
PAGE
52
22 Mrs. Vidya has created a list of marks of six students in her subject. List is as follows.
Consider the following list and give answer of any four questions from (i) to (v).
L = [45, 99, 80, 60, 86, 91]
(i) She wants to display marks in ascending order. Help her to write code to display marks in 1
ascending order.
Ans: print(L.sort())
NO NAME TDATE KM
101 Janish Kin 2015–11–13 200
105 Tarun Ram 2016–03–23 350
PAGE
53
(ii) 1
Out of the following queries, which query will give the above output?
PAGE
54
(a) Select * from travel where km>200;
(b) Select * from travel where km>=200;
(c) Select no, name, tdate, km from travel where km>=200;
(d) Select no, name, tdate, km from travel where km between 200 and 350;
Ans: (d) Select no, name, tdate, km from travel where km between 200 and 350;
(iii) Neelima has given the following command to arrange the data in ascending order of date. 1
Select * from travel where order by tdate;
but she is not getting the desired result. Help her by choosing the correct command.
Select * from travel order by tdate;
(a) Select * from travel in ascending order;
(b) Select tdate from travel order by tdate;
Ans: (a) Select * from travel order by tdate;
(iv) Choose the correct command to display the name of the traveller whose travel date is after 1
2015?
(a) select name, tdate from travel where tdate > 2015;
(b) select name, tdate from travel where tdate < ‘2015-12-31’;
(c) select name, tdate from travel where tdate > ‘2015-12-31’;
(d) select * from travel where tdate < ‘2015-12-31’;
Ans: (c) select name, tdate from travel where tdate > ‘2015-12-31’;
(v) Which query is correct to display following output: 1
Janish Kin
John Fen
Ahmed
Khan
PAGE
56
27 Write a program to print factorial of given number. 2
Ans: num = int(input("enter a number:
")) fact = 1.
for i in range(1, num +
1): fact = fact * i.
print("factorial of ", num, " is ", fact)
OR
Write a program to print largest number in given three numbers.
Ans: n1= int(input("Enter first number"))
n2 = int(input("Enter second
number")) n3 = int(input("Enter
third number")) if(n1 >= n2) and
(n1>=n3):
Max = n1
elif (n2 >=n1) and (n2>= n3):
Max = n2
else:
Max = n3
28 Find error in following code. Correct it and underline the corrections. 2
x= int(“enter value”))
For i in
range(0,11) if x
= i:
print(x+y
) else:
Ans: x= int(input(“enter value”))
for i in range(0,11):
if x ==
i: print(x+y)
else:
print(x-
29 y)
Suppose there is a table named student with 4 rows and 5 columns. 2 more rows added and one 2
column deleted from the table. What will be degree and cardinality of table student?
Ans: Degree: 4 Cardinality: 6
30 Write following query in alternate way that will give same result. 2
Select * from student where marks = 60 or marks = 80 or marks = 90 or marks = 100;
Ans: select * from student where marks in(60,80,90,100);
31 Write any two advantages of SQL. 2
Ans.: 2 Marks for any 2 correct advantages
OR
What is difference between DDL and DML?
PAGE
57
Ans: DDL DML
PAGE
58
1. Data definition language 1. Data manipulation language
2. These commands work on structure 2.These commands work on the
of table content of the table
3. Example: Create, drop 3.insert, select
32 Identify datatype of columns in following table: 2
Ans.: (i) Data Redundancy: Redundancy means same data are duplicated in different places (files).
(ii) Data inconsistency: Data inconsistency occurs when same data maintained in
different places do not match.
SECTION II
34 Write brief note on followings: 3
a. Data capture b. Data Storage c. Data retrieval
Ans: a.Data capture: It Involves the process of gathering data from different sources in digital
form. b.Data Storage: It is the process of storing the captured data for processing.
c.Data Retrieval: It involves fetching the data from the storage devices for its processing as
per user requirement.
OR
Draw block diagram of Computer.
PAGE
59
Ans:
35 Write a Python program to find sum of all elements of a given list using for loop. 3
Ans.: L=[ ]
sum1=0
n = int(input(“Enter the number of elements”))
for i in range(n):
items = int(input(“Enter element”))
L.append(items)
Sum1 =
sum1+L[i]
print(L)
OR
Write a program that takes a list ‘L’ as an argument, adds 5 in all odd values and 10 in all even
values of the list L. Also display the list.
Ans.: L = [10,20,3,100,65,87,2]
for i in range(len(L)):
if L[i]%2==0:
L[i]=L[i]+10
else:
L[i]=L[i]+5
print(L)
36 Define below database concepts 3
a. Tuple
b. Data Redundancy
c. DML Commands
Ans: a. A tuple is simply a row in a table
b. Data redundancy occurs when the same piece of data exists in multiple places or Duplicate
entries of the customer name is considered redundant data
c. Data manipulation language (DML) statements add, change, and delete Database table
data eg insert,delete,insert etc.
PAGE
60
37 Consider the following tables product and sales, identify the primary keys of both tables and 3
foreign key.
PAGE
61
BILLNUMBER BILLDATETABLE : SALES
PRODUCTCODE QTY AMOUNT
79 03/03/2020 P1101 3 124
69 03/03/2020 K750 2 345
86 03/03/2020 K750 1 343
85 03/03/2020 P12 5 232
Ans: Primary Keys: PRODUCTCODE IN PRODUCTS TABLE
BILLNUMBER IN SALES
TABLE Foreign Keys: PRODUCTCODE IN
SALES TABLE SECTION III
38 Create a dictionary named cities with following details: 2
City names are keys: Indore, Khandwa, Bhopal, Agra, Umaria
Pincodes are values: 452001, 450001, 462001, 453115,453331
Ans.: cities = {‘Indore’:452001,’Khandwa’:450001,’Bhopal’:462001,’Agra’:453115, ’Umaria’:453331}
On the basis of above created dictionary cities, answer following questions:
(i) Remove Khandwa from dictionary Cities. 1
Ans.: cities.pop('Khandwa')
(ii) Write code to check whether Agra is present in dictionary or not. 1
PAGE
63
(i) Display the details of KVs whose StationCode between 300 and 500. (300 and 500
exclusive)
Ans.: select * from KV where StationCode >300 and Statoncode<500;
(ii) Display the details of KVs whose name ends with AFS.
Ans: select * from KV where KVName like “%AFS”;
(iii) Print the details of KVs of Jaipur region.
Ans.: select * from KV where Region = ‘Jaipur’;
(iv) Print the Stationcode and Region of KVs which are not situated in Ahmedabad region.
Ans.: select Stationcode from KV where not Region = ‘Ahmedabad’;
(v) Display records of table in descending order of KVCode.
Ans.: select * from KV order by KVCode desc;
OR
On the basis of following table product answer question (i) to (v).
Table: PROUDCT
PID Productname Manufacturer Price
TP01 Talcum Powder LAK 40
FW05 Face Wash ABC 45
BS01 Bath Soap ABC 55
SH06 Shampoo XYZ 120
FW12 Face Wash XYZ 95
PAGE 10
Ans.: Cloud computing is the delivery of different services through the internet. These resources
include tools and applications like data storage, servers, databases, networking and
software. Types of Cloud Computing:
1. IAAS (Infrastructure as a Service),
PAGE 10
2. PAAS(Platform as a Service),
3. SAAS(Software as a service)
What is virtual reality? 1
s.: Virtual Reality (VR) is a three-dimensional, computer-generated situation that simulates the
real world.
Page 2 of 5
(b) immutable, mutable (d) immutable, immutable
12. Which method is used to remove list elements? 1
13. Dictionary keys can be repeated. (True/False) 1
14. Which function is used to print all the keys of dictionary? 1
(a) Values() (c) Items()
(b) Keys() (d) None of these
15. Which of the followings is DDL command? 1
(a) Insert (c) create
(b) Select (d) delete
16. What is missing in following query: 1
Insert into employee ……….. (‘e01’, ‘Satya’, ‘Bombay’);
17. A table may contain more than one primary keys. (True/False) 1
18. The column of a table that points to the primary is: 1
(a) Primary Key (c) Candidate Key
(b) Foreign Key (d) Alternate Key
19. MySQL is a ………… 1
(a) RDBMS (c) Database
(b) DBMS (d) Table
20. In Like % and _ are: 1
(a) Clauses (c) Wild Cards
(b) Commands (d) All of these
21. Alphanumeric values are supported by which data type? 1
(a) CHAR (c) VARCHAR
(b) DATE (d) INTEGER
Section – II
Both the case study-based questions (22 and 23) are compulsory. Attempt any four sub parts
from each question. Each sub question carries 1 mark.
22. Mrs. Vidya has created a list of marks of six students in her subject. List is as follows.
Consider the following list and give answer of any four questions from (i) to (v).
L = [45, 99, 80, 60, 86, 91]
(i) She wants to display marks in ascending order. Help her to write code to display marks in 1
ascending order.
(ii) Which output is correct for following code: 1
Print(L[2:6])
(a) [99,80,60,86,91] (c) [80,60,86,91]
(b) [45,99,80,60,86,91] (d) None of these
(iii) She wants to delete 60 from list. What will be statement for this? 1
(iv) She wants to add a new element in list i.e. 100 at position 3. What is the correct statement 1
for this?
(a) L.append(3,100) (c) L.insert(3,100)
(b) L.extend(3,100) (d) None of these
(v) What will output of following: 1
Print(L*3)
23. On the basis of table Travel as given below, answer any four questions out of (i) to (v).
NO NAME TDATE KM CODE NOP
101 Janish Kin 2015–11–13 200 101 32
103 Vedika Sahai 2016–04–21 100 103 45
105 Tarun Ram 2016–03–23 350 102 42
102 John Fen 2016–02–13 90 102 40
107 Ahmed Khan 2015–01–10 75 104 2
104 Raveena 2016–05–28 400 105 4
Page 3 of 5
(i) Write sql query to create above table Travel. (Take data types according to values in 1
columns).
1
Page 4 of 5
(ii) NO NAME TDATE KM
101 Janish Kin 2015–11–13 200
105 Tarun Ram 2016–03–23 350
Out of the following queries, which query will give the above output?
(a) Select * from travel where km>200;
(b) Select * from travel where km>=200;
(c) Select no, name, tdate, km from travel where km>=200;
(d) Select no, name, tdate, km from travel where km between 200 and 350;
(iii) Neelima has given the following command to arrange the data in ascending order of date. 1
Select * from travel where order by tdate;
but he is not getting the desired result. Help her by choosing the correct command.
Page 5 of 5
30. Write following query in alternate way that will give same result. 2
Select * from student where marks = 60 or marks = 80 or marks = 90 or marks = 100;
Page 6 of 5
31. Write any two advantages of SQL. 2
OR
What is difference between DDL and DML?
32. Identify datatype of columns in following table: 2
TABLE : SALES
BILLNUMBER BILLDATE PRODUCTCODE QTY AMOUNT
79 03/03/2020 P1101 3 124
69 03/03/2020 K750 2 345
86 03/03/2020 K750 1 343
85 03/03/2020 P12 5 232
SECTION III
38. Create a dictionary named cities with following details: 2
City names are keys: Indore, Khandwa, Bhopal, Agra, Umaria Pincodes are
values: 452001, 450001, 462001, 453115,453331
On the basis of above created dictionary cities, answer following questions:
(i) Remove Khandwa from dictionary Cities. 1
(ii) Write code to check whether Agra is present in dictionary or not. 1
Page 7 of 5
(iii) Write code to display keys from dictionary 1
39. Write SQL queries for question from (i) to (v) based on the table KV given below: 5
KVCode KVName StationCode Region Zone
1603 Bharatpur 331 Jaipur West
Page 8 of 5
1595 Alwar 324 Jaipur West
1596 Alwar Itarana 324 Jaipur West
1019 Gandhidham IFFCO 11 Ahmedabad West
1020 Gandhidham Railway 11 Ahmedabad West
1769 Avadi AFS 584 Chennai South
1702 Uri 390 Jammu North
1296 Barnala AFS 172 Chandigarh North
(i) Display the details of KVs whose StationCode between 300 and 500.
(ii) Display the details of KVs whose name ends with AFS.
(iii) Print the details of KVs of Jaipur region.
(iv) Print the Stationcode and Region of KVs which are not situated in
Ahmedabad region
(v) Display records of table in descending order of KVCode.
OR
On the basis of following table product answer question (i) to (v).
Table: PROUDCT
PID Productname Manufacturer Price
Page 9 of 5