Xii Cs Question Bank For Bright Students Chapter Wise Set-II

Download as pdf or txt
Download as pdf or txt
You are on page 1of 40

XII CS QUESTION BANK FOR BRIGHT STUDENTS CHAPTER WISE SET-II

CLASS XII COMPUTE SCIENCE (QUESTION BANK - MLL)

CHAPTER -1 PYTHON REVSION TOUR -I

Q.1 State some features of Python.

Ans: - Python is a language which is Easy to use, it is Expressive, Cross Platform and an Open
Source Language.

Q.2 What is a python variable? Identify the variables that are invalid and state the reason

Class, do, while, 4d, a+

Ans: - A variable in python is a container to store data values.

a) do, while are invalid because they are python keyword


b) 4d is invalid because the name can’t be started with a digit.
c) a+ is also not valid as no special symbol can be used in name except underscore. ( _ )

Q.3 What is None?

Ans: - None keyword is used to define a null value or no value at all. None cannot be 0 or empty
string or False.

Eg: - var = None

print(var)

The above code will print None.

Q.4 How strings are represented in Python?

Ans: - Strings in Python are array of bytes representing Unicode characters. There are three ways
to represent a string data in python –

1) Single Line Strings

Eg: - Str1= ‘I Start Learning PYTHON’

2) Multiline strings

1|Page
Eg: - Str2= “Initially I am scaring from Python Language\

But Now Working in Python become Easy for me.”

Str3= ‘’’It is an easy

Language’’’

Q.5 What are the various mutable and immutable data types in Python?

Ans: - The data types which are changeable called Mutable Data Type, and those which are not
changeable called immutable data types.

Mutable Data types of Python are: - list, dictionary, set

Immutable Data Types are: - int, float, complex, string, tuple

Q.6 What is the use of indentation in Python. Explain.

Ans: - Indentation helps to show the beginning and ending of a block.


Eg: - X=10
Y=20
if (X>Y):
print(‘Greater No is =’,X)
else:
print(‘Greater No is =’,Y)

Q.7 Predict the output


for i in range( 1, 10, 3):
print(i)
Ans: - 1
4
7

Q.8 Rewrite the code after correcting errors: -


if N=>0
print(odd)
else
Print("even")

Ans: - if N=>0:
print(“odd”)
else:
print("even")

2|Page
Q.9 What problem occurs with the following code
X=40
While X< 50 :
print(X)
Ans: - The given code does not have the incrementing value of X, thus the loop becomes
endless.

Q.10 Write a program to find average of three numbers.

Ans: -

n1=int(input('Enter first No.'))

n2=int(input('Enter first No.'))

n3=int(input('Enter first No.'))

avg=n1+n2+n3

print('Average of numbers are=',avg)

Output: -

Q.11 Write a program to check if a number is odd or even.

Ans: -

x=int(input('Enter first No.'))

if (x%2==0):

print(x, ' is an Even Number')

else:

3|Page
print(x, 'is an Odd Number')

Output: -

Q.12 Write a program to print numbers from 1 to 10 and 10 to 1

Ans: -

x=int(input('Enter 1 or 10'))

if x==1:

for x in range(1,11):

print(x)

else:

for x in range(10,0,-1):

print(x)

Output: -

***

4|Page
CHAPTER -2 PYTHON REVSION TOUR -II
1. What is a string slice? How is it useful?

Ans: A sub part or a slice of a string , say s , can be obtained using s[n:m] where n and m are
integers. Python returns all the character at indices n, n+1, n+2 ... m-1
e.g. ‘Well done’ [1:4] will give ‘ell’ here index starts from 0.

2. How are list different from strings when both are sequences?

Ans: The list and string are different in following ways:


(i) The lists are mutable sequence while string are immutable.
(ii) String store single type of elements – all characters while list can store element belonging to
different types.

Eg: -

S="PYTHON IS INTERPRETER BASED LANGUAGE"


L=[83, 'Computer Science', 'PYTHON']
print(S)
print(L)

#S[2]='K' # This statement generate error as String is immutable.

print(S)
L[0]=65
L[1]='IP'
print(L)

3. What will be the output of the following code snippet?


values =[ ]
for i in range (1,4):

5|Page
values.apend(i)
print(values)

Ans: [1]
[1 ,2 ]
[1,2,3]

4. Find the error in following code. State the reason of the error.
aLst = { ‘a’:1 ,’ b’:2, ‘c’:3 }
print (aLst[‘a’,’b’])

Ans: The above code will produce KeyError, the reason being that there is no key same as the list
[‘a’,’b’]

in dictionary aLst.

5. How are dictionaries different from list?

Ans: List are ordered collection and Dictionary are unordered collection of elements.

***

6|Page
Chapter – 3 Working with Functions

Q.1) Define a function?

Ans: - It is a sub program that perform some task on the data and return a value.

Q.2) Write a python function that takes two numbers and find their product.

Ans: - def PRODUCT(X,Y):

return (X*Y)

Q.3) Write a python function that takes two numbers and print the smaller number. Also write how to
call this function.

Ans: - def SMALER(A,B):

if(A<B):

print(“Smaller No – “, A)

else:

print(“Smaller No – “, B)

a=int(input(“Enter a number:”))

b=int(input(“Enter another number:”))

SMALLER(a,b)

Q.4) How many values a python function can return? Explain how?

Ans: Python function can return more than one values.

def square_and_cube(X):

return X*X, X*X*X, X*X*X*X

a=3

x,y,z=square_and_cube(a)

print(x,y)

Q.5) Rewrite the correct code after removing the errors: -

def SI(p, t=2, r):

return (p*r*t)/100

7|Page
Ans: - def SI(p, r, t=2):

return(p*r*t) /100

Q.6) Write a small python function that receive two numbers and return their sum, product, difference
and multiplication and modulo division.

Ans: - def ARITHMATIC_OPERTAIONS(a,b):

return a+b, a*b, a-b, a/b, a%b

calling of function: -

a,b,c,d,e=ARITHMATIC_OPERTAIONS(3,4)
print('Sum=',a)
print('Product=',b)
print('Difference=',c)
print('Division=',d)
print('Modulo Division=',e)

Q.7) What is scope of a variable?

Ans: - Part of program within which a name is legal and accessible is called scope of the variable.

Q.8) Explain two types of variable scope with example.

Ans – Global Scope – A name declared in top level segment of a program is said to have global scope
and it is accessible inside whole programme.

Local Scope – A name declared in a function body is said to have local scope and it can be used only
within this function.

A=0 # global scope


8|Page
def fun1():

B=0 # local scope

print(B)

print(A)

Q.9) Consider the following function headers. Identify the correct statement: -

1) def correct(a=1,b=2,c): 2) def correct(a=1,b,c=3):

c) def correct(a=1,b=2,c=3): 4) def correct(a=1,b,c):

Ans: - c) def correct(a=1,b=2,c=3)

Q.10) Find the output of the following code: -

Ans: - def CALLME(n1=1,n2=2):

n1=n1*n2

n2+=2

print(n1,n2)

CALLME()

CALLME(2,1)

CALLME(3)

Ans: - 2 4

23

64

***

9|Page
Chapter-4 Python Library

Q.1) What is Libraries in Python and How many types of main library use in Python?

Ans: -A Library is a collection of modules that together caters to specific types of needs
or applications. Like NumPy library of Python caters to scientific computing needs.

Q.2) How we can import library in Python program?

Ans: - We can import a library in python program with the help of import command.

Eg: - import random

import pandas as pd

Q.3) Give the basic structure of user defined function.

Ans: - def <Function_name>(arguments):

Statements

Eg: - def MEAN(x,y):

Z=(x+y)/2

Print(Z)

Q.4) Create a function in Python to calculate and return Area of rectangle when user
enters length and bredth.

Ans: - def AREA(a,b):

Return(a*b)

Q.5) What is module in Python?

Ans: - A module is a file with .py extension that contains variables, class definitions,
statements and functions related to a particular task.

Q.6) Write the features of a module.

Ans: - 1) Modules can be reused in other programmes

2) It is independent group of code and data

Q.7) Create a package Arithmetic Operations(named AO) contain sum, product and
difference of two numbers and use it in your main programme.

Ans: - def ADD(X,Y):

10 | P a g e
return (X+Y)

def PRODUCT(X,Y):

return(X*Y)

def DIFFERENCE(X,Y):

return(X-Y)

Now lets save this file as AO.py then our module is created now.

Now we are creating our main python file: -

import AO
n1=int(input(‘Enter a Number’))
n2=int(input(‘Enter another Number’))
print(‘Sum = ‘, AO.ADD(n1,n2))
print(‘Difference=’,AO.DIFFERENCE(n1,n2))
print(‘Product=’,AO.PRODUCT(n1,n2))

Output: -

11 | P a g e
***

Chapter-5 File Handling

Q.1 What is a data file in python?

Ans: A bunch of bytes / data stores on some storage device referred by the filename.

Q.2 Differentiate between a text file and a binary file.

Ans: A text file stores data as ASCII/UNICODE characters where as a binary file stores data in
binary format (as it is stored in memory). Internal conversion is required in text file and hence
slower but binary file does not need any translation and faster.

Q.3 What is the significance of a file object or a file handle?

Ans: A file object or file handle establishes a link or a reference to a file

Q.4 What is the use of flush( )?

Ans: Forcefully write data from buffer to file.

Q.5 Name the methods used for reading and writing data from text file.

Ans: read( ), readline( ), readlines( ) for reading data from file and write( ), writelines( ) to write
data to a file

Q.6 What are the various file opening modes?

r – read only, w – write only, a – append

rb – read in binary mode, w – write in binary mode, a – append in binary mode

r+ , rb+ : read and write, w+, wb+ , a+ , ab+ : write/append and read

Q.7 What is the significance of close( )?

Ans: When a file is closed data from buffer gets written onto the file on the disk and link from file
is removed. It ensures that data is saved in the file.

Q8. Write a python code to write some text to a file Lines.txt.

Ans: # writing data to file


f=open(‘Lines.txt’,’w’)
s=input(‘Enter text ‘)
f.write(s)
f.close( )

12 | P a g e
Q.9 Write a python code to find the size of the file in bytes, number of lines and number of
words.

# reading data from a file and find size, lines, words


f=open(‘Lines.txt’,’r’)
str=f.read( )
size=len(str)
print(‘size of file n bytes’,size)
f.seek(0)
L=f.readlines( )
word=L.split( )
print(‘Number of lines ’,len(L))
print(‘Number of words ’,len(word))
f.close( )

Q.10. What does stdin, stdout represent?

Ans : stdin represent standard input device and stdout represent standard output device which
are represented as files.

***

13 | P a g e
CHAPTER -6 RECURSION

Q.1 What is recursion in Python?

Ans: Recursion is the process of defining something in terms of itself. We know that in Python,
a function can call other functions. It is even possible for the function to call itself. These types of
construct are termed as recursive functions.

Q.2 What are the advantage and disadvantage of recursion?

Ans: Advantages of Recursion:

1) Recursive functions make the code look clean and elegant.


2) A complex task can be broken down into simpler sub-problems using recursion.
3) Sequence generation is easier with recursion than using some nested iteration.

Disadvantages of Recursion:

1. Sometimes the logic behind recursion is hard to follow through.


2. Recursive calls are expensive (inefficient) as they take up a lot of memory and time.
3. Recursive functions are hard to debug.

Q.3) Write recursive code to compute the factorial of an integer.

Ans:

def calc_factorial(x):

if x == 1:
return 1
else:
return (x * calc_factorial(x-1))

num = 4
print("The factorial of", num, "is", calc_factorial(num))

Q.4) Write program to find the H.C.F of two input number

Ans:

def computeHCF(x, y):


if x > y:
smaller = y
else:
smaller = x
14 | P a g e
for i in range(1, smaller+1):
if((x % i == 0) and (y % i == 0)):
hcf = i

return hcf

num1 = 54
num2 = 24
print("The H.C.F. of", num1,"and", num2,"is", computeHCF(num1, num2))

Q.5) Write Python program to find the sum of natural numbers up to n using recursive function.

Ans:

def recur_sum(n):
if n <= 1:
return n
else:
return n + recur_sum(n-1)
num = 16
if num < 0:
print("Enter a positive number")
else:
print("The sum is",recur_sum(num))

***

15 | P a g e
Chapter-7 Idea of Algorithmic Efficiency

Q.1 What is an Algorithm?

Ans: An Algorithm is a step by step process of solving any problem.

Q.2 What do you mean by complexity of an algorithm? How it is measured?

Ans: Complexity is a measure of efficiency of algorithm. It can be measured in terms of time


required to execute an algorithm and/or memory space required for execution of an algorithm

Q.3 What factors determine the complexity of an algorithm?

Ans. The factors determining complexity of an algorithm are Time for execution and Memory space
required during execution.

Q4. How we determine time complexity of an algorithm?

Ans: We determine the time complexity as the number of elementary instruction that it executes
with respect to some given input size.

Q.5 What are - best case & worst case?

Ans: Best case means best possible performance (say minimum time required) of an algorithm. It
indicates the optimal time of performance of any algorithm.

Worst case means the worst possible performance (say maximum possible time required) of an
algorithm. It provides an upper bound on running time.

Example : for a binary search the best case for an input size of N is when it is sorted

and the worst case is when it is unsorted.

Q.6 What does Big-O notation indicate?

Ans: Big-O notation indicates an algorithm’s growth rate which in turn determines the algorithm’s
performance with increase in the input size.

Q7. Give the meaning of O(1), O(N), O(log N)

Ans: O(1) means an algorithms requires a constant time for its execution e.g. pushing an element
at the top of a stack

O(N) means an algorithm takes at most N time (or steps) for an input size of N e.g. searching an
element in an array

O(N2) means an algorithm takes at most N2 time (steps) for an input of size N e.g. Sorting an array
using bubble sort

16 | P a g e
Q8. What is a Dominant term?

Ans: As the input size grows it affects the efficiency of an algorithm. While describing the growth
rate, the term that affect the most on algorithm’s performance is called dominant term.

Example : if in an algorithm there are terms with growth rate O(N2) and O(N) then the dominant
term is O(N2)

Q9. Compare the efficiency of linear and binary search algorithms.

Efficiency of binary search is better than that of linear search algorithm when the array is sorted as
the growth rate of binary search is O(log N) which is much smaller than that of linear search O(N).

Q10. State some external factors that may affect an algorithm’s efficiency.

Ans: Size of input, Speed of the computer, Compiler that is used etc.

* **

17 | P a g e
CHAPTER -8 Visualization with Pyplot

Q.1 What is visualization of Data? How to use Pyplot for it?

Ans. Data visualization is the discipline of trying to understand data by placing it in a


visual context so that patterns, trends and correlations that might not otherwise be
detected can be exposed.

# ------- file: myplot.py ------

import matplotlib.pyplot as plt

import numpy as np

x = np.linspace(0, 10, 100)

plt.plot(x, np.sin(x))

plt.plot(x, np.cos(x))

plt.show()

Q.2 Which packages of Python is use to draw 2-D graphics?

Ans. Matplotlib is a Python library developed by John Hunter et al. for drawing 2D graphics.
It takes the advantages of the numerical calculation modules Numeric and Numarray in
Python, and clones many functions in Matlab to help users obtain high-quality 2D graphics
easily. Matplotlib can draw a variety of forms of graphics including usual line graphs,
histograms, pie charts, scatter plots and error bars, etc

Q.3 Which function is to be use for draw a line in Pyplot Python? Give example.

Ans. import numpy as np


x = np.linspace(0,10)
y = x**2
p1 = [1,20]
p2 = [6,70]
plt.plot(x, y)
newline(p1,p2)
plt.show()
Q.4 How can we charge the Line Colors, Width and Style in Pyplot.

Ans. # Plot the distribution of numpy data


plt.hist(exp_data, bins=21, align='left', color='b',
edgecolor='red',
linewidth=1)

18 | P a g e
Q.5 Difference between Line and Bar Chart in Pyplot..

Ans. A line chart or line graph is a type of chart which displays information as a series of
data points called 'markers' connected by straight line segments. Line graphs are usually
used to find relationship between two data sets on different axis; for instance X, Y.

A bar chart or bar graph is a chart or graph that presents categorical data with
rectangular bars with heights or lengths proportional to the values that they represent.
The bars can be plotted vertically or horizontally.

***

19 | P a g e
CHAPTER -9 Data Structures : Linear Lists

Q.1 What do you mean by Data Structure?

Ans: Data Structure means organization of data. A data structure has well defined operations or
behavior.

Q2. How is Data Structure different from Data Type?

Data Structure provides information regarding organization of data where as Data Type provides
information regarding the domain of values and operations that can be perform on data

Q3. Define - Stack, Queue, Tree.

Stack – A stack is a linear list also known as LIFO list with the special property that items can be
added or removed from only one end called the top.

Queue – A queue is a linear list also known as FIFO list with the special property that items can be
added added at one end and removed from the other.

Tree – A non-linear hierarchical organization of data as nodes and links between them where the
topmost node called root and bottom most nodes called leaves.

Q4. Name some linear and non-linear data structures

Linear Data Structures – Lists, Arrays, Stack, Queue

Non Linear Data Structures – Trees, Graphs

Q5. Name some operations commonly performed on data structures?

Ans: Traversal, Insertion, Deletion, Searching, Sorting, Merging etc.

Q6. What is a list?

Ans: A list is a mutable sequence of data elements indexed by their position. A list is represented
using [ ] . e.g L=[10,20,30]

Q7. What is traversing? Write python code to traverse a list.

Ans: Traversing means accessing or visiting or processing each element of any data structure.

#List traversal
L=[10,20,30,40,50]
for x in L :
print(x)

Q8. Name the methods used for inserting and deleting elements from a list.

20 | P a g e
Various methods for inserting elements in a list are - insert(), append(), extend() and methods used
for deleting items from a list are – pop() , remove(), clear()

Q9. Predict the output with respect to the list L=[40,20,30,10,50]


(a) print(L)
(b) print(len(L)
(c) L.pop() ; print(L)
(d L.append(70); print(L)
(e) L.sort(); print(L)

Q10. What is List Comprehension? Explain with an example.


Ans: A concise description of a list, shorthand for list creation.
E.g. L=[x for x in range(1,10,2)]

***

21 | P a g e
CHAPTER -10 DATA STRUCTURE – II : STACK AND QUEUE

1. What is data structure and why do we need it?

Ans: Data structure is a particular way of storing and organizing information in a computer so that
it can be retrieved and used most productively. Different kinds of data structures are meant for
different kinds of applications, and some are highly specialized to specific tasks.

2. what is a stack ? what basic operation can be performed on them?

Ans: A stack is a collection of objects that supports fast last-in, first-out (LIFO) semantics for
inserts and deletes.

Basic operation are:

a) Push – insertion of element


b) Pop – deletion of an element
c) Peek- viewing topmost element without removing
d) Display- view all the element

3. What is queue explain with example?

Ans:

A Queue is a linear structure which follows a particular order in which the operations are
performed. The order is First In First Out (FIFO). A good example of a queue is any queue of
consumers for a resource where the consumer that came first is served first. The difference
between stacks and queues is in removing.

4. What are Application of Stack?

Ans:

1. Expression Evolution
2. Expression conversion
1. Infix to Postfix
2. Infix to Prefix
3. Postfix to Infix
4. Prefix to Infix
3. Parsing
4. Simulation of recursion

***

22 | P a g e
Chapter – 11 Computer Networks – I

Q.1) Differentiate between Client and Server

Ans: - Client – It is a host computer that requests for some services from a server.

Server – It is a computer that responds to the request of the client.

Q.2) How many types of Networks are there?

Ans: - PAN – Personal Area Network

LAN – Local Area Network

MAN – Metropolitan Area Network

WAN – Wide Area Network

Q.3) Differentiate between LAN and WAN?

Ans: - LAN: -

1) Spread over a small area. 2) Less setup cost 3) It is usually a single network

WAN: -

2) Spread over a very large area. 2) High setup cost 3) It is usually a network of many
networks.

Q.4) What is P2P network?

Ans: - They are home networks used in a small companies since they are inexpensive and easy
to install, but they are limited in scope and are difficult to secure.

Q.5) What are the three wired types of network?

Ans: - 1) Twisted pair cable 2) Coaxial Cable 3) Fibre Optic

Q.6) Name any 3 wireless computer networks.

Ans: - 1) Microwave 2) Radio wave 3) Satellite

Q.7) Explain the use of the following terms: NIC, MAC address, WiFi Card, Hub, switch, bridge,
router, gateway, access point

Ans: - NIC – Network interface card attached to each of the workstation and the server, and
helps the workstation to establish the all-important connection with the network.

MAC Address – The NIC manufacturer assigns a unique physical address to each NIC card, which
is known as MAC address. It’s a 6 bytre address separated by colon
23 | P a g e
Eg: 10:B5:03:63:2E:FC

WiFi card – It is either an internal or external Local are network adapter with a built-in wireless
radio and antenna.

Hub – It is a networking device having multiple ports that are used for connecting multiple
computers.

Switch – It is a device that segment a big network into small subnets so that it prevent traffic
overload in a network.

Bridge – It is a device that helps to link two networks together. Bridge can handle with same
protocols.

Router – A router is a network device that forward data from one network to another. It can
handle different protocols.

Gateway – It is a network device that connects dissimilar networks. It establishes an intelligent


connection between a local network and external network with completely different structure.

Access Point – It is also called wireless access point(WAP) which is a hardware device that
establishes connection of computing devices on Wireless LAN with a fixed wire network.

Q.8) What do you know about cloud? How many types of clouds are there?

Ans: - Cloud is a generic term used for internet. Cloud refers to the collection of servers.

Types of clouds: -

1) Private cloud 2) Public Cloud 3) Community Cloud 4) Hybrid Cloud


Q.9) What is IoT?

Ans: - IoT( Internet of Things) is a phenomenon that connects the things to the internet over
wired or wireless connections. Ie it connects a variety of devices to the Internet.

Q.10) What are the different enabling technologies for IoT?

Ans: - 1) RFID – Radio Frequency Identification – This technology uses radio waves to read and
capture information stored on a tag, called RFID tag. RFID tag is a microchip attached to an
antenna. It identifies the tracks the data of the “things”.

2) Sensors – A device that can detect changes in an environment. It helps to collect data
about the status of the “Things”.
3) Smart Technologies – Smart technologies include additional functionalities to take
action and have other processing capabilities as per the requirements.
4) Software – It is also important in the success of a technology as it provide the reusable
solutions for connecting taking actions and solving issue that occurs.
24 | P a g e
5) Efficient Network connectivity – IoT is formed through interconnection of device to
Internet.
***

25 | P a g e
Chapter -12 Networking –II
Q.1 What is Network?

Ans: It is a group of interconnected computers which allow sharing of resources.

Q.2 Explain terms

a. Amplitude

Ans. Amplitude modulation (AM) is a modulation technique used in electronic


communication, most commonly for transmitting information via a radio carrier wave.

b. Collision

Ans. In a half duplex Ethernet network, a collision is the result of two devices on the same
Ethernet network attempting to transmit data at exactly the same time.
Thenetwork detects the “collision” of the two transmitted packets and discards them both.

c. CSMA-

Ans. Code Division Multiple Access

d. Error Detection

Ans. In networking, error detection refers to the techniques used to detect noise or other
impairments introduced into data while it is transmitted from source to destination. Error
detection ensures reliable delivery of data across vulnerable networks.

e. Checksum

Ans. A checksum is a value that represents the number of bits in a transmission message
and is used by IT professionals to detect high-level errors within data transmissions. Prior
to transmission, every piece of data or file can be assigned a checksum value after running
a cryptographic hash function.

Q. 3 Define the use of following with expands

a. Router –

Ans. A router is a networking device that forwards data packets between computer
networks. Routers perform the traffic directing functions on the Internet. Data sent through
the internet, such as a web page or email, is in the form of data packets

b. TCT/IP-

Ans. Transmission control protocol/Internet protocol, TCP/IP is a set of rules (protocols)


governing communications among all computers on the Internet. More specifically, TCP/IP

26 | P a g e
dictates how information should be packaged (turned into bundles of information
called packets), sent, and received, as well as how to get to its destination.

c. URL

Ans. A Uniform Resource Locator, colloquially termed a web address, is a reference to a


web resource that specifies its location on a computer network and a mechanism for
retrieving it. A URL is a specific type of Uniform Resource Identifier, although many people
use the two terms interchangeably.

d. DNS

Ans. He Domain Name System (DNS) is the phonebook of the Internet. Humans access
information online through domain names, like nytimes.com or espn.com. Web browsers
interact through Internet Protocol (IP) addresses. DNS translates domain names to IP
addresses so browsers can load Internet resources.

Q.4 Why we use Ipv4 and Ipv6? Also specify the difference between them.

Ans. The Internet Protocol version 4 (Ipv4) is a protocol for use on packet-switched Link
Layer networks (e.g. Ethernet). Ipv4provides an addressing capability of approximately 4.3
billion addresses. The Internet Protocol version 6 (Ipv6) is more advanced and has better
features compared to Ipv4.

Q.5 Write the name Networks commands and why they use for any two?

Ans. Ipconfig- Ipconfig is a Console Command which can be issued to the Command Line
Interpreter (or command prompt) to display the network settings currently assigned to any
or all network adapters in the machine. This command can be utilised to verify a network
connection as well as to verify your network settings.

ping - Helps in determining TCP/IP Networks IP address as well as determine issues with
the network and assists in resolving them.

***

27 | P a g e
CHAPTER -13 SQL

Q.1 State two advantages of using Databases.

Ans: Databases help in reducing Data Duplication i.e. Data Redundancy and controls Data
Inconsistency.

Q2. Name some popular relational database management systems.

Ans: Oracle, MYSQL, Sqlite, MS-Access etc

Q.3 Define – Relation, Tuple, Degree, Cardinality

Ans: A Relation is logically related data organized in the form of tables.

Tuple indicates a row in a relation.

Degree indicates the number of Columns.

Cardinality indicates the number of Columns.

Q4. What is Data Dictionary?

Ans: Data Dictionary contains data about data or metadata. It represents structure or schema of a
database?

Q5. Name some data types in MySQL

Ans: Char, Varchar, Int, Decimal, Date, Time etc.

Q6. Differentiate between Char and Varchar.

Ans: Char means fixed length character data and Varchar means variable length character data.
E.g. For the data “Computer” Char(30) reserves constant space for 30 characters whereas
Varchar(30) reserves space for only 8 characters.

Q.7 What is a Primary Key?

Ans: A Primary Key is a set of one or more attributes (columns) of a relation used to uniquely
identify the records in it.

Q.8 What is a Foreign Key? What is its use?

Ans: A Foreign key is a non-key attribute of one relation whose values are derived from the primary
key of some other relation. It is used to join two / more relations and extract data from them.

28 | P a g e
Q.9 Write SQL statements to do the following

(a)Create a table Result with two columns Roll and Name with Roll as primary key

CREATE TABLE Result

(Roll INT PRIMARY KEY, Name Varchar(30))

(b)Add a column Marks to Result table

ALTER TABLE Result

ADD (Marks DECIMAL(10,2))

€Insert a record with values 1, “Raj”, 75.5

INSERT INTO Result

VALUES(1,”Raj”,75.5)

(d)Show the structure of Result table

DESCRIBE Result

€Display the records in ascending order of name

SELECT * FROM Result

ORDER BY Name

(f)Display records having marks>70

SELECT * FROM Result

WHERE Marks > 70

(g)Update marks of ,”Raj” to 80

UPDATE Result

SET Marks = 80

WHERE Name=”Raj”

29 | P a g e
Q10. What are the various Integrity Constraints?

Ans: Various Integrity Constraints are –

NOT NULL – Ensures value for the column is not left unassigned

UNIQUE – ensures that all values in a column are distinct or no two rows can have the same values for a
column having UNIQUE constraint

CHECK – Ensures that values for a particular column satisfy the specified condition

DEFAULT – Ensures that the default value is assumed if value for the column is not specified

PRIMARY KEY – Automatically applies UNIQUE and NOT NULL for uniquely identifying rows / records in a
table
***

30 | P a g e
CHAPTER -14 MORE ON SQL

1. What is ORDER BY CLAUSE in SQL?

Ans: The ORDER BY statement in sql is used to sort the fetched data in either ascending or
descending according to one or more columns.

By default ORDER BY sorts the data in ascending order. We can use the keyword DESC to sort
the data in descending order and the keyword ASC to sort in ascending order.
Syntax of all ways of using ORDER BY is shown below:

SELECT * FROM table_name ORDER BY column_name ASC|DESC

2. what is Aggregate function in MYSQL?

Ans: Aggregate Functions are all about Performing calculations on multiple rows Of a single
column of a table And returning a single value.

The ISO standard defines five (5) aggregate functions namely;

1) COUNT
2) SUM
3) AVG
4) MIN
5) MAX

3. What is group by clause in MYSQL?

Ans: The GROUP BY clause groups a set of rows into a set of summary rows by values of
columns or expressions. The GROUP BY clause returns one row for each group. In other words,
it reduces the number of rows in the result set.
The GROUP BY clause is an optional clause of the SELECT statement. The following illustrates
the GROUP BY clause syntax:

SELECT
c1, c2,..., cn, aggregate_function(ci)
FROM
table
WHERE
where_conditions
GROUP BY c1 , c2,...,cn;

31 | P a g e
4. Consider the following tables DRESS and MATERIAL. Write SQL commands for the statements (i)
to (iv) and give outputs for SQL queries (v) to (viii).

Table : DRESS
DCODE DESCRIPTION PRICE MCODE LAUNCHDATE
10001 FORMAL SHIRT 1250 M001 12–JAN–08
10020 FROCK 750 M004 09–SEP–07
10012 INFORMAL SHIRT 1450 M002 06–JUN–08
10019 EVENING GOWN 850 M003 06–JUN–08
10090 TULIP SKIRT 850 M002 31–MAR–07
10023 PENCIL SKIRT 1250 M003 19–DEC–08
10089 SLACKS 850 M003 20–OCT–08
10007 FORMAL PANT 1450 M001 09–MAR–08
10009 INFORMAL PANT 1400 M002 20–OCT–08
10024 BABY TOP 650 M003 07–APR–08

Table : MATERIAL

MCODE TYPE
M001 TERELENE
M002 COTTON
M004 POLYESTER
M003 SILK

(i) To display DCODE and DESCRIPTION of an each dress in ascending order of DCODE.
(ii) To display the details of all the dresses which have LAUNCHDATE in between 05–DEC–07 and
20–JUN–08 (inclusive of both the dates).
(iii) To display the average PRICE of all the dresses which are made up of material with MCODE as
M003.
(vi) To display material wise highest and lowest price of dresses from DRESS table.
(Display MCODE of each dress along with highest and lowest price)
(v) SELECT SUM (PRICE) FROM DRESS WHERE MCODE=‘M001’;
(vi) SELECT DESCRIPTION, TYPE FROM DRESS, MATERIAL WHERE DRESS. DCODE=MATERIAL. MCODE
AND DRESS. PRICE>=1250;
(vii) SELECT MAX(MCODE) FROM MATERIAL;
(viii) SELECT COUNT(DISTINCT PRICE) FROM DRESS

32 | P a g e
Ans: -

(i) SELECTGCODE, DESCRIPTION FROM GARMENT ORDER BY GCODE DESC;


(ii) SELECT * FROM GARMENT WHERE READYMADE BETWEEN (08–DEC–07, 16–JUN–08);
(iii) SELECT AVG(PRINCE) FROM GARMENTG, FABRIC F WHERE G. FCODE= F.CODE AND F. FCODE
= FO3;
(iv) SELECT F. FCODE, GPRICE FROM GARMENT G, FABRIC F
GROUP BY F. FCODE ORDER BY G. PRICE DESC;
(v) 1600

(vi) DESCRIPTION TYPE


INFORMAL SHIRT COTTON
INFORMAL PANT COTTON
FORMAL PANT POLYSTER
(vii) MAX () selects Numeric value not alphanumeric value. So, its error.
(viii) 7

5.What is the difference between WHERE and HAVING clauses?

Ans: The WHERE clause is used to filer rows from a results.

SELECT COUNT(SalesOrderID) FROM Sales.SalesOrderDetail

This quesry will return 121,317 as the count, whereas, the query

SELECT COUNT(SalesOrderID) FROM Sales.SalesOrderDetail WHERE UnitPrice > 200

Returns 48,159 as the count. This is because the WHERE clause filters out the 73,158 SalesOrderDetails
whose UnitPrice is less than or equal to 200 from the results.

HAVING Clause

The HAVING clause is used to filter values in a GROUP BY. You can use them to filter out groups such as

SELECT SalesOrderID, SUM(UnitPrice * OrderQty) AS TotalPrice

FROM Sales.SalesOrderDetail

GROUP BY SalesOrderID

HAVING SalesOrderID > 50000

***

33 | P a g e
Chapter – 15 Creating a Django based Basic Web Application

Q.1) What is Django?

Ans: - Django is a web framework used with Python to develop Dynamic Websites. Here web framework
is actually a software tool that helps to build and run Dynamic websites and web – enabled applications.

Q.2) How a web works?

Ans: - A Web works in the form of Client -Server architecture. Web browser acts as a client programme
and the web server interacts as the server.

Q.3) Which protocol widely used by the clients of web ie web browsers?

Ans: - Mostly web browsers work with Hyper Text Transfer Protocols (HTTP)

Q.4) Explain the working of HTTP GET and HTTP POST request?

Ans: - HTTP GET : - Whenever a web client has to display a webpage it calls the HTTP GET request and
send the URL of the webpage. The server receives the GET request and respond by sending HTML of the
URL, if available; but if the URL is not existing it sends error 404.

HTTP POST : - An HTTP POST request is a way to send data to the server using HTML forms over web.

Q.5) Write the characteristics of Django?

Ans: - 1) Django is Python based free and Open Source web application framework.

2) Django is powerful server-side web framework used by many developers as it is versatile, Portable and
Secure.

Q.6) What do you know about Virtualenv?

Ans: - Virtualenv is a useful tool which creates isolated Python Environment that take care of
interdependencies and let us develop different applications in isolation.

Each isolated environment has different set of libraries unlike a common global set of libraries.

Q.7) Differentiate between a project and an app?

Ans: - A project refers to an entire application. There can be multiple apps in a project.

Whereas, an app is a submodule which take cares of one part of the project.

Q.8) Write the use of the following files: -

admin.py, apps.py, models.py, tests.py, views.py, migrations/

Ans: - 1) admin.py – It is a configuration file for the build in Django Admin app

34 | P a g e
2) apps.py - It is a configuration file for the app itself

3) models.py - It is the file where we will define the database models.

4) tests.py – This file is for our app-specific tests

5) views.py – This file is for resolving http request/response for our web app

6) migrations/ - This folder keeps track of changes in models.py file and updates database accordingly.

Q.9) Explain MVC Project Architecture.

Ans: - MVC ie Model, View Controller Architecture.

Here Model is the lowest level of pattern responsible for maintain data.

View is responsible for displaying all or a portion of data to the user.

Controller is the software code that controls the interaction between the Model and View.

Q.10) Explain MVT Project Architecture of Django.

Ans: - MVT is Model, View Template architecture which is slightly different from MVC. In fact the main
difference between the two patterns is that Django itself takes care of the controller part (Software
code) and leaving us with the template. The template is a HTML file mixed with Django Template
Language (DTL).

The develop provides the model, the view and the template then just maps it to a URL and Django does
the magic to serve it to the user.

***

35 | P a g e
Chapter -16 Data Base Connectivity

Q.1 What is database.

Ans. The database is a collection of organized information that can easily be used,
managed, update, and they are classified according to their organizational approach.

Q.2 write the steps of connectivity between SQL and Python

Ans.

Q.3 What is result set? Explain with example.

Ans. Fetching rows or columns from result sets in Python. The fetch functions in the ibm_db
API can iterate through the result set. If your result set includes columns that contain large
data (such as BLOB or CLOB data), you can retrieve the data on a column-by-column basis
to avoid large memory usage.

Q.4 Use of functions in connectivity - INSERT,READ, UPDATE, DELETE, ROLLBACK

Environment Description
Variables

INSERT It is an SQL statement used to create a record into a table.

READ Fetches useful information from the database.

UPDATE It is used update those available or already existing record(s).

DELETE It is used to delete records from the database.


Ans.

36 | P a g e
ROLLBACK It works like "undo", which reverts all the changes that you have made.

Q.5 Write code for database connectivity

Ans. # importing the module

import MySQLdb
# opening a database connection
db = MySQLdb.connect ("localhost","testprog","stud","PYDB")
# define a cursor object
cursor = conn.cursor
# drop table if exists
Cursor.execute("IF STUDENT TABLE EXISTS DROP IT")
# query
sql = "CREATE TABLE STUDENT (NAME CHAR(30) NOT NULL, CLASS CHAR(5), AGE
INT, GENDER CHAR(8), MARKS INT"
# execute query
cursor.execute(sql)
# close object
cursor.close()
# close connection
conn.close()

***

37 | P a g e
Chapter – 17 Society, Law and Ethics

Q.1) which of the following can be termed as intellectual property – Washing Machine, Music
Composition, Mixer Grinder, Email account

Ans: - Music Composition, Email Account

Q.2) In a multi national company Mr. A steals Mr. B’s intellectual work and representing it as A’s own
work without citing the source of information, which kind of act this activity be termed as?

Ans: Plagiarism

Q.3) Give any two examples of Digital Property.

Ans: - 1) Online personal account such as email, communication account, social media account, shopping
accounts, online storage accounts

2) Intellectual Property including copyright material, trademarks, patents and any software or code that
a programmer may have written and own etc.

Q.4) Expand the following terms: - OSS, FSF, OSI, W3C, FLOSS, GNU, GPL, LGPL

Ans: - OSS – Open Source Software FSF – Free Software Foundation

OSI - Open Source Initiatives W3C – World Wide Web Consortium

FLOSS – Free Libre Open Source Software GNU – GNU’s Not Unix

GPL - General Public License LGPL – Lesser General Public License

Q.5) Differentiate between Public Domain Software and Proprietary Software with . example.

Ans: - Public Domain Software: -

1) It is free and can be used without restriction

2) It is outside the scope of copyright and licensing.

Proprietary Software: -

1) It is neither free nor available for public

2) It has a proper license and user has to buy that license in order to use it.

Q.6) How you can check weather a website is safe or not?

Ans: - A Safe website has a pad lock sigh that shows safe connection to the website. A safe website url
stars with https:// and not with http://

Q.7) What do you know about cyber/digital forensics?


38 | P a g e
Ans: - Cyber/Digital Forensics refers to methods used for Interpretation of computer media for digital
evidence. It is a process that interprets electronic data for use in a court of law. The goal of the process is
to preserve any evidence in its original form while performing a structural investigation by collecting,
identifying and validating the digital information for the purpose of reconstructing past events.

Q.8) What is cyber law and IT Act?

Ans: - Cyber Law refers to all legal and regulatory aspects of Internet and the world wide web. It is
important as it touches almost all aspects of transactions and activities related to Internet, www and
cyber space.

In India the cyber law is enforced through IT act whose purpose is to provide legal recognition to
electronic commerce, focus on information security etc.

Q.9) Explain some major benefits of ICT in the Business World.

Ans: - 1) Secure Transaction – Fund transfer at anywhere in the world with a greater security is one of
the major benefits of ICT in the Business World.

2) Global Market – Nowadays with ICT a small business can be done from any part of the world.

3) Net Banking – With Online or Internet Banking a lots of payments can be done online through a bank
account at the convenient place like home/office.

4) Ease and Availability – ICT made Everything easy and available through mobile banking, ATM cards,
Internet Banking facilities like the movement of money from customer to merchant.

Q.10) What is e-waste? What are the benefits of e-waste Recycling?

Ans: - e-waste/e-scrap/Electronic waste/WEEE(Waste Electrical and Electronic Equipment) describes


discarded electrical or electronic devices like discarded computers, office electronic equipment,
entertainment devices, mobiles etc.

e-waste recycling allows for recovery of valuable precious metals, Protects public health and
water quality, Saves landfill space etc.

Q.11) What is Identity theft?

Ans: - Theft of personal information so that to gain access of personal information of victim(Some body)
and later use victim’s personal information to commit fraud.

Q.12) How a user of cyber world can safe personal information online?

Ans: - A user can protect his/her personal information by the following ways: -

1) Use of Unique Ids to protect personal account and devices.


2) Apply Bio-metric protection to safe the personal information.

39 | P a g e
Q.13) How we can resolve gender issues as far as school level computer science education is concern?

Ans: - 1) Girls should be motivated by different programmes to take up CS as one of the subjects to make
career in it.
2) Ads play a vital role in the whole life style of a girl thus ads will be designed so well and female role
models should be projected under those Ads who encourage girls to take up subjects like CS.

3) Girls should be encouraged in computer practical classes to handle the devices and find out the
problems and their solutions related to hardware part.

Q.14) List some disability issues faced in the teaching/using computers with respect to specially abled
students.

Ans: - 1) Unavailability of Teachers Materials/Aids

3) Lack of Special Needs Teachers


4) Lack of Supporting Curriculum

Q.15) What are the possible solutions to deal with disability issues in a school?

Ans: - 1) Teaching Materials / aids should be available to cater the needs of special needs of students.

2) Sufficient No. of specially Trained Teachers should be available who can take care of these students.

3) School must follow the inclusive curriculum so that especially abled student doesn’t feel
himself/herself in a disadvantageous group.

***

40 | P a g e

You might also like