Student Support Material XII CS
Student Support Material XII CS
Student Support Material XII CS
21. Name the Python Library modules which need to be imported to invoke the following
functions: (i) ceil( ) (ii) randrange( )
22. What will be the output of the following expression: print(24//6%3, 24//4//2, 20%3%2)
23. Evaluate following expressions:
a) 18 % 4 ** 3 // 7 + 9
b) 2 > 5 or 5 == 5 and not 12 <= 9
c) 16%15//16
d) 51+4-3**3//19-3
e) 17<19 or 30>18 and not 19==0
24. Expand the following terms:
a. HTML b. ITA c. SIP d. GSM
e. PPP f. PAN g. POP3 h. FTP
84
SOLUTIONS: GENERAL THEORY
Ans1. The round( ) function is used to convert a fractional number into whole as the nearest next
whereas the floor( ) is used to convert to the nearest lower whole number.
E.g. round(5.8) = 6 and floor(5.8)= 5
Ans3. Default arguments are used in function definition, if the function is called without the argument,
the default argument gets its default value.
Ans 4. Actual parameters are those parameters which are used in function call statement and formal
parameters are those parameters which are used in function header (definition).
e.g. def sum(a,b): # a and b are formal parameters
return a+b
x, y = 5, 10
res = sum(x,y) # x and y are actual parameters
Ans 6: Built in functions can be used directly in a program in python, but in order to use modules, we have
to use import statement to use them.
Ans 7.
Sno. LOCAL VARIABLE GLOBAL VARIABLE
1 It is a variable which is declared within a It is a variable which is declared outside
function or within a block. all the functions.
2 It is accessible only within a function/ block in It is accessible throughtout the
which it is declared. program.
For example,
def change():
n=10 # n is a local variable
x=5 # x is a global variable
print( x)
Ans 8. i) using the function is easier as we do not need to remember the order of the arguments.
ii) we can specify values of only those parameters which we want to give, as other parameters
have default argument values
Ans9. Scope of variables refers to the part of the program where it is visible, i.e, the area where you can
use it
Ans10. (i)
85
2. QUESTIONS - ERROR FINDING
Q1. Find error in the following code(if any) and correct code by rewriting code and
underline the correction;-
x= int(“Enter value of x:”)
for y in range [0,10]:
if x=y
print( x + y)
else:
print( x-y)
Q2. Rewrite the following program after finding and correcting syntactical errors and
underlining it.
a, b = 0
if (a = b)
a +b = c
print(c)
Q3. Rewrite the following code in python after removing all syntax error(s). Underline
each correction done in the code.
250 = Number
WHILE Number<=1000:
if Number=>750
print (Number)
Number=Number+100
else
print( Number*2)
Number=Number+50
Q4. Rewrite the following code in python after removing all syntax error(s). Underline
each correction done in the code.
Val = int(rawinput("Value:"))
Adder = 0
for C in range(1,Val,3)
Adder+=C
if C%2=0:
Print (C*10)
Else:
print (C*)
print (Adder)
Q5. Rewrite the following code in python after removing all syntax error(s). Underline
each correction done in the code.
25=Val
for I in the range(0,Val)
if I%2==0:
print( I+1):
Else:
print [I-1]
Q6. Rewrite the following code in python after removing all syntax error(s). Underline
each correction done in the code.
STRING=""WELCOME
NOTE""
for S in range[0,8]:
print (STRING(S))
86
Q7. Rewrite the following code in python after removing all syntax error(s). Underline
each correction done in the code.
a=int{input("ENTER FIRST NUMBER")}
b=int(input("ENTER SECOND NUMBER"))
c=int(input("ENTER THIRD NUMBER"))
if a>b and a>c
print("A IS GREATER")
if b>a and b>c:
Print(" B IS GREATER")
if c>a and c>b:
print(C IS GREATER)
Q8. Rewrite the following code in python after removing all syntax error(s). Underline
each correction done in the code.
i==1
a=int(input("ENTER FIRST NUMBER"))
FOR i in range[1, 11];
print(a,"*=", i ,"=",a * i)
Q9. Rewrite the following code in python after removing all syntax error(s). Underline
each correction done in the code.
a=”1”
while a>=10:
print("Value of a=",a)
a=+1
Q10. Rewrite the following code in python after removing all syntax error(s). Underline
each correction done in the code.
Num=int(rawinput("Number:"))
sum=0
for i in range(10,Num,3)
Sum+=1
if i%2=0:
print(i*2)
Else:
print(i*3 print Sum)
Q11. Rewrite the following code in python after removing all syntax error(s). Underline
each correction done in the code.
weather='raining'
if weather='sunny':
print("wear sunblock")
elif weather='snow':
print("going skiing")
else:
print(weather)
Q12. Write the modules that will be required to be imported to execute the following
code in Python.
def main( ):
for i in range (len(string)) ):
if string [i] = = ‘’ “
print
else:
c=string[i].upper()
print( “string is:”,c)
print (“String length=”,len(math.floor()))
87
Q13. Observe the following Python code very carefully and rewrite it after removing all
syntactical errors with each correction underlined.
DEF execmain():
x = input("Enter a number:")
if (abs(x)=x):
print ("You entered a positive number")
else:
x=*-1
print "Number made positive:"x
execmain()
Q14. Rewrite the following code in python after removing all syntax error(s).Underline
each correction done in the code
x=integer(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)
Q15. Rewrite the following code in python after removing all syntax error(s). Underline
each correction done in the code.
30=To
for K in range(0,To)
IF k%4==0:
print (K*4)
else
print (K+3)
88
Ans 4. Val = int(raw_input("Value:")) # Error 1
Adder = 0
for C in range(1,Val,3) : # Error 2
Adder+=C
if C%2==0 : # Error 3
print( C*10 ) # Error 4
else: # Error 5
print (C ) # Error 6
print(Adder)
Also range(0,8) will give a runtime error as the index is out of range. It shouldbe range(0,7)
i=1
a=int(input("ENTER FIRST NUMBER"))
for i in range(1,11):
print(a,"*=",i,"=",a*i)
a=1
while a<=10:
print("Value of a=",a)
a+=1
90
Q4. Find out the output of the Following –
for a in range(3,10,3):
for b in range(1,a,2):
print(b, end=’ ‘)
print( )
Q10. Find and write the output of the following python code:
Msg1="WeLcOME"
Msg2="GUeSTs"
Msg3=""
for I in range(0,len(Msg2)+1):
if Msg1[I]>="A" and Msg1[I]<="M":
Msg3=Msg3+Msg1[I]
elif Msg1[I]>="N" and Msg1[I]<="Z":
Msg3=Msg3+Msg2[I]
else:
Msg3=Msg3+"*"
print (Msg3)
91
Q11. Find and write the output of the following python code :
def Changer(P,Q=10):
P=P/Q
Q=P%Q
print (P,"#",Q)
return P
A=200
B=20
A=Changer(A,B)
print (A,"$",B)
B=Changer(B)
print (A,"$",B)
A=Changer(A)
print (A,"$",B)
Q12. Find and write the output of the following python code:
Data = ["P",20,"R",10,"S",30]
Times = 0
Alpha = ""
Add = 0
for C in range(1,6,2):
Times= Times + C
Alpha= Alpha + Data[C-1]+"$"
Add = Add + Data[C]
print (Times,Add,Alpha)
Q13. Find and write the output of the following python code:
Text1="AISSCE 2018"
Text2=""
I=0
while I<len(Text1):
if Text1[I]>="0" and Text1[I]<="9":
Val = int(Text1[I])
Val = Val + 1
Text2=Text2 + str(Val)
elif Text1[I]>="A" and Text1[I] <="Z":
Text2=Text2 + (Text1[I+1])
else:
Text2=Text2 + "*"
I=I+1
print (Text2)
Q14. Find and write the output of the following python code:
TXT = ["20","50","30","40"]
CNT = 3
TOTAL = 0
for C in [7,5,4,6]:
T = TXT[CNT]
TOTAL = float (T) + C
print(TOTAL)
CNT-=1
92
Q15. Find output generated by the following code:
line = "I'll come by then."
eline = ""
for i in line:
eline += chr(ord(i)+3)
print(eline)
1. t1=("sun","mon","tue","wed")
print(t1[-1])
2. t2=("sun","mon","tue","wed","thru","fri")
for i in range (-6,2):
print(t2[i])
3. t3=("sun","mon","tue","wed","thru","fri")
if "sun" in t3:
for i in range (0,3):
print(t2[i])
else:
for i in range (3,6):
print(t2[i])
5. t5=("sun",2,"tue",4,"thru",5)
if "sun" not in t4:
for i in range (0,3):
print(t5[i])
else:
for i in range (3,6):
print(t5[i])
6. t6=('a','b')
95
t7=('p','q')
t8=t6+t7
print(t8*2)
7. t9=('a','b')
t10=('p','q')
t11=t9+t10
print(len(t11*2))
8. t12=('a','e','i','o','u')
p, q, r, s, t=t12
print("p= ",p)
print("s= ",s)
print("s + p", s + p)
9. t13=(10,20,30,40,50,60,70,80)
t14=(90,100,110,120)
t15=t13+t14
print(t15[0:12:3])
2. t1=(10,20,30,40,50,60,70,80)
i=t1.len()
Print(T1,i)
3. t1=(10,20,30,40,50,60,70,80)
t1[5]=55
t1.append(90)
print(t1,i)
4. t1=(10,20,30,40,50,60,70,80)
t2=t1*2
t3=t2+4
print t2,t3
5. t1=(10,20,30,40,50,60,70,80)
str=””
str=index(t1(40))
print(“index of tuple is ”, str)
str=t1.max()
print(“max item is “, str)
1. d1 ={"john":40, "peter":45}
2. d2 ={"john":466, "peter":45}
3. d1 > d2
a) True b) False
c) ERROR d) None
Q9. What will be the error of the following code Snippet?
Lst =[1,2,3,4,5,6,7,8,9]
Lst[::2]=10,20,30,40,50,60
Print[Lst]
Q10. Find the error in following code. State the reason of the error
aLst={‘a’:1,’b’:2,’c’:3}
print(aLst[‘a’,’b’])
98
Q13. What will be the output of the following Code Snippet?
a = {(1,2):1,(2,3):2}
print(a[1,2])
A. Key Error B. 1 C. {(2,3):2} D. {(1,2):1}
Ans 4. list1 + list 2 = : [1998, 2002, 1997, 2000, 2014, 2016, 1996, 2009]
list1 * 2 = : [1998, 2002, 1997, 2000, 1998, 2002, 1997, 2000]
Ans 10. The above code produce KeyError, the reason being that there is no key same as the
list[‘a’,’b’] in dictionary aLst
Ans 15. B
99
QUESTIONS : FUNCTIONS - OUTPUT AND ERROR
b) def main ( )
print ("hello")
c) def func2() :
print (2 + 3)
func2(5)
def calcSquare(a):
a = power (a, 2)
return a
n=5
result = calcSquare(n)
print (result)
100
Q4. Find the output of the following-
import math
print (math. floor(5.5))
Q. 10. a=10
def call( ):
global a
a=15
b=20
print(a)
call( )
11. Write a user defined function GenNum(a, b) to generate odd numbers between a and b
(including b).
101
12. Write definition of a method/function AddOdd(VALUES) to display sum of odd values
from the list of VALUES.
13. Write definition of a Method MSEARCH(STATES) to display all the state names from a list of
STATES, which are starting with alphabet M.
For example:
If the list STATES contains [“MP’,”UP”,”MH”,”DL”,”MZ”,”WB”]
The following should get displayed
MP
MH
MZ
14. Write a python function generatefibo(n) where n is the limit, using a generator function
Fibonacci (max)( where max is the limit n) that produces Fibonacci series.
15. Write a definition of a method COUNTNOW(PLACES) to find and display those place names,
in which here are more than 7 characters.
For example:
If the list PLACES contains. ["MELBORN","TOKYO","PINKCITY","BEIZING","SUNCITY"]
The following should get displayed : PINKCITY
3. output: 25 4. output: 6
5. output: [0,1] 6. output: 4
[3,2,1,0,1,4]
[0,1,0,1,4]
7. output: 36 8. output: python
easyeasyaesy
9. Output: 33 10. 15
32
53
102
13. Ans def MSEARCH(STATES):
for i in STATES:
if i[0]==’M’:
print(i)
Q1. Which operator is used in the python to import all modules from packages?
(a) . operator
(b) * operator
(c) -> symbol
(d) , operator
Q2. Which file must be part of the folder containing python module file to make it importable
python package?
(a) init.py
(b) ____steup__.py
(c) __init ___.py
(d) (d) setup.py
Q4. Which is the correct command to load just the tempc method from a module called usable?
(a) import usable,tempc (b) Import tempc from usable
(c) from usable import tempc (d) import tempc
103
SECTION B (2 MARK QUESTION)
Q1. How can you locate environment variable for python to locate the module files imported into a
program?
Q2. What is the output of the following piece of code?
#mod1
def change (a):
b=[x*2 for x in a]
print (b)
#mod2
def change (a) :
b =[x*x for x in a]
print (b)
from mode 1 import change
from mode 2 import change
#main
S= [1,2,3]
Change (s)
Note: Both the modules mod1 and mod 2 are placed in the same program.
(a) [2,4,6] (b) [1,4,9]
(c) [2,4,6][1,4,9] (d) There is a name clash
Q3. What happens when python encounters an import statement in a program? What would happen, if
there is one more important statement for the same module, already imported in the same program?
104
Fill in the blanks for the following code:
1. Math _operation #get the name of the module.
2. print (_______) #output: math_operation
# Add 1and 2
3. print(_______(1,2) ) # output 3
Q2. Consinder the code given in above and on the basis of it, complete the code given below:
# import the subtract function
#from the math_operation module
1.________________________ #subtract 1from 2
2.print(_______(2,1) ) # output : 1
# Import everything from math____operations
3._______________________________
print (subtract (2,1) ) # output:1
print (add (1,1) ) # output:2
105
SECTION B (2 MARK ANSWERS )
Ans 1. Pythonpath command is used for the same. It has a role similar to path. This variable tells the
python interpreter where to locate the module files imported into a program.It should include the
python source library ,directory containing python source code.
Ans 2. (d)
Ans 4. In the “from–import” from of import, the imported identifiers (in this case factorial ()) become
part of the current local namespace and hence their module’s name aren’t specified along with the
module name. Thus, the statement should be:
print( factorial (5) )
Ans 5. There is a name clash. A name clash is a situation when two different entities with the same name
become part of the same scope. Since both the modules have the same function name, there is a
name clash, which is an error..
Ans 4. The possible outputs could be (ii), (iii) (v) and (vi).
The reason being that randint( ) would generate an integer between range 2…4, which is then
raised to power 2.
106
The above program saves a dictionary in binfile.dat and prints it on console after reading it from
the file binfile.dat
QUESTIONS (1 MARK)
Q3. Write a statement to open a binary file name sample.dat in read mode and the file
sample.dat is placed in a folder ( name school) existing in c drive
Q5. How many file objects would you need to manage the following situations :
(a) To process four files sequentially
(b) To process two sorted files into third file
Q6. When do you think text files should be preferred over binary files?
QUESTIONS (2 MARK)
Q1. Write a single loop to display all the contens of a text file file1.txt after removing leading
and trailing WHITESPACES
out=open('output.txt','w')
out.write('hello,world!\n')
out.write('how are you')
out.close( )
open('output.txt').read( )
Q2. Read the code given below and answer the questions
f1=open('main.txt','w')
f1.write('bye')
f1.close()
if the file contains 'GOOD' before execution, what will be the content of the file after
execution of the code
Q1. Write a user defined function in python that displays the number of lines starting with 'H'in
the file para.txt
Q2. Write a function countmy() in python to read the text file "DATA.TXT" and count the
number of times "my" occurs in the file. For example if the file DATA.TXT contains-"This is
my website. I have diaplayed my preference in the CHOICE section ".-the countmy()
function should display the output as:"my occurs 2 times".
Q3. Write a method in python to read lines from a text file DIARY.TXT and display those lines
which start with the alphabets P.
Q4 write a method in python to read lines from a text file MYNOTES.TXT and display those
lines which start with alphabets 'K'
Q5 write a program to display all the records in a file along with line/record number.
Q6. consider a binary file employee.dat containing details such as
empno:ename:salary(seperator ':') write a python function to display details of those
employees who are earning between 20000 and 30000(both values inclusive)
Q7. write a program that copies a text file "source.txt" onto "target.txt" barring the lines
starting with @ sign.
Ans1. w mode opens a file for writing only. it overwrites if file already exist but 'a mode appends the
existing file from end. It does not overwrites the file
Ans2 binary file are easier and faster than text file.binary files are also used to store binary data such as
images, video files, audio files.
Ans3 f1=open(“c:\school\sample.dat”,’r’)
108
Ans4 d) f.readlines()
Ans5 a)4 b)3
Ans6 Text file should be preferred when we have to save data in text format and security of file is not
important
(2 MARKS QUESTIONS)
Ans1 for line in open(“file1.txt”):
print(line.strip())
Ans2 The file would now contains “Bye”only because when an existing file is openend in write mode .it
truncates the existing data in file .
Ans3 i) Text file
ii) f1.write(“abc”)
Ans4 Line1
Line3
Line 6
Line 4
Ans5 ab and a+b mode
Ans7 No Output
Explanation: the f1.read() of line 2 will read entire content of file and place the file pointer at the
end of file. for f1.read(5) it will return nothing as there are no bytes to be read from EOF and,
thus,print statement prints nothing.
Q1. Sunita writing a program to create a csv file “a.csv” which contain user id and name of the
beneficiary. She has written the following code. As a programmer help her to successfully
execute the program.
import ______________ #Line 1
with open('d:\\a.csv','w') as newFile:
newFileWriter = csv.writer(newFile)
newFileWriter.writerow(['user_id','beneficiary'])
newFileWriter.________________([1,'xyz']) #Line2
newFile.close()
with open('d:\\a.csv','r') as newFile:
newFileReader = csv._______________(newFile) #Line 3
for row in newFileReader:
print (row) #Line 4
newFile.____________ #Line 5
a) Name the module he should import in Line 1
b) Fill in the blank in line 2 to write the row.
c) Fill in the blank in line 3 to read the data from csv file.
d) Write the output while line 4 is executed.
110
e) Fill in the blank in line 5 to close the file.
Q2. MOHIT is writing a program to search a name in a CSV file “MYFILE.csv”. He has written the
following code. As a programmer, help him to successfully execute the given task.
import _________ # Statement 1
f = open("MYFILE.csv", _______) # Statement 2
data = ____________ ( f ) # Statement 3
nm = input("Enter name to be searched: ")
for rec in data:
if rec[0] == nm:
print (rec)
f.________( ) # Statement 4
2. (a) csv.
(b) “r”?
111
(c) data = csv.reader(f)
(d) f.close()
(e) Comma Separated Values
3. def AddCustomer(Customer):
CStake.append(Customer)
if len(CStack)==0:
print (“Empty Stack”)
else:
print (CStack)
4. def DeleteCustomer():
if (CStack ==[]):
print(“There is no Customer!”)
else:
print(“Record deleted:”,CStack.pop())
Number of Computers
Wing A 10
Wing S 200
Wing J 100
Wing H 50
(i) Suggest a suitable Topology for networking the computer of all wings.
(ii) Name the wing where the server is to be installed. Justify your answer
(iii) Suggest the placement of Hub/Switch in the network.
(iv) Mention the economic technology to provide internet accessibility to all wings.
Ans 2. Spyware is software that is installed on a computing device without the end user's knowledge.
Any software can be classified as spyware if it is downloaded without the user's authorization.
Spyware is controversial because even when it is installed for relatively innocuous reasons, it can
violate the end user's privacy and has the potential to be abused.
Ans 3. Ethernet is the traditional technology for connecting wired local area networks (LANs), enabling
devices to communicate with each other via a protocol -- a set of rules or common network
language.
As a data-link layer protocol in the TCP/IP stack, Ethernet describes how network devices can
format and transmit data packets so other devices on the same local or campus area network
segment can recognize, receive and process them. An Ethernet cable is the physical, encased
wiring over which the data travels
Ans 4. Advantage:
We can share resources such as printers and scanners.
Can share data and access file from any computer.
Disadvantage:
Server faults stop applications from being available.
Network faults can cause loss of data.
114
Ans 5. ARPAnet (Advanced Research Project Agency Network is a project sponsored by U. S.
Department of Defense.
Ans 6. Name the basic types of communication channels available. Communication channel mean the
connecting cables that link various workstations. Following are three basic types of
communication channels available:
a) Twisted-Pair Cables
b) Coaxial Cables
c) Fiber-optic Cables
Ans 7. Baud is a unit of measurement for the information carrying capacity of a communication channel.
bps- bits per second. It refers to a thousand bits transmitted per second. Bps- Bytes per second. It
refers to a thousand bytes transmitted per second. All these terms are measurement
Ans 8. Interspace is a client/server software program that allows multiple users to communicate online
with real-time audio, video and text chat I dynamic 3D environments.
Ans 10. Communication channel mean the connecting cables that link various workstations.
Following are three basic types of communication channels available:
a) Twisted-Pair Cables
b) Coaxial Cables
c) Fiber-optic Cables.
Ans.11. Similarities: In both Bus and Tree topologies transmission can be done in both the
directions, and can be received by all other stations. In both cases, there is no need to
remove packets from the medium.
Differences: Bus topology is slower as compared to tree topology of network. Tree
topology is expensive as compared to Bus Topology
Ans 12. Requires more cable length than a linear topology. If the hub, switch, or concentrator
fails, nodes attached are disabled. More expensive than linear bus topologies because of
the cost of the hubs, etc.
Ans 13. Ring topology becomes the best choice for a network when, short amount of cable is
required. No wiring closet space requires.
Ans 14. ADVANTAGE: Easy to connect a computer or peripheral to a linear bus. Requires less
cable length than a star topology
.
DISADVANTAGE: Slower as compared to tree and star topologies of network. Breakage of
wire at any point disturbs the entire
Ans 15. (i) RJ-45: RJ45 is a standard type of connector for network cables and networks. It is
an 8-pin connector usually used with Ethernet cables.
(ii)Ethernet: Ethernet is a LAN architecture developed by Xerox Corp along with DEC
and Intel. It uses a Bus or Star topology and supports data transfer rates of
up to 10 Mbps.
(iii)Ethernet card: The computers parts of Ethernet are connected through a special
card called Ethernet card. It contains connections for either coaxial or
twisted pair cables.
115
(iv)Hub: In computer networking, a hub is a small, simple, low cost device that joins
multiple computers together.
(v)Switch: A Switch is a small hardware device that joins multiple computers together
within one local area network (LAN).
Ans 16. A protocol means the rules that are applicable for a network or we can say that the common set
of rules used for communication in network. Different types of protocols are :
(i) HTTP : Hyper Text Transfer Protocol
(ii) FTP : File Transfer Protocol
(iii) SLIP : Serial Line Internet Protocol
(iv) PPP : Point to Point Protocol
(v) TCP/IP : Transmission Control Protocol/ Internet Protocol
(vi) NTP : Network Time Protocol
(vii) SMTP : Simple Mail Transfer Protocol
(viii) POP : Post Office Protocol
(ix) IMAP : Internet Mail Access Protocol
Ans 17. GSM: GSM (Global system for mobile communication) is a wide area wireless communications
System that uses digital radio transmission to provide voice data and multimedia
communication services. A GSM system coordinates the communication between mobile
telephones, base stations, and switching systems.
CDMA: CDMA (Code Division Multiple Access) is a digital wireless telephony transmission
technique, which allows multiple frequencies to be used simultaneously – Spread Spectrum.
WLL: WLL (Wireless in Local Loop) is a system that connects subscriber to the public switched
telephone network (PSTN) using radio signal as alternate for other connecting media.
Ans 18 (i) 3G: 3G (Third Generation) mobile communication technology is a broadband, packet-based
transmission of text, digitized voice, video and multimedia at data rates up to 2 mbps, offering a
consistent set of services to mobile computer and phone users no matter where they are located
in the world.
(ii)EDGE: EDGE (Enhanced Data rates for Global Evolution) is radio based high-speed of mobile
data standard, developed specifically to meet the bandwidth needs of 3G.
(iii)SMS: SMS (Short Message Service) is the transmission of short text messages to and from a
mobile phone, fax machine and IP address. (iv)TDMA: TDMA (Time Division Multiple Access) is
a technology for delivering digital wireless service using time- division multiplexing (TDM).
Ans 19. Web Browser: A Web Browser is software which used for displaying the content on web
page(s). It is used by client to view web sites.
Example of Web browser – Google Chrome, Fire Fox, Internet Explorer, Safari, Opera, etc.
Web Server: A Web Server is software which fulfills the request(s) done by web browser. Web
server have different ports to handle different request from web browser like generally FTP
request is handle at Port 110 and HTTP request is handle at Port 80.
Example of Web server are – Apache, IIS
Ans 20. (i) Star or Bus or any other valid topology or diagram.
(ii) Wing S, because maximum number of computer are located at Wing S.
(iii) Hub/Switch in all the wings.
(iv)Coaxial cable/Modem/LAN/TCP-IP/Dialup/DSL/Leased Lines or any other valid technology.
Ans 22 Carrier Sense Multiple Access/Collision Avoidance (CSMA/CA) is a media access protocol that is
related to CSMA/CD and is also used on multiple access networks
Ans. 23. Carrier Sense Multiple Access/Collision Avoidance (CSMA/CA) is a media access protocol that is
used on multiple access wireless networks. With CSMA/CA, a device listens for an opportunity
to transmit its data, i.e, CARRIER SENSE If the carrier is free, the sending device does not
immediately transmit data. Rather, it first transmits a signal notifying other devices (i.e., a
116
warning packet) that it is transmitting for so much time before actually sending the data. The
other device refrains from transmitting data for the specified time limit. This means data
packets will never collide.
Ans 24. There are many methods of checking or detecting simplest ones are:
(i) Single dimensional parity checking
(ii) Two dimensional parity checking
(iii) Checksums
Ans 25. The errors that may occur in the data transmitted over networks, can be one or more of
following types:
(i) Single-bit error. This type of error occurs if only one bit of the transmitted data got changed
from 1 to 0 or from 0 to 1.
(ii) Multiple-bit error. This type of error occurs if two or more nonconsecutive bits in data got
changed from 0 to 1 or from 1 to 0.
(iii) Burst Error. This type of error occurs if two or more consecutive bits in data got changed
from 0 to 1 or from 1 to 0
Ans 26. Parity checking is a method of error detection that can checkk1 or 2 bit errors (but not all dr
these) In parity checks, a parity bit is added to the end of a string of binary code to indicate
whether the number of bits in the string with the value 1 is even or odd.
Ans 27. The sender, which is the checksum generator, follows these steps:
(a) The units are divided into k sections each of n bits, taking 1's complement to get the sum.
(b) All sections are added together
(c) The sum is complemented and become the checksum.
(d) The checksum is sent with the data.
Ans 28. The acknowledgement signal or the ACK signal is a control code, which is sent by the receiving
computer to indicate that the data has been received without error and that the next part of the
transmission may be sent.
Ans 29. Routing is the process of selecting paths to move information across networks When a data
packet reaches a router, the router selects the best route to the destination network from js
routing table and forwards the data packet to the neighbouring router as per the selected best
path. This way each router keeps passing the data packet(s) to its neighbouring router on best
route the destination and finally the data packet reaches its destination.
Q3. Consider the following tables GAMES and PLAYER. Write SQL commands for the
statements (i) to (iv) and give outputs for SQL queries (v) to (viii).
Table:GAMES
GCode GameName Number PrizeMoney ScheduleDate
101 Carom Board 2 5000 23-Jan-2004
102 Badminton 2 12000 12-Dec-2003
103 Table Tennis 4 8000 14-Feb-2004
105 Chess 2 9000 01-Jan-2004
108 Lawn Tennis 4 25000 19-Mar-2004
Table: PLAYER
PCode Name Gcode
1 Nabi Ahmad 101
2 Ravi Sahai 108
3 Jatin 101
4 Nazneen 103
(i) To display the name of all Games with their Gcodes.
(ii) To display details of those games which are having PrizeMoney more than 7000.
(iii) To display the content of the GAMES table in ascending order of ScheduleDate.
(iv) To display sum of PrizeMoney for each of the Number of participation groupings (as
shown in column Number 2 or 4)
(v) SELECT COUNT(DISTINCT Number) FROM GAMES;
(vi) SELECT MAX(ScheduleDate),MIN(ScheduleDate) FROM GAMES;
(vii) SELECT SUM(PrizeMoney) FROM GAMES;
(viii) SELECT DISTINCT Gcode FROM PLAYER;
Q4. Consider the following tables FACULTY and COURSES. Write SQL commands for the
statements (i) to (iv) and give outputs for SQL queries (v) to (vi).
FACULTY
F_ID Fname Lname Hire_date Salary
102 Amit Mishra 12-10-1998 12000
103 Nitin Vyas 24-12-1994 8000
104 Rakshit Soni 18-5-2001 14000
105 Rashmi Malhotra 11-9-2004 11000
106 Sulekha Srivastava 5-6-2006 10000
COURSES
C_ID F_ID Cname Fees
C21 102 Grid Computing 40000
C22 106 System Design 16000
C23 104 Computer Security 8000
C24 106 Human Biology 15000
C25 102 Computer Network 20000
C26 105 Visual Basic 6000
i) To display details of those Faculties whose salary is greater than 12000.
ii) To display the details of courses whose fees is in the range of 15000 to 50000 (both
values included).
118
iii) To display details of those courses which are taught by ‘Sulekha’ in descending order
of courses ?
iv) Select COUNT(DISTINCT F_ID) from COURSES;
v) Select Fname,Cname from FACULTY,COURSE where COURSE.F_ID=FACULTY.F.ID;
Q-5 Write SQL Command for (a) to (e) and output of (f)
TABLE : GRADUATE
S.NO NAME STIPEND SUBJECT AVERAGE DIV
1 KARAN 400 PHYSICS 68 I
2 DIWAKAR 450 COMP Sc 68 I
3 DIVYA 300 CHEMISTRY 62 I
4 REKHA 350 PHYSICS 63 I
5 ARJUN 500 MATHS 70 I
6 SABINA 400 CHEMISTRY 55 II
7 JOHN 250 PHYSICS 64 I
8 ROBERT 450 MATHS 68 I
9 RUBINA 500 COMP Sc 62 I
10 VIKAS 400 MATHS 57 II
a. List the names of those students who have obtained DIV I sorted by NAME.
b. Display a report, listing NAME, STIPEND, SUBJECT and amount of stipend received in a
year assuming that the STIPEND is paid every month.
c. To count the number of students who are either PHYSICS or COMPUTER SC graduates.
d. To insert a new row in the GRADUATE table: 11,”KAJOL”, 300, “computer sc”, 75, 1
e. Give the output of following sql statement based on table GRADUATE:
(i) Select MIN(AVERAGE) from GRADUATE where SUBJECT=”PHYSICS”;
(ii) Select SUM(STIPEND) from GRADUATE WHERE div=2;
(iii) Select AVG(STIPEND) from GRADUATE where AVERAGE>=65;
(iv) Select COUNT(distinct SUBJECT) from GRADUATE;
Q-6 Consider the following tables Sender and Recipient. Write SQL commands for the
statements (i) to (iv) and give the outputs for SQL queries (v) to (viii).
Sender
SenderID SenderName SenderAddress Sendercity
ND01 R Jain 2, ABC Appls New Delhi
MU02 H Sinha 12 Newtown Mumbai
MU15 S Jha 27/A, Park Street Mumbai
ND50 T Prasad 122-K,SDA New Delhi
Recipients
RecID SenderID RecName RecAddress recCity
KO05 ND01 R Bajpayee 5, Central Avenue Kolkata
ND08 MU02 S Mahajan 116, A-Vihar New Delhi
MU19 ND01 H Singh 2A, Andheri East Mumbai
MU32 MU15 P K Swamy B5, C S Terminals Mumbai
ND48 ND50 S Tripathi 13, BI D Mayur Vihar New delhi
a. To display the names of all Senders from Mumbai
b. To display the RecIC, Sendername, SenderAddress, RecName, RecAddress for every Recipient
c. To display Recipient details in ascending order of RecName
d. To display number of Recipients from each city
e. SELECT DISTINCT SenderCity from Sender;
f. SELECT A.SenderName, B.RecName From Sender A, Recipient B
Where A.SenderID = B.SenderID AND B.RecCity =’Mumbai’;
g. SELECT RecName, RecAddress From Recipient
Where RecCity NOT IN (‘Mumbai’, ‘Kolkata’) ;
119
h. SELECT RecID, RecName FROM Recipent
Where SenderID=’MU02’ or SenderID=’ND50’;
Q-7 Write SQL queries for (i) to (iv) and find outputs for SQL queries (v) to (viii), which
are based on the tables.
Table : VEHICLE
CODE VTYPE PERKM
101 VOLVO BUS 160
102 AC DELUXE BUS 150
103 ORDINARY BUS 90
105 SUV 40
104 CAR 20
Note : PERKM is Freight Charges per kilometer , VTYPE is Vehicle Type
Table : TRAVEL
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 80 105 4
• NO is Traveller Number
• KM is Kilometer travelled
• NOP is number of travellers travelled in vehicle
• TDATE is Travel Date
(i) To display NO, NAME, TDATE from the table TRAVEL in descending order of NO.
(ii) To display the NAME of all the travellers from the table TRAVEL who are travelling by
vehicle with code 101 or 102.
(iii) To display the NO and NAME of those travellers from the table TRAVEL who travelled
between ‘2015-12-31’ and ‘2015-04-01’.
(iv) To display all the details from table TRAVEL for the travellers, who have travelled
distance more than 100 KM in ascending order of NOP.
(v) SELECT COUNT (*), CODE FROM TRAVEL GROUP BY CODE HAVING COUNT(*)>1;
(vi) SELECT DISTINCT CODE FROM TRAVEL;
(vii) SELECT A.CODE,NAME,VTYPE FROM TRAVEL A, VEHICLE B WHERE A.CODE=B.CODE
AND KM<90;
Q9. Observe the following table and answer the parts (i) and(ii) accordingly
Table:Product
Pno Name Qty PurchaseDate
101 Pen 102 12-12-2011
102 Pencil 201 21-02-2013
103 Eraser 90 09-08-2010
109 Sharpener 90 31-08-2012
113 Clips 900 12-12-2011
(i) Write the names of most appropriate columns, which can be considered as candidate
keys.
(ii) What is the degree and cardinality of the above table?
Q-10 Write SQL queries for (i) to (iv) and find outputs for SQL queries (v) to(viii), which
are based on the tables.
TRAINER
TID TNAME CITY HIREDATE SALARY
101 SUNAINA MUMBAI 1998-10-15 90000
102 ANAMIKA DELHI 1994-12-24 80000
103 DEEPTI CHANDIGARG 2001-12-21 82000
104 MEENAKSHI DELHI 2002-12-25 78000
105 RICHA MUMBAI 1996-01-12 95000
106 MANIPRABHA CHENNAI 2001-12-12 69000
COURSE
CID CNAME FEES STARTDATE TID
C201 AGDCA 12000 2018-07-02 101
C202 ADCA 15000 2018-07-15 103
C203 DCA 10000 2018-10-01 102
C204 DDTP 9000 2018-09-15 104
C205 DHN 20000 2018-08-01 101
C206 O LEVEL 18000 2018-07-25 105
(i) Display the Trainer Name, City & Salary in descending order of their Hiredate.
(ii) To display the TNAME and CITY of Trainer who joined the Institute in the month of
December 2001.
(iii) To display TNAME, HIREDATE, CNAME, STARTDATE from tables TRAINER and
COURSE of all those courses whose FEES is less than or equal to 10000.
(iv) To display number of Trainers from each city.
(v) SELECT TID, TNAME, FROM TRAINER WHERE CITY NOT IN(‘DELHI’, ‘MUMBAI’);
(vi) SELECT DISTINCT TID FROM COURSE;
(vii) SELECT TID, COUNT(*), MIN(FEES) FROM COURSE GROUP BY TID HAVING
COUNT(*)>1;
(viii) SELECT COUNT(*), SUM(FEES) FROM COURSE WHERE STARTDATE< ‘2018-09-15’;
121
QUESTONS : MORE ON SQL
Answer-1 Define the terms:
I. PRIMARY KEY : It is a key/attribute or a set of attributes that can uniquely identify
tuples within the relation.
II. CANDIDATE KEY : All attributes combinations inside a relation that can serve as
primary key are candidate key as they are candidates for being as a primary
key or a part of it.
III. RELATIONAL ALGEBRA : It is the collections of rules and operations on
relations(tables). The various operations are selection, projection, Cartesian
product, union, set difference and intersection, and joining of relations.
IV. DOMAIN : it is the pool or collection of data from which the actual values appearing in
a given column are drawn.
Answer-2
Ans1. Data Definition Language (DDL): This is a category of SQL commands. All the commands
which are used to create, destroy, or restructure databases and tables come under this category.
Examples of DDL commands are - CREATE, DROP, ALTER.
Data Manipulation Language (DML): This is a category of SQL commands. All the commands
which are used to manipulate data within tables come under this category. Examples of DML
commands are - INSERT, UPDATE, DELETE.
Ans 3: Single Row Function work with a single row at a time. A single row function returns a result for
every row of a quired table
Examples of Single row functions are Sqrt( ), Concat( ), Lcase( ), Upper( ), Day( ), etc.
Ans 4. The CHAR data-type stores fixed length strings such that strings having length smaller than the
field size are padded on the right with spaces before being stored.
The VARCHAR on the other hand supports variable length strings and therefore stores strings
smaller than the field size without modification.
Ans 5: WHERE clause is used to select particular rows that satisfy the condition where having clause is
used in connection with the aggregate function GROUP BY clause.
FOR EXAMPLE- select * from student where marks >80;
Select * from student group by stream having marks>90;
Ans 6: i) 100001 ii)No output
Ans 8. COMMIT command permanently saves the changes made during the transacation execution.
ROLLBACK command undoes the changes made during transaction execution.
Ans9: DISTINCT
Ans 10: curdate() returns the current date whereas date() extracts the date part of a date.
Answer-3
(i) SELECT GameName, Gcode FROM GAMES;
(ii) SELECT * FROM GAMES WHERE PrizeMoney>7000;
(iii) SELECT * FROM GAMES ORDER BY ScheduleDate;
(iv) SELECT SUM(PrizeMoney),Number FROM GAMES GROUP BY Number;
(v) 2
(vi) 19-Mar-2004 12-Dec-2003
(vii) 59000
(viii) 101
103
108
122
Answer-4
(i) Select * from faculty where salary > 12000;
(ii) Select * from Courses.where fees between 15000 and 50000;
(iii) Select * from faculty fac, courses cour where fac.f_id = cour.f_id and fac.fname = 'Sulekha'
order by cname desc;
(iv) 4
(vi) Amit Grid Computing
Rakshit Computer Security
Rashmi Visual Basic
Sulekha Human Biology
Answer-5.
a. SELECT NAME from GRADUATE where DIV = ‘I’ order by NAME;
b. SELECT NAME,STIPEND,SUBJECT, STIPEND*12 from GRADUATE;
c. SELECT SUBJECT,COUNT(*) from GRADUATE group by SUBJECT having SUBJECT=’PHYISCS’ or
SUBJECT=’COMPUTER SC’;
d. INSERT INTO GRADUATE values(11,’KAJOL’,300,’COMPUTER SC’,75,1);
e. (i) 63
(ii) 800
(iii) 475
(iv) 4
Answer-6
a. SELECT sendername from Sender where sendercity=’Mumbai’;
b. Select R.RecIC, S.Sendername, S.SenderAddress, R.RecName, R.RecAddress
from Sender S, Recepient R where S.SenderID=R.SenderID ;
c. SELECT * from Recipent ORDER By RecName;
d. SELECT COUNT( *) from Recipient Group By RecCity;
e) SenderCity
Mumbai
New Delhi
f) A.SenderName B.RecName
R Jain H Singh
S Jha P K Swamy
g) RecName RecAddress
S Mahajan 116, A Vihar
S Tripathi 13, BID, Mayur Vihar
h) RecID RecName
ND08 S Mahajan
ND48 STripathi
Answer-7
i. SELECT NO, NAME, TDATE FROM TRAVEL ORDER BY NO DESC;
ii. SELECT NAME FROM TRAVEL WHERE CODE=‘101’ OR CODE=’102’;
OR
SELECT NAME FROM TRAVEL WHERE CODE IN (101,102);
iii. SELECT NO, NAME from TRAVEL
WHERE TDATE >= ‘20150401’ AND TDATE <= ‘20151231’;
OR
SELECT NO, NAME from TRAVEL
WHERE TDATE BETWEEN ‘20150401’ AND ‘20151231’;
iv. SELECT * FROM TRAVEL WHERE KM > 100 ORDER BY NOP;
iv. SELECT * FROM TRAVEL WHERE KM > 100 ORDER BY NOP;
vi. count(*) code
2 101
2 102
vii. DISTINCT CODE
101
123
102
103
104
105
viii. Code Name Vtype
104 Ahmed Khan Car
105 Raveena Suv
Answer-7
i. SELECT M_Compnay, M_Name, M_Price FROM MobileMaster
ORDER BY M_Mf_Date DESC;
ii. SELECT * FROM MobileMaster WHERE M_Name LIKE “S%‟;
iii. SELECT M_Supplier, M_Qty FROM MobileStock WHERE M_Id <> ‘MB003’;
iv. SELECT M_Company FROM MobileMaster WHERE M_Price
v. M_Id SUM(M_Qty)
MB004 450
MB003 400
MB001 300
MB006 200
vi.
MAX(M_Mf_Date) MIN(M_Mf_Date)
2017-11-20 2010-08-21
vii.
M_Id M_Name M_Qty M_Supplier
MB004 Unite3 450 New_Vision
MB001 Galaxy 300 Classic Mobile Store
viii. 5450
Answer-9
i) Candidate Key: Pno, Name
ii) Degree:4 Cardinality:5
Answer-10
(i) SELECT TNAME, CITY, SALARY FROM TRAINER ORDER BY HIREDATE;
(ii) SELECT TNAME, CITY FROM TRAINER
WHERE HIREDATE BETWEEN ‘2001-12-01’ AND ‘2001-12-31’;
(iii) SELECT TNAME,HIREDATE,CNAME,STARTDATE FROM TRAINER, COURSE
WHERE TRAINER.TID=COURSE.TID AND FEES<=10000;
(iv) SELECT CITY, COUNT(*) FROM TRAINER GROUP BY CITY;
(v) SELECT TID, TNAME, FROM TRAINER WHERE CITY NOT IN(‘DELHI’,’MUMBAI’);
(vi) TID TNAME
103 DEEPTI
106 MANIPRABHA
(vii) DISTINCT TID
101
103
102
104
105
(viii) TID Count(*) Min(Fees)
101 2 12000
(ix) Count(*) sum(Fees)
4 65000
124
QUESTION : PYTHON WITH SQL
Q1. What is MySQLdb?
Q2. What is resultset?
Q3. What is database cursor?
Q4. What is database connectivity?
Q5. Which function do use for executing a SQL query?
Q6. Which package must be imported to create a database connectivity application?
Q7. Differentiate between fetchone() and fetchall()
Q8. How we can import MYSQL database in python?
Q9. Write a small python program to insert a record in the table books with attributes
(title, isbn).
Q.10 Write a small python program to retrieve all record from the table books with attributes
(title ,isbn).
A2. Result set refers to a logical set of records that are fetched from the database by executing a
query.
A3. Database cursor is a special control structure that facilitates the row by row processing of records
in the result set
A4. Database connectivity refers to connection and communication between an application and a
database system.
A7. fetchone() − It fetches the next row of a query result set. A result set is an object that is returned
when a cursor object is used to query a table.
fetchall() − It fetches all the rows in a result set. If some rows have already been extracted from
the result set, then it retrieves the remaining rows from the result set.
A8. Use the mysql.connector.connect() method of MySQL Connector Python with required parameters
to connect MySQL. Use the connection object returned by a connect() method to create a cursor
object to perform Database Operations. The cursor.execute() to execute SQL queries from Python.
125
conn =sqlator.connect(host=”localhost”,user=”root”,passwd=””,database=”test”)
cursor=con.cursor()
query=”select * from query”
cursor.execute(query)
data=cursor.fetchall()
for row in data:
print(row)
conn.close()
1. Intellectual property rights are the rights given to persons over the creations of their minds. They
usually give the creator an exclusive right over the use of his/her creation for a certain period of
time12.
2. Plagiarism is the "wrongful appropriation" and "stealing and publication" of another author's
"language, thoughts, ideas, or expressions" and the representation of them as one's own original
work. Plagiarism is considered academic dishonesty and a breach of journalistic ethics.
3. Open-source software is a type of computer software in which source code is released under a
license in which the copyright holder grants users the rights to study, change, and distribute the
software to anyone and for any purpose. Open-source software may be developed in a collaborative
public manner.
4. Privacy law refers to the laws that deal with the regulation, storing, and using of personally
identifiable information of individuals, which can be collected by governments, public or private
organisations, or other individuals.
Privacy laws are considered within the context of an individual's privacy rights or within
reasonable expectation of privacy.
5. The crime that involves and uses computer devices and Internet, is known as cybercrime.
Cybercrime can be committed against an individual or a group; it can also be committed against
government and private organizations. It may be intended to harm someone's reputation, physical
harm, or even mental harm.
6. Voice phishing, or “vishing”, works the same way as a spear phishing attack (by using
personalized information to leverage trust), but uses a different channel: the telephone. The
126
scammer calls an individual, pretending to be calling for a trusted organization (like the bank or
your credit card company).
7. child pornography means
(a) a photographic, film, video or other visual representation, whether or not it was made by
electronic or mechanical means,
o (i) that shows a person who is or is depicted as being under the age of eighteen years and
is engaged in or is depicted as engaged in explicit sexual activity, or
o (ii) the dominant characteristic of which is the depiction, for a sexual purpose, of a sexual
organ or the anal region of a person under the age of eighteen years;
(b) any written material, visual representation or audio recording that advocates or counsels sexual
activity with a person under the age of eighteen years that would be an offence under this Act;
8. Cybercriminals are constantly looking for ways to make money at your expense. Individuals and
organisations often fall prey to frauds that involve various forms of social engineering techniques,
where the information required is garnered from a person rather than breaking into a system.
IT CAN BE AVOIDED BY FOLLOWING:
Check your online accounts regularly.
Check your bank account regularly and report any suspicious activity to your bank.
Perform online payments only on secure websites (check the URL bar for the padlock and https)
and using secure connections (choose a mobile network instead of public Wi-Fi).
Your bank will never ask you for sensitive information such as your online account credentials
over the phone or email.
If an offer sounds too good to be true, it’s almost always a scam.
Keep your personal information safe and secure.
Fraudsters can use your information and pictures to create a fake identity or to target you with a
scam.
9. Waste management (or waste disposal) are the activities and actions required to manage waste from
its inception to its final disposal. This includes the collection, transport, treatment and disposal of
waste, together with monitoring and regulation of the waste management process.
10. A biometric device is a security identification and authentication device. Such devices use
automated methods of verifying or recognising the identity of a living person based on a
physiological or behavioral characteristic. These characteristics include fingerprints, facial images,
iris and voice recognition.
echo chamber refers to the overall phenomenon by which individuals are exposed only to
information from like-minded individuals, while filter bubbles are a result of algorithms that choose
content based on previous online behavior, as with search histories or online shopping activity.
127
Frequently Asked Questions (FAQs)
Unit- 1
Very Short Answer Type Questions (1 mark)
Q1. Name the Python Library modules which need to be imported to invoke the following functions :
(i) load ()
(ii) pow ()
(iii) Uniform ()
(iv) fabs ()
(v) sqrt()
(vi)dump()
(vii)ceil()
(viii)randrange()
Ans:
(i)pickle
(ii)math
(iii)random ()
(iv)math ()
(v)math
(vi) pickle
(vii) math
(viii) random()
Q2. Which of the following is not a valid identifier name in Python? Justify reason for it not being a
valid name.
a) 5Total b) _Radius c) pie d)While
Ans: a) 5Total Reason : An identifier cannot start with a digit.
Q6. Identify the valid arithmetic operator in Python from the following.
a) ? b) < c) ** d) and
Ans: c) **
Q3. What do you understand by local and global scope of variables? How can you access a global
variable inside the function, if function has a variable with same name.
Ans:
Variables that are defined inside a function body have a local scope, and those defined outside have a
global scope. This means that local variables can be accessed only inside the function in which they
are declared, whereas global variables can be accessed throughout the program body by all functions.
Ex:
Local Scope: A variable created inside a function is available inside that function:
def myfunc():
x = 300
print(x)
myfunc()
Global Scope: A variable created in the main body of the Python code is a global variable and belongs
to the global scope. Global variables are available from within any scope, global and local.
x = 300
def myfunc():
print(x)
myfunc()
print(x)
129
If your function has a local variable with same name as global variable and you want to modify
the global variable inside function then use 'global' keyword before the variable name.
Q4. Explain with a code about Positional arguments, Keyword arguments and Default arguments.
These are the arguments which are passed in correct positional order in function.
When we pass the values during the function call, they are assigned to the respective arguments
according to their position.
Following program illustrate the use of positional parameters
If we change the position of the arguments, then the answer will be changed.
Keyword argument:
When we call a function with some values, these values get assigned to the arguments according to
their position. If a function has many arguments and we want to change the sequence of them then we
have to use keyword arguments.
See the following program where whenever we pass the values to the function then we pass the values
with the argument name :
130
But we must keep in mind that keyword arguments must follow positional arguments.
Having a positional argument after keyword arguments will result in errors. For example, the function
calls as follows:
A default argument is an argument that assumes a default value if a value is not provided in the
function call for that argument. In other words, a parameter having default value in the function header
is known as a default parameter.
Python allows function arguments to have default values. If the function is called without the
argument, the argument gets its default value.
These are the values which are used by the function for any specific task.
Python Program of default argument:
In the above program when the value is provided to parameter T, it will overwrite the default
value (see the first function call).When the value is not provided, the argument gets its default value
(see in the second function call, value for third parameter is not provided, so it will get the default
value T=3).
Any number of arguments in a function can have a default value. But once we have a default
argument in a function header, all the arguments to its right must also have default values. This means
to say, non-default arguments cannot follow default arguments.
Q5. Rewrite the following code in Python after removing all syntax error(s). Underline each correction
done in the code.
p=30
for c in range(0,p)
If c%4==0:
print (c*4)
elseif c%5==0:
print (c+3)
else
print(c+10)
131
Ans:
p=30
for c in range(0,p): Error 1
if c%4==0: Error 2
print (c*4)
elif c%5==0: Error 3
print (c+3)
else: Error 4
print(c+10)
Q6. Rewrite the following code in python after removing all syntax errors. Underline each correction
done in the code:
Def func(a):
for i in (0,a):
if i%2 =0:
s=s+1
else if i%5= =0
m=m+2
else:
n=n+i
print(s,m,n)
func(15)
Ans:
def func(a): Error 1
for i in range(0,a): Error 2
if i%2 ==0: Error 3
s=s+1
elif i%5= =0 Error 4
m=m+2
else:
n=n+i
print(s,m,n)
func(15)
Q7.What possible outputs(s) are expected to be displayed on screen at the time of execution of the
program from the following code. Select which option/s is/are correct
import random
print(random.randint(15,25) , end=' ')
print((100) + random.randint(15,25) , end = ' ' )
print((100) -random.randint(15,25) , end = ' ' )
print((100) *random.randint(15,25) )
(i) 15 122 84 2500 (ii) 21 120 76 1500
(ii) (iii) 105 107 105 1800 (iv) 110 105 105 1900
Q9. Write a statement in Python to declare a dictionary whose keys are 1,2,3 and
values are Monday, Tuesday and Wednesday respectively.
Ans:
Dict1 = { 1:‟Monday‟, 2:‟Tuesday‟, 3: „Wednesday‟ }
Q10.Differentiate between actual parameters and formal parameters with suitable example:
Ans:
The list of identifiers used in a function call is called actual parameter(s) whereas the list of
parameters used in the function definition is called formal parameter(s).
Q1. Write a function DisplayHeShe() in python that counts the number of „He‟ or She‟ words present
in a text file „Text.txt‟
Ans:
def displayHeShe():
num=0
f=open("Text.txt","r")
N=f.read()
M=N.split()
for x in M:
if x=="He" or x== "She":
133
print(x)
num=num+1
f.close()
print("Count of He/She in file:",num)
Q2. Write a method in python to read lines from a text file DIARY.TXT and display those lines which
start with the alphabets „P‟.
Ans:
def display ():
file = open("DIARY.txt" , "r")
lines = file.readlines()
for l in lines:
if l[0]== "p" or l[0] == "P":
print(l)
file.close()
Q3. Write a function DISPLAYWORDS() in python to display the count of words starting with “t” or
“T”in a text file „STORY.TXT‟.
Ans:
def DISPLAYWORDS():
count=0
file=open(„STORY.TXT','r')
line = file.read()
word = line.split()
for w in word:
if w[0]=="T" or w[0]=="t":
count=count+1
file.close()
print(count)
Q4.Write a method/function SHOW_TODO() in python to read contents from a text file ABC.TXT
and display those lines which have occurrence of the word „„TO‟‟ or „„DO‟‟.
For example : If the content of the file is:
Q6. Write a function in Python POP(Arr), where Arr is a stack implemented by a list of numbers. The
function returns the value deleted from the stack.
Ans:
def popStack(st) : # If stack is empty
if len(st)==0:
print("Underflow")
else:
L = len(st)
Val = st[L-1]
print(“Deleted item is:”, val)
return (st.pop(L-1) )
Q7. Write a function in python, PushEl(e) to add a new element and PopEl(e) to delete a element
from a List ,considering them to act as push and pop operations of the Stack data structure
Ans:
def PushEl(element):
a=int(input("enter element : "))
element.append(a)
print(“Element added successfully”)
def PopEl(element):
if (element==[]):
print( "Stack empty")
else:
print ("Deleted element:", element.pop())
Long Answer Questions: (4/5 Marks)
Q1. Rahul of class 12 is writing a program to create a CSV file “student.csv”. He has written the
following code to read the content of file „student.csv‟ and display the employee record whose name
begins from „S‟ also show no. of student with first letter „S‟ out of total record. As a programmer, help
him to successfully execute the given task. Consider the following CSV file (student.csv):
101,Mahak,3500
102,Ajay,4000
103,Suman,5000
135
104,Arnavi,2500
105,Smriti,4200
Ans: (a)csv
(b) read mode
(c) 'student.csv'
(d) reader
(e) 103,Suman,5000
105,Smriti,4200
Number of 'S' names are 2/5.
def MakeFile( ):
f = open (“Items.dat”, “ab”)
Item = [ ]
ans = „y‟
while ans == „y‟:
code = input(“Enter Item Code :”)
desc = input(“Enter description :”)
price = float(input(“Enter price:”))
Item.append ( [code,desc,price] )
ans = input(“Add more record? (y/n) :”)
p.dump( Item,f )
f.close( )
136
(ii) def SearchRec(code):
f = open("Items.dat", "rb")
Item = [ ]
found = False
while True:
try:
Item = p.load(f)
except:
break
for e in Item:
if e[0] == code :
print(e[0],"\t",e[1],"\t",e[2])
found = True
break
if found == False:
print("No such record")
Unit- 2
137
Q12. An attack that encrypts files in a computer and only gets decrypted after paying money to the
attacker..
a) Botnet b) Trojan c) Ransomware d) Spam
Ans: c) Ransomware
Q13. Name the fastest available transmission media.
Ans: OFC (Optical Fiber Cable)
Q2. Ravi has purchased a new Smart TV and wants to cast a video from his mobile to his new Smart
TV. Identify the type of network he is using and explain it.
Ans: Ravi is using PAN-Personal Area Network. It is a private network which is setup by an individual
to transfer data among his personal devices of home.
Q3.Differentiate between Virus and worms.
Ans: Viruses require an active host program or an already-infected and active operating system in
order for viruses to run, cause damage and infect other executable files or documents.
Worms are stand-alone malicious programs that can self-replicate.
Q4.Your friend Rakesh complaints that somebody accessed his mobile device remotely and deleted the
important files. Also he claims that the password of his social media accounts were changed. Write a
the name of crime?
Ans:The gaining of unauthorized access to data in a system or computer is termed as hacking. It can
be classified in two ways: (i) Ethical Hacking (ii)Cracking
Q5. What is the difference between hub and switch? Which is more preferable in a large network of
computers and why?
138
Ans: Hub forwards the message to every node connected and create a huge traffic in the network hence
reduces efficiency whereas a Switch (also called intelligent hub) redirects the received information/
packet to the intended node(s).
In a large network a switch is preferred to reduce the unwanted traffic in the network. It makes the
network much more efficient.
Q6.Differentiate between web server and web browser. Write any two popular web browsers.
Ans: Web Browser : A web browser is a software application for accessing information on the World
Wide Web. When a user requests a web page from a particular website, the web browser retrieves the
necessary content from a web server and then displays the page on the user‟s device.
Web Server : A web server is a computer that runs websites. The basic objective of the webserver is to
store, process and deliver web pages to the users. This intercommunication is done using Hypertext
Transfer Protocol (HTTP).
Popular web browsers: Google Chrome, Mozila Firefox, Internet Explorer etc.
ADMIN
i. Suggest the most suitable location to install the main server of this institution to get efficient
connectivity.
ii. Suggest by drawing the best cable layout for effective network connectivity of the blocks
having server with all the other blocks.
139
iii. Suggest the devices to be installed in each of these buildings for connecting computers installed
within the building out of the following:
Modem, Switch, Gateway, Router
iv. Suggest the most suitable wired medium for efficiently connecting each computer installed in
every building out of the following network cables:
Coaxial Cable, Ethernet Cable, Single Pair, Telephone Cable
v. Suggest the type of implemented network.
Q2.
PVS Computers decided to open a new office at Ernakulum, the office consist of Five Buildings and
each contains number of computers. The details are shown below.
Building-2
Building-1 Building-3
Building-4
Building-5
Q3. Differentiate between DDL and DML with one Example each.
Ans: DDL- Data definition language. Consists of commands used to modify the metadata of a table.
For Example- create table, alter table, drop table.
DML-Data manipulation language. Consist of commands used to modify the data of a table. For
Example- insert, delete, update
Q4. What do understand by an Alternate key?
Ans: Those candidate keys which are not made the Primary key are called the Alternate keys.
Q5. Answer the following :
i) Name the package for connecting Python with MySQL database.
ii) What is the purpose of cursor object?
Ans: (i) import mysql.connector
ii) It is the object that helps to execute the SQL queries and facilitate row by row processing of records
in the resultset.
Q6. How is equi-join different from natural-join? Give example.
Ans: Equi-join : It is a sql join where we use the equal sign as the comparison operator while
specifying the join condition. In this, the common column from both the tables will appear twice in the
output.
Natural join : It is similar to Equi-join but only one of the identical columns exist in the output.
Example : select * from student, course where course.cid = student.cid; (Equi-join) Select * from
student natural join course where course.cid = student.cid; (Natural join)
Q7. Differentiate between fetchone() and fetchmany() methods with suitable examples for each.
Ans: fetchone() is used to retrieve one record at a time but fetchmany(n) will fetch n records at a time
from the table in the form of a tuple.
142
Example: fetchone():
cursor.execute("SELECT * FROM employees")
row = cursor.fetchone()
while row is not None:
print(row)
row = cursor.fetchone()
fetchmany()
cursor.execute("SELECT * FROM employees ORDER BY emp_no")
head_rows = cursor.fetchmany(size=2)
Q8. What is the difference between CHAR & VARCHAR data types in SQL? Give an example for
each.
Ans: CHAR is used to occupy fixed memory irrespective of the actual values but VARCHAR uses
only that much memory which is used actually for the entered values. E.g. CHAR(10) will occupy
always 10 bytes in memory no matter how many characters are used in values. But VARCHAR will
uses only that much bytes of memory whose values are passed.
Q9. Differentiate between an Attribute and a Tuple in a Relational Database with suitable example.
Ans: Attributes / Field: Columns of the table (Relation) is called as attributes.
Tuple: Rows of the table (relation) is called as a tuple (record).
TABLE: VISITOR
(a) Write the name of most appropriate column which can be considered as Primary key?
(b) Which command will be used to see the Structure of a table Visitor ?
(c) What is the degree and cardinality of the table?
(d) Insert the following data into the attributes VisitorID, VisitorName and ContactNumberrespectively
in the given table VISITOR.
VisitorID = “V004”, VisitorName= “VISHESH” and ContactNumber=9907607474
(e)Remove the table VISITOR from the database HOTEL. Which command will he used from the
following:
a) DELETE FROM VISITOR;
b) DROP TABLE VISITOR;
143
c) DROP DATABASE HOTEL;
d) DELETE VISITOR FROM HOTEL;
Ans:
(a) VIsitorID
(b) DESCRIBE VISITOR
(c) Degree= 3, Cardinality=4
(d) insert into VISITOR values(“V004”, “VISHESH”,9907607474)
(e) DROP TABLE VISITOR
Q2.A departmental store MyStore is considering to maintain their inventory using SQL to store
the data. As a database administer,
Name of the database – mystore
Name of the table - STORE
The attributes of STORE are as follows:
ItemNo - numeric
ItemName – character of size 20
Scode - numeric
Quantity – numeric
Table : STORE
ItemNo ItemName Scode Quantity
2005 Sharpener Classic 23 60
2003 Ball Pen 0.25 22 50
2002 Get Pen Premium 21 150
2006 Get Pen Classic 21 250
2001 Eraser Small 22 220
2004 Eraser Big 22 110
2009 Ball Pen 0.5 21 180
Q4. Consider a database LOANS and Write SQL queries for (i) to (iii)
Table: LOANS
(i) Display the sum of all Loan Amounts whose Interest rate is greater than 10.
(ii) Display the Maximum Interest from Loans table
(iii) Display the count of all loan holders whose names are ending with „Sharma‟
145
Ans: (i) Select sum(Loan_Amount) from LOANS where Interest >10;
(ii) Select max(Interest) from LOANS;
(iii) Select count(*) from LOANS where Cust_Name Like „%Sharma‟;
Table : DEALERS
Dcode Dname Location
101 Vikash Stationers Lanka Varanasi
102 Bharat Drawing Emporium Luxa Varanasi
103 Banaras Books Corporation Bansphatak Varanasi
(i) To display all the information about items containing the word “pen” in the field Itname in
the table STOCK.
(ii) List all the itname sold by Vikash Stationers.
(iii) List all the Itname and StkDate in ascending order of StkDate.
(iv) List all the Itname, Qty and Dname for all the items for the items quantity more than 40.
(v) List all the details of the items for which UnitPrc is more than 10 and <= 50.
Ans: (i) SELECT * FROM STOCK WHERE Itname LIKE “%pen%”;
(ii) SELECT DISTINCT(Itname) FROM STOCK, DEALERS WHERE STOCK.Dcode=
DEALERS.Dcode;
(iii) SELECT Itname, StkDate FROM STOCK ORDER BY StkDate;
(iv) SELECT Itname, Qty, Dname FROM STOCK, DEALERS WHERE STOCK.Dcode=
DEALERS.Dcode;
(v) SELECT * FROM STOCK WHERE UnitPrc BETWEEN 10 AND 50;
146
KENDRIYA VIDYALAYA SANGATHAN
RAIPUR REGION
BLUE PRINT BASED ON CBSE SAMPLE PAPER
Computer Science (083) –
Class XII
TOPICS 1 Mark 2 Marks 3 Marks 4 Marks 5 Marks Total
Short Long Case study Very
answer answer based Long
questions questions questions. answer
with with Examinee questions
internal internal has to with
options options attempt 4 internal
parts out of option in
5 sub parts one
question
147
KENDRIYA VIDYALAYA RAIPUR REGION
COMPUTER SCIENCE (083)
CLASS :XII
BLUE PRINT BASED ON CBSE SAMPLE PAPER
PART A SECTION-1 15 MARKS (15X1 mark)+6 choice
148
KENDRIYA VIDYALAYA SANGATHAN, RAIPUR REGION
SAMPLE PAPER -I
Class: XII
Subject: Computer Science (083)
Maximum Marks:70 Time Allowed: 3hours
___________________________________________________________________________________
General Instructions:
1. This question paper contains two parts A and B. Each part is compulsory.
2. Both Part A and Part B have choices.
3. Part-A has 2sections:
a. Section – I is short answer questions, to be answered in one word or one line.
b. Section – II has two case studies questions. Each case study has 4 case-based sub- parts. An
examinee is to attempt any 4 out of the 5 subparts.
4. Part - B is Descriptive Paper.
5. Part- B has three sections
a. Section-I is short answer questions of 2 marks each in which two question have internal options.
b. Section-II is long answer questions of 3 marks each in which two questions have internal options.
c. Section-III is very long answer questions of 5 marks each in which one question has internal option.
6. All programming questions are to be answered using Python Language only
Q.NO Section-I Marks
Select the most appropriate option out of the options given for each question. Attempt allocated
any 15 questions from question no 1 to 21.
1 Which of the following is not a valid identifier name in Python? Justify reason for it 1
not being a valid name.
3 Write the importance of passing file mode while declaring a file object in data file handling. 1
a) DELETE b) CREATE
c) INSERT d) UPDATE
15 What do you understand by data transfer rate? 1
16 Identify the valid declaration of L: 1
L = [„JAN‟, „12‟, „NEW YEAR‟, ‟365‟]
a.dictionary b. string
c.tuple d. list
17 Suppose list1 = [0.5 * x for x in range(0,4)], list1 is 1
a) [0, 1, 2, 3] b) [0, 1, 2, 3, 4]
c) [0.0, 0.5, 1.0, 1.5] d) [0.0, 0.5, 1.0, 1.5, 2.0]
18 Write an SQL query to display all the attributes of a relation named 1
“exam” along with their description.
19 Give the full form of the following: 1
(a) URL (b) TDMA
20 Write SQL statement to find total number of records in table stu? 1
21 Write the name of topology in which all the nodes are connected through a 1
single Coaxial cable?
Section-II
Both the Case study based questions are compulsory. Attempt any 4 sub parts from
each question. Each question carries 1 mark
22 A medical store Devshri is considering to maintain their inventory using SQL to store the
data. As a database administer, atul has decided that:
• Name of the database -Devshri
• Name of the table -medicalstore
• The attributes of medicalstore are as:
MedicineNo - numeric
MedicineName – character of size 25
MedCode– numeric
Quantity – numeric
2
MedicineNo MedicineNa MedCode Quantity
me
5647 Saridon 141 75
5741 Paracetamol 142 44
3546 Nicip Plus 141 60
9541 Disprin 140 53
2025 Diclofenac 143 73
2783 Corex Syrup 141 97
8614 Psorid 142 48
a) Identify the attribute best suitable to be declared as a primary key, 1
(b) Write the degree and cardinality of the table medicalstore. 1
(c) Insert the following data into the attributes respectively in the given table medicalstore. 1
MedicineNo = 6647, MedicineName = “Dapsone”, MedCode = 141 and Quantity = 55
(d) Atul want to remove the table medicalstore from the database Devshri. Which command 1
will he use from the following:
a) DELETE FROM Devshree;
b) DROP TABLE medicalstore;
c) DROP DATAB AS medicalstore;
d) DELETE medicalstore FROM Devshree;
(e) Now Sahil wants to know the Primary key of the table along with data types of all the 1
columns. Which query should he write?
23 Rohit of class 12 is writing a program to search a name in a CSV file
“MYFILE.csv”. He has written the following code. As a programmer, help him to
Successfully execute the given task.
import _________ # Statement 1
f = open("MYFILE.csv", _______) # Statement 2
data = ____________ ( f ) # Statement 3
nm = input("Enter name to be searched: ")
for rec in data:
if rec[0] == nm:
print (rec)
f.________( ) # Statement 4
.
(a) Name the module he should import in Statement 1. 1
(b) In which mode, Rohit should open the file to search the data in the file in 1
Statement 2? 1
(c) Fill in the blank in Statement 3 to read the data from the file. 1
(d) Fill in the blank in Statement 4 to close the file. 1
(e) Write the full form of CSV
Part B
Section-I
24 2
Evaluate the following expressions:
a) 15*(4%4)//2+6
b) not 10> 5 and 2 < 11 or not 10 < 2
25 Differentiate between SMTP & POP3. 2
OR
List any two security measures to ensure network security.
26 2
Expand the following terms:
3
a) IPR b) SIM c) IMAP d)HTTP
27 What is a module in Python? Define any two functions of Math module in 2
python.
OR
Differentiate between Positional Argument and Default Argument of function in
python with suitable example
28 Observe the following Python code very carefully and rewrite it after removing 2
all syntactical errors with each correction underlined.
DEF callme():
x = input("Enter a number:")
if (abs(a)= a):
print("You entered a positive number")
else:
a=*-2
print ("Number made positive:" a)
callme()
29 What possible outputs(s) are expected to be displayed on screen at the time of execution of 2
the program from the following code?
import random
x=3
N = random, randint (1, x)
for i in range (N):
print(i, „#‟, i + i)
a. What is the minimum and maximum number of times the loop will execute?
b. Find out, which line of output(s) out of (i) to (iv) will not be expected from the
program?
i. 0#1
ii. 1#2
iii. 2#3
iv. 3#4
Section -II
34 Write a function in Display which accepts a list of integers and its size as 3
4
arguments and replaces elements having even values with its half and elements
having odd values with twice its value .
eg: if the list contains
5, 6, 7, 16, 9
then the function should rearranged list as
10, 3,14,8, 18
35 Write a method in python to read lines from a text file Test.TXT and display 3
those lines which start with the alphabets B.
OR
Write a function Count_word( ) in python to read the text file "story.txt" and count
the number of times "vidyalaya" occurs in the file. For example if the file story.txt
contains:
"This is my vidyalaya. I love to play and study in my vidyalaya."
the Count_word ( ) function should display the output as:"vidyalaya occurs 2 times".
36 Write the output of the SQL queries (i) to (iii) based on the table: Staff 3
5
Note: * In Villages, there are community centres, in which one room has been
given as training center to this organization to install computers. * The organization
has got financial support from the government and top IT companies.
1. Suggest the most appropriate location of the SERVER in the YHUB (out of
the 4 locations), to get the best and effective connectivity. Justify your
answer.
2. Suggest the best wired medium and draw the cable layout (location to
6
location) to efficiently connect various locations within the YHUB.
3. Which hardware device will you suggest to connect all the computers within
each location of YHUB?
39 Consider the tables given below which are linked with each other and maintains 5
referential integrity.
Table :Party
Partyid Description Costperperson
P101 Birthday 400
P102 Wedding 700
P103 Farewell 350
P104 Engagement 450
Table: Client
7
Adarsh
Nagar
C102 Fauzia Aria K-5/52 981166568 500 P102
Vikas
Vihar
C103 Rashi Khanaa D-6 981166568 50 P101
Hakikat
Nagar
C104 S.K.Chandra 76-A/2 65877756 100 P104
MG
Colony
Adarsh
Avenue
(ii) „P101‟ data is present twice in column „PartyId‟ in „Client‟ table – Is there any
discrepancy? Justify your answer.
With reference to the above given tables , Write commands in SQL for (iii) and (iv)
and write output for (v)
(iii) To display Client names of clients, their phone numbers,PartyId and party description
who will have number of guests more than 50 for their parties.
(iv) To display Client Ids, their addresses, number of guests of those clients who have
„Adarsh‟ anywhere in their addresses.
8
KENDRIYA VIDYALAYA SANGATHAN, RAIPUR REGION
SAMPLE PAPER -2
Class: XII
Subject: Computer Science (083)
Maximum Marks:70 Time Allowed: 3hours
__________________________________________________________________________________
_
General Instructions:
1. This question paper contains two parts A and B. Each part is compulsory.
2. Both Part A and Part B have choices.
3. Part-A has 2sections:
a. Section – I is short answer questions, to be answered in one word or one line.
b. Section – II has two case studies questions. Each case study has 4 case-based sub-
parts. An examinee is to attempt any 4 out of the 5 subparts.
4. Part - B is Descriptive Paper.
5. Part- B has three sections
a. Section-I is short answer questions of 2 marks each in which two question have
internal options.
b. Section-II is long answer questions of 3 marks each in which two questions have
internal options.
c. Section-III is very long answer questions of 5 marks each in which one question has
internal option.
6. All programming questions are to be answered using Python Language only
Q.NO Section-I Marks
Select the most appropriate option out of the options given for each question. Attempt allocated
any 15 questions from question no 1 to 21.
1 Which of the following is a valid identifier name in Python? And justify your answer. 1
>>>A[5:15:2]
a) DELETE b) UPDATE
c) INSERT d) ALL
15 Name the Transmission media which consists of an inner copper core and a second 1
conducting outer sheath
16 Identify the data type of R: 1
R = tuple(list( (3,5,7,6,11) ) )
2
Table student
AdmissionNo FirstName LastName DOB
012355 Rahul Singh 2005-05-16
012358 Mukesh Kumar 2004-09-15
012360 Pawan Verma 2004-03-03
012366 Mahesh Kumar 2003-06-08
012367 Raman Patel 2007-03-19
Attempt any four questions
(i)What is the degree and cardinality of the table student 1
(ii)Identify the attribute best suitable to be declared as Primary Key 1
(iii)Insert the following data in table student 1
AdmissionNo=012368
FirstName = Kamlesh
LastName = Sharma
DOB =01 Jan 2004
(iv) Pratham wants to remove the data of mukesh whose admission no is 012358, suggest 1
him SQL command to remove the above said data.
(v) To remove the table student which command is used : 1
i. Delete from student
ii. Drop table student
iii. Drop database school
iv. Delete student from school
23 Sourya Pratap Singh of class 12 is writing a program to create a CSV file “phone.csv”
which will contain Name and Mobile Number for some entries. He has written the
following code. As a programmer, help him to successfully execute the given task.
import # Line 1
def addCsvFile(Name,Mobile): # to write / add data into the CSV file
f=open(' phone.csv',' ') # Line 2
newFileWriter = csv.writer(f)
newFileWriter.writerow([Name,Mobile])
f.close()
#csv file reading code
def readCsvFile(): # to read data from CSV file
with open(' phone.csv','r') as newFile:
newFileReader = csv. (newFile) # Line 3
for row in newFileReader:
print (row[0],row[1])
newFile. # Line 4
addCsvFile(“Atul”,”1111111111”)
addCsvFile(“Arun”,”2222222222”)
addCsvFile(“Amit”,”3333333333”)
readCsvFile() #Line 5
3
a) Name the module he should import in Line 1. 1
b) In which mode, Sourya Pratap singh should open the file to add data into the file 1
c) Fill in the blank in Line 3 to read the data from a csv file. 1
d) Fill in the blank in Line 4 to close the file. 1
e) Write the output he will obtain while executing Line 5. 1
Part B
Section-I
24 2
Evaluate the following expressions:
a) 7*5+2**4//2-3
b) 5<10 or 12<7 and not 3>18
25 Differentiate between Viruses and Trojans in context of networking and data ommunication 2
threats.
OR
Differentiate between Website and webpage. Write any two popular example of online
shopping..
26 2
Expand the following terms:
a. IP b.MAN c.NIC d. UTP
27 Differentiate between break and continue statements with a suitable example. 2
OR
What is the difference between local and a global variable? Explain with the help of a
suitable example
28 Rewrite the following Python program after removing all the syntactical errors (if any), 2
underlining each correction:
def Data:
w = input("Enter a number")
if w % 2 =0:
print (w, "is Even Value")
elseif w<0:
print (w, "should be positive Value")
else;
print (w, "is odd Value")
29 What possible outputs(s) are expected to be displayed on screen at the time of execution of 2
the program from the following code? Also specify the maximum values that can be
assigned to each of the variables FROM and TO.
4
def Update (A=10,B=20):
33 A=A+B 2
B=A-B
print(A,"#",B)
return(A)
X=5
Y=10
R=Update(X,Y)
print(X,"#",Y)
S=Update(X)
Part B( Section II)
34 Take the two lists, and write a program that returns a list only the elements that are common 3
between both the lists (without duplicates) in ascending order. Make sure your program
works on two lists of different sizes.
e.g.
L1= [1,1,2,3,5,8,13,21,34,55,89]
L2= [20,1,2,3,4,5,6,7,8,9,10,11,12,13]
The output should be:
[1,2,3,5,8,13]
35 Write a function COUNT_AND( ) in Python to read the text file “STORY.TXT” and count 3
the number of times “AND” occurs in the file. (include AND/and/And in the counting)
OR
Write a function DISPLAYWORDS( ) in python to display the count of words starting with
“t” or “T” in a text file „STORY.TXT‟.
36 Table : Employee 3
EmployeeId Name Sales JobId
E1 Sumit Sinha 110000 102
E2 Vijay Singh 130000 101
Tomar
E3 Ajay Rajpal 140000 103
E4 Mohit Kumar 125000 102
E5 Sailja Singh 145000 103
Table: Job
JobId JobTitle Salary
101 President 200000
102 Vice President 125000
103 Administrator Assistant 80000
104 Accounting Manager 70000
105 Accountant 65000
106 Sales Manager 80000
Give the output of following SQL statement:
(i) Select max(salary),min(salary) from job
(ii) Select Name,JobTitle, Sales from Employee,Job
where Employee.JobId=Job.JobId and JobId in (101,102)
(iii)Select JobId, count(*) from Employee group by JobId
37 Write a function in Python PUSH(Arr), where Arr is a list of numbers. From this list push 3
all numbers divisible by 5 into a stack implemented by using a list. Display the stack if it
has at least one element, otherwise display appropriate error message.
OR
5
Write a function in Python POP(Arr), where Arr is a stack implemented by a list of
numbers. The function returns the value deleted from the stack.
Section- III
38 LaDadaBhai Marketing Ltd. has four branches in its campus named Raipur, Balod, Bhilai 5
Office and Bilaspur . DadaBhai Marketing Ltd. wants to establish the networking between
all the four offices. A rough layout of the same is as follows:
Raipur Bhilai
Office Office
Bilaspur Balod
Office Office
Approximate distances between these offices as per network survey team are as follows:
Place From Place To Distance
Raipur Bhilai 30 m
Bhilai Balod 40 m
Balod Bilaspur 25 m
Raipur Bilaspur 150 m
Bhilai Bilaspur 105 m
Raipur Balod 60 m
In continuation of the above, the company experts have planned to install the following
number of computers in each of their offices:
Raipur 40
Bhilai 80
Balod 200
Bilaspur 60
i. Suggest the most suitable place (i.e., Block/Center) to install the server of
this organization with a suitable reason.
ii. Suggest an ideal layout for connecting these blocks/centers for a wired
connectivity.
iii. Which device will you suggest to be placed/installed in each of these offices
to efficiently connect all the computers within these offices?
iv. Suggest the placement of a Repeater in the network with justification.
v. The organization is planning to connect its new office in Delhi, which is
more than 1250 km current location. Which type of network out of LAN, MAN, or WAN
will be formed? Justify your answer
39 5
Write SQL queries for (i) to (v), which are based on the table: SCHOOL and
ADMIN
6
TABLE: SCHOOL
CODE TEACHERNAM SUBJECT DOJ PERIODS EXPERIENC
E E
1001 RAVI SHANKAR ENGLISH 12/03/2000 24 10
TABLE: ADMIN
CODE GENDER DESIGNATION
1001 MALE VICE PRINCIPAL
1009 FEMALE COORDINATOR
1203 FEMALE COORDINATOR
1045 MALE HOD
1123 MALE SENIOR TEACHER
1167 MALE SENIOR TEACHER
1215 MALE HOD
7
iii) To Display number of teachers in each subject.
iv) To display details of all teachers who have joined the school after 01/01/1999 in
descending order of experience.
v) Delete all the entries of those teachers whose experience is less than 10 years in
SCHOOL table.
A binary file named “EMP.dat” has some records of the structure
40 [EmpNo, EName, Post, Salary] 5
(a)Write a user-defined function named NewEmp() to input the details of a new
employee from the user and store it in EMP.dat.
(b) Write a user-defined function named SumSalary(Post) that will accept an argument
the post of employees & read the contents of EMP.dat and calculate the SUM of salary
of all employees of that Post.
Or
A binary file named “TEST.dat” has some records of the structure
[TestId, Subject, MaxMarks, ScoredMarks]
8
1
>>>A[::2]
3 Which is the file access mode using for both reading and writing in python? 1
4 Which of the following is a Invalid relational operator in Python? 1
a) > b) < c) = < d) > =
5 What is the result of code shown below? 1
>>> t1=("sun","mon","tue","wed")
>>> print(t1[-1])
6 Write a statement in Python to declare a dictionary whose keys are Day,Month,Year and 1
values are 31, 12 and 2020 respectively
7 What is the wrong in the following code ? 1
t1=(10,20,30,40,50,60,70,80)
i=t1.len()
print(t1,i)
2
8 Differentiate between the round ( ) and floor ( ) functions with the help of suitable example. 1
9 Name the protocol that is used to receive e-mail ……………………………… 1
10 What is Phishing? Explain with examples. 1
11 The FROM SQL clause is used to… 1
A) specify what table we are selecting or deleting data FROM
B) specify range for search condition
C) specify search condition
D) None of these
12 Which SQL keyword is used to retrieve a maximum value? 1
A) TOP
B) MOST
C) UPPER
D) MAX
13 Which of the following is not a built in aggregate function in SQL? 1
a) avg
b) max
c) total
d) count
14 In SQL, what is the use of Like Operator? 1
15 Name two transmission media for networking. 1
16 What will be the output of the following Python code? 1
>>>t = (1, 2)
>>>2 * t
a) (1, 2, 1, 2)
b) [1, 2, 1, 2]
c) (1, 1, 2, 2)
d) [1, 1, 2, 2]
17 Write the output of the following python code: 1
aList = [5, 10, 15, 25]
print(aList[::-2])
import #Line 1
with open('d:\\abc.csv','w') as newFile:
newFileWriter = csv.writer(newFile)
newFileWriter.writerow(['user_id','beneficiary'])
newFileWriter. ([1,'xyz']) #Line2
newFile.close()
with open('d:\\abc.csv','r') as newFile:
newFileReader = csv. (newFile) #Line 3
for row in newFileReader:
print (row) #Line 4
newFile. #Line 5
Part B
Section-I
24 2
Evaluate the following expressions:
a) 4+2*5**2//4-2
b) 75>56 and 1<0 and not 2>4
25 What is the difference between packet switching and circuit switching techniques?. 2
OR
State two reasons for which you may like to have a network of computers instead of having
4
standalone computers...
26 2
Expand the following terms:
(a) VoIP (b) SMTP (c) TDMA (d) TCP/IP
27 What is the difference between actual and formal parameters. 2
OR
What do you mean by scope of variables ?
28 Rewrite the following code in python after removing all syntax error(s). Underline 2
each correction done in the code.
a=int{input("ENTER FIRST NUMBER")}
b=int(input("ENTER SECOND NUMBER"))
c=int(input("ENTER THIRD NUMBER"))
if a>b and a>c
print("A IS GREATER")
if b>a and b>c:
Print(" B IS GREATER")
if c>a and c>b:
print(C IS GREATER)
29 What will be the possible output(s), from options (i) to (iv) of the following code segment, 2
also write minimum and maximum value of N when I = 2.
import random
L=10
P=10
for I in range(1,4):
N=L+random.randrange(P)+1
print(N, end = "@")
P -= 1
(i)10@12@13@
(ii)11@14@18@
(iii)12@16@20@
(iv)13@20@15@
30 Differentiate between DDL and DML commands. 2
31 What is a cursor and how to create it in Python SQL connectivity? 2
32 How Varchar is different from char datatype in SQL? 2
Find and write the output of the following python code:
s = 'XYZ'
33 for i in range(len(s)): 2
if i % 2 == 0:
print(s[i] * 2)
else:
print(s[i] * i)
Part B( Section II)
34 Write a Python function to sum all the even numbers in a list. 3
Write a function in python to count and display the no. of words starting with “S” in a text
file “Poem.txt”.
36 3
Write SQL queries (i) to (iii) based on the relation Graduate.
S.NO NAME STIPEND SUBJECT AVERAGE DIV
1 KARAN 400 PHYSICS 68 I
2 DIWAKAR 450 COMP. Sc. 68 I
3 DIVYA 300 CHEMISTRY 62 I
4 REKHA 350 PHYSICS 63 I
5 ARJUN 500 MATHS 70 I
6 SABINA 400 CEHMISTRY 55 II
7 JOHN 250 PHYSICS 64 I
8 ROBERT 450 MATHS 68 I
9 RUBINA 500 COMP. Sc. 62 I
10 VIKAS 400 MATHS 57 II
37 Write a function in Python PUSH() to insert an element in the stack. After inserting 3
the element display the stack.
OR
Write a function in Python POP() to remove the element from the stack and also
display the deleted value.
Section- III
38 Ravya Industries has set up its new center at Kaka Nagar for its office and web based 5
activities. The company compound has 4 buildings as shown in the diagram below:
Fazz
Raj
Building
Building
Jazz
Harsh Building
Building
6
Harsh Building 15
Raj Building 150
Fazz Building 15
Jazz Bulding 25
2) Suggest the most suitable place (i.e. building) to house the server of this
organization with a suitable reason.
(i) Repeater
39 Write SQL command for (i) to (v) on the basis of the table Employees & EmpSalary 5
Table: Employee
Empid Firstname Lastname Address City
010 Ravi Kumar Raj nagar GZB
105 Harry Waltor Gandhi GZB
nagar
152 Sam Tones 33 Elm St. Paris
215 Sarah Ackerman 440 U.S. 110 Upton
244 Manila Sengupta 24 Friends New Delhi
300 Robert Samuel 9 Fifth Cross Washington
335 Ritu Tondon Shastri GZB
Nagar
400 Rachel Lee 121 Harrison New York
441 Peter Thompson 11 Red Road Paris
Table: EmpSalary
Empid Salary Benefits Designation
010 75000 15000 Manager
105 65000 15000 Manager
152 80000 25000 Director
215 75000 12500 Manager
244 50000 12000 Clerk
300 45000 10000 Clerk
335 40000 10000 Clerk
400 32000 7500 Salesman
441 28000 7500 salesman
a) To show firstname,lastname,address and city of all employee living in paris
b) To display the content of Employee table in descending order of Firstname.
c) To display the firstname,lastname and total salary of all managers from the tables
Employee and empsalary , where total salary is calculated as salary+benefits.
d) To display Empid, Designation and Salary of all employee from EmpSalary table
whose benefits more than 14000.
e) To display empid, FirstName and city from employee table whose lastname start
with s.
40 A binary file “EMPLOYEE. DAT’ has structure as empcode, Name and Salary. 5
Write a function count() that would read content of the file “EMPLOYEE.DAT”
and display the details of all those employee whose salary is more than 50000.
Or
Consider a binary file emp.dat having records in the form of dictionary. E.g
{eno:1, name:”Rahul”, sal: 5000}
8
write a python function to display the records of above file for those employees who
get salary between 25000 and 30000.
KENDRIYA VIDYALAYA SANGATHAN, RAIPUR REGION
SAMPLE PAPER -4
Class: XII
Subject: Computer Science (083)
Maximum Marks:70 Time Allowed: 3hours
__________________________________________________________________________________
_
General Instructions:
1. This question paper contains two parts A and B. Each part is compulsory.
2. Both Part A and Part B have choices.
3. Part-A has 2sections:
a. Section – I is short answer questions, to be answered in one word or one line.
b. Section – II has two case studies questions. Each case study has 4 case-based sub-
parts. An examinee is to attempt any 4 out of the 5 subparts.
4. Part - B is Descriptive Paper.
5. Part- B has three sections
a. Section-I is short answer questions of 2 marks each in which two question have
internal options.
b. Section-II is long answer questions of 3 marks each in which two questions have
internal options.
c. Section-III is very long answer questions of 5 marks each in which one question has
internal option.
6. All programming questions are to be answered using Python Language only
Q.NO Section-I Marks
Select the most appropriate option out of the options given for each question. Attempt allocated
any 15 questions from question no 1 to 21.
1 Which of the following is / are valid identifier/s in Python: 1
3 ……………………is a process of storing data into files and allows to performs various 1
tasks such as read, write, append, search and modify in files.
4 What is the output of the following code : 1
>>> print(9//2)
(A) 4.5
(B) 4.0
(C) 4
(D) Error
5 What is the result of code shown below? 1
tuple1 = (10, 20)
tuple2 = (30, 40)
tuple1, tuple2 = tuple2, tuple1
print(tuple2)
1
print(tuple1)
6 Write a statement in Python to declare a dictionary whose keys are 1
Mon,Tues,Wed,Thur,Fri,Sat and values are “CS”,”Phy”,”Chem”,”Maths” “Eng” and
“Hindi” respectively
7 A tuple is declared as T = (10,20), (10,20,40), (50,30) 1
What will be the value of min(T) ?
8 What are the built-in types of python?. 1
9 A ……………… is a device that works like a bridge but can handle different protocols 1
10 Posing as someone else online and using his/her personal/financial information shopping or 1
posting something is a common type of cyber-crime these days. What are such types of
cyber-crimes collectively called?
11 What is the purpose of using references word in terms of DBMS/RDBMS? 1
12 Which clause of select command is used to group the rows on the basis of common values 1
in a column?
13 Which of the following is/are built in aggregate function in SQL? 1
a) sum
b) min
c)count
d) All
14 Sourabh wants to remove all rows from the table ACCT. But he needs to maintain the 1
structure of the table. Which command is used to implement the same?
15 Write one characteristic each for 2G and 3G mobile technologies. 1
16 What will be the output of the following Python code? 1
S= “Hello Friends”
print S[:-4]
print S[-4:]
17 How many times is the following loop executed? 1
i = 100
while (i<=200):
print i
i + =20
18 While creating table „customer‟, Maneesha forgot to add column „price‟. Which command 1
is used to add new column in the table. Write the command to implement the same.
19 Write two characterstics of Wi-Fi.. 1
20 What is relation? Define the relational data model. 1
21 Identify the Domain name and URL from the following: 1
http://www.income.in/home.aboutus.hml.
Section-II
Both the Case study based questions are compulsory. Attempt any 4 sub parts from
each question. Each question carries 1 mark
22 As a database administrator, answer any 4 of the following questions:
Name of the table : S_DRINK
The attributes are as follows:
Drinkcode, Calories – Integer
Price - Decimal
Dname - Varchar of size 20
2
Drinkcode Dname Price Calories
import #Line 1
f = open(“Games.csv”,”a”)
wobj = csv. (f, delimiter = ‘\t’) # Line 2
3
a) Name the module he should import in Line 1 1
b) To create an object to enable to write in the csv file in Line 2 1
c) To create a sequence of user data in Line 3 1
d) To write a record onto the writer object in Line 4 1
e) Fill in the blank in Line 5 to close the file. 1
Part B
Section-I
24 2
Evaluate the following expressions:
a) (2**2)*(3**3)//(2**4)
b) 2>1 and 1<0 and not 4>2
25 What is the function of Modem? 2
OR
In networking, what is WAN? How is it different from LAN?.
26 2
Expand the following terms:
(a) WLL (b) 5G (c) POP3 (d) Gbps
27 Which string method is used to implement the following: 2
function double(x):
return 2*x
I =int(input())
N = double (I)
if N= 100:
print(“Input is equal to 50”)
else:
print(“Double of the Number”+ I + “is” + N)
29 What are the possible outcome(s) expected from the following python code? Also specify 2
the maximum and minimum values that can be assigned to variable .
import random
def Show():
p = "MY PROGRAM"
i=0
while p[i] != "R":
l = random.randint(0,3) + 5
print(p[l],"-")
i += 1
Show()
(i) R – P – O – R – (ii) P – O – R – Y –
4
(iii) O – R – A – G – (iv) A– G – R – M –
But the query is’nt producing the result. Identify the problem.
Find and write the output of the following python code:
def Find():
33 L = "computer" 2
x=""
count = 1
for i in L:
if i in ['a', 'e',' i', 'o', 'u']:
x=x+i
else:
if (count%2!= 0):
x = x + str(len(L[:count]))
else:
x=x+i
count = count + 1
print(x)
Find()
5
36 Write output for queries (i) to(iii), which are based on the table : 3
Books.
Publishe
Book_id Book_name Author_name r Price Qty
William
F0001 The Tears hopkin NIL 650 20
Brain&
T0001 My First Py Brooke EPB 350 10
A.W.
T0002 Brain works Rossaine TDH 450 15
Thunderbolt
F0002 s Anna Roberts NIL 750 5
JUNIOR
SENIOR
ADMIN HOSTEL
6
Distance between various wings are given below:
1. Suggest the best wired medium and draw the cable layout to efficiently connect various
wings of Happy Home Public School, RAIPUR.
2. Name the most suitable wing where the Server should be installed. Justify
your answer.
3. Suggest a device/software and its placement that would provide data security for the
entire network of the School
4. Suggest a device and the protocol that shall be needed to provide wireless Internet access
to all smartphone/laptop users in the campus of Happy Home Public School,
RAIPUR
5. Suggest the placement of the Hub/Switch device with justification.
39 Write SQL command for (i) to (v) on the basis of the table Trainer & Course 5
Trainer
TID TNAME CITY HIREDATE SALARY
101 SUNANA MUMBAI 1998-10-15 90000
102 ANAMIKA DELHI 1994-12-24 80000
103 DEEPTI CHANDIGARG 2001-12-21 82000
104 MEENAKSHI DELHI 2002-12-25 78000
105 RICHA MUMBAI 1996-01-12 95000
106 MANIPRABHA CHENNAI 2001-12-12 69000
7
Course
a. Display the Trainer Name, City & Salary in descending order of their Hiredate.
b. To display the TNAME and CITY of Trainer who joined the Institute in the month of
December 2001.
c. To display TNAME, HIREDATE, CNAME, STARTDATE from tables TRAINER and
COURSE of all those courses whose FEES is less than or equal to 10000
d. To display number of Trainers from each city.
e. To Display the TID, TNAME and SALARY whose TNAME starts with „M‟.
40 Given a binary file “record.dat” has structure (Emp_id, Emp_name, Emp_Salary). Write 5
a function in Python Rec_count() in Python that would read contents of the file
“record.dat” and display the details of those employee whose salary is less than 20000
OR
(i)Write a function in Python add_record() to input data for a record and add to Stu.dat.
8
KENDRIYA VIDYALAYA SANGATHAN, RAIPUR REGION
SAMPLE PAPER -5
Class: XII
Subject: Computer Science (083)
Maximum Marks:70 Time Allowed: 3hours
__________________________________________________________________________________
_
General Instructions:
1. This question paper contains two parts A and B. Each part is compulsory.
2. Both Part A and Part B have choices.
3. Part-A has 2sections:
a. Section – I is short answer questions, to be answered in one word or one line.
b. Section – II has two case studies questions. Each case study has 4 case-based sub-
parts. An examinee is to attempt any 4 out of the 5 subparts.
4. Part - B is Descriptive Paper.
5. Part- B has three sections
a. Section-I is short answer questions of 2 marks each in which two question have
internal options.
b. Section-II is long answer questions of 3 marks each in which two questions have
internal options.
c. Section-III is very long answer questions of 5 marks each in which one question has
internal option.
6. All programming questions are to be answered using Python Language only
Q.NO Section-I Marks
Select the most appropriate option out of the options given for each question. Attempt allocated
any 15 questions from question no 1 to 21.
1 Out of the following, find those identifiers, which cannot be used for naming Variables 1
or functions in a Python program:
Total * Tax, While, class, Switch, 3rd Row, finally, Column 31, Total
2 What is the output when following code is executed? 1
3 A ___________ is plain text file which contains list of data in tabular form. 1
4 Which of the following is/are valid Membership Operators in Python? 1
a) ? b) < c) not in d) and e) in
5 What will be the output of the following Python code? 1
>>>my_tuple = (1, 2, 3, 4)
>>>my_tuple.append( (5, 6, 7) )
>>>print len(my_tuple)
a) 1
b) 2
c) 5
d) Error
1|Page
6 Given is the following Dictionary dict={1:’A’,2:’B’,3:’C’,6:’D’,4:’E’} ? What is the output 1
of the command print(dict[6])
7 Which of the options out of (i) to (iv) the correct data type for the variable lst is as 1
defined in the following Python statement?
lst = ('A', 'E', 'I', 'O', 'U')
(i) List
(ii) Dictionary
(iii) Tuple
(iv) Array
8 Name the Python Library modules which need to be imported to invoke the following 1
functions :
1. sin() 2. ceil()
9 What is MAC Address? 1
10 Credit card frauds, phishing, cyber bullying, spamming are kind of ………….crime 1
11 Which keyword eliminates redundant data from a query result? 1
12 What are alternate keys? 1
13 What is the use of UNIQUE constraint in MYSQL? 1
14 Which command is used to delete a table schema 1
i) Delete
ii) Drop
iii) Del
iv) Remove
15 What is Baud rate? 1
16 Write the output of the following code of python: 1
A={10:1000,20:2000,30:3000,40:4000,50:5000}
print A.keys()
print A.values()
18 Which is the table constraint used to stop null values to be entered in the field 1
(i) Unique
(ii) Not NULL
(iii) Not Empty
(iv) None
19 Name the media preferably used in the Internet Backbone of Country 1
20 In SQL, write the query to display the list of database in the server. 1
21 10:B4:03:56:2E:DF is an example of ………………………. 1
Section-II
Both the Case study based questions are compulsory. Attempt any 4 sub parts from
each question. Each question carries 1 mark
22 A Ramco Book Shop is considering to maintain their inventory using SQL to store the
data. As a database administer, Neelmadhav has decided that:
• Name of the database -Ramco
• Name of the table -shop
• The attributes of shop are as:
2|Page
ICODE,SCODE,QTY,RATE - numeric
INAME– character of size 25
BUYDATE -date
ICODE INAME SCODE QTY RATE BUYDATE
1005 Note Book 13 120 24 03-May-13
1003 Eraser 12 80 5 07-Aug-13
1002 Pencil 12 300 10 04-Mar-13
1006 Bag 11 70 300 27-Dec-12
1001 Pen 13 250 20 18-Jul-13
1004 Sharpener 12 100 10 23-Jun-13
1009 Box 11 50 80 17-Dec-12
3|Page
Part B
Section-I
24 Evaluate the following expressions: 2
a) 10*1 * 2**4 - 4// 4
b) 1> -1 and 15 < 12 or not 2 > 1
25 Explain LAN, WAN and MAN with examples. 2
OR
Differentiate between Internet and Intranet.
26 Write the full form of the following: 2
(i) LED (ii) Modem ( iii)PPP (iv) ISP
27 What is the difference between built‐in functions and modules?. 2
OR
Write definition of a Method MSEARCH(STATES) to display all the state names from a
list of STATES, which are starting with alphabet M.
For example: If the list STATES contains [“MP’,”UP”,”MH”,”DL”,”MZ”,”WB”] The
following should get displayed MP MH MZ
28 Rewrite the following code in python after removing all syntax error(s).Underline each 2
correction done in the code.
80=T
for i in range(0,T)
if i%2=0:
print(i*10)
Else:
print(i+5)
29 What possible outputs(s) are expected to be displayed on screen at the time of 2
execution of the program from the following code? Also specify the maximum values
that can be assigned to each of the variables Lower and Upper.
import random as r
val = 35
P=7
Num = 0
for i in range(1, 5):
Num = val + r.randint(0, P - 1)
print(Num, " $ ", end = "")
P=P-1
(a) 41 $ 38 $ 38 $ 37 $
(b) 38 $ 40 $ 37 $ 34 $
(c) 36 $ 35 $ 42 $ 37 $
(d) 40 $ 37 $ 39 $ 35 $
30 What is the difference between UNIQUE and PRIMARY KEY constraint. Give a suitable 2
example of both in a table containing some meaningful data..
31 2
Consider the following Python code is written to access the record of CODE
passed to function: Complete the missing statements:
def Search(eno):
#Assume basic setup import, connection and cursor is created
query="select * from emp where empno=________".format(eno)
mycursor.execute(query)
results = mycursor._________
print(results)
4|Page
32 Differentiate between alternate key and candidate key. 2
Write the output of following python code
def result(s):
33 n = len(s) 2
m=''
for i in range(0, n):
if (s[i] >= 'a' and s[i] <= 'm'):
m = m + s[i].upper()
elif (s[i] >= 'n' and s[i] <= 'z'):
m = m + s[i-1]
elif (s[i].isupper()):
m = m + s[i].lower()
else:
m = m + '#'
print(m)
result('Cricket'))
Section -II
34 Write a program to input any string and to find the number of words in the string.. 3
35 Write a function count_is_as() in Python that counts the number of “is” and “as” words 3
present in a text file “STORY.TXT”.
5|Page
36 3
Consider the following tables FACULTY and COURSES. Write SQL commands for the
statements (i) to (iii). FACULTY
F_ID Fname Lname Hire_date Salary
102 Amit Mishra 12-10-1998 12000
103 Nitin Vyas 24-12-1994 8000
104 Rakshit Soni 18-5-2001 14000
105 Rashmi Malhotra 11-9-2004 11000
COURSES
C_ID F_ID Cname Fees
C21 102 Grid Computing 40000
C22 103 System Design 16000
C23 104 Computer Security 8000
C24 103 Human Biology 15000
C25 102 Computer Network 20000
C26 105 Visual Basic 6000
i) Select F_ID, sum(Fees) from COURSES group by F_ID;
ii) Select Max(Salary), Min(Salary) from Faculty;
iii) Select Fname, Lname from FACULTY where Lname like =’M%’;
37 Write PushStk(Car) and PopStk(Car) functions in Python to add a new Car 3
and delete a Car from a list of Car specification, considering them to act as
push and pop operations of the Stack data structure
OR
Write a function in python named Drop_Data(d) where d is a stack
implemented by a list of numbers. The function will display the popped element
after function call.
Section- III
38 Smart Connectivity Association is planning to spread their office in four major cities in 5
India to provide regional IT infrastructure support in the field of Education & Culture. The
company has planned to setup their head office in New Delhi in three locations and have
named their New Delhi offices as “FRONT OFFICE”, “BACK OFFICE”, “WORK
OFFICE”. The company has three more regional offices namely “WEST OFFICE”,
“SOUTH OFFICE”, “EAST OFFICE” Located in other three major cities of India. A rough
layout of the same is as follow:
NEW DELHI
INDIA FRONT BACK
OFFICE
WEST
EAST
OFFICE SOUTH
OFFICE
OFFICE
6|Page
Back Office to Front Office - 10 KM Back Office ----- 100
Back Office to Work Office -70 mtr Front Office ----- 20
Back Office to East Office -1291 KM Work Office ----- 50
Back Office to West Office -790 KM East Office ----- 50
Back Office to South Office -952 KM West Office ----- 50
South Office ----- 50
(i)Suggest network type for connecting each of the following sets of their offices:
(a)Back Office and Work Office
(b) Back Office and South Office
(ii)Which device you will suggest to be produced by the company for connecting all the
computers within each of their offices out of the following devices?
a. Hub/Switch b. Modem c. Telephone
(iii)Which of the following communication medium, you will suggest to be produced by the
company for connecting their local offices in New Delhi for very effective and fast
communication.
a. Telephone cable b. Optical Fiber c. Ethernet Cable
(v) Suggest the type of networking between Back Office to West Office
LAN,MAN,WAN
39 Consider the following tables Shop and answer the following questions: 5
ICODE INAME SCODE QTY RATE BUYDATE
1005 Note Book 13 120 24 03-May-13
1003 Eraser 12 80 5 07-Aug-13
1002 Pencil 12 300 10 04-Mar-13
1006 Bag 11 70 300 27-Dec-12
1001 Pen 13 250 20 18-Jul-13
1004 Sharpener 12 100 10 23-Jun-13
1009 Box 11 50 80 17-Dec-12
Write SQL commands for the following statements:
(i) To display all the details of table shop in ascending order of Buydate.
(ii) To display ICODE and INAME from the table shop whose QTY is
more than 100.
(iii) To display all the details of the table shop whose SCODE is12 and rate
is more than 5
(iv) To display all the details from shop table whose INAME start with B.
(v) To display all the details whose QTY between 80 to 150.
7|Page
OR
8|Page
KENDRIYA VIDYALAYA SANGATHAN, RAIPUR REGION
SAMPLE PAPER -I
Class: XII
Subject: Computer Science (083)
MARKING SCHEME
MaximumMarks:70 Time Allowed: 3hours
Part – A
Section - I
1 a) 5Total 1
Reason: An identifier cannot start with a digit.
2 „RUPIAR‟ 1
3 File mode is used to tell that file object will read or write or both data in 1
a data file.
4 = 1
5 b) T[2] = -29 1
1
Part – A
Section - II
22 1
Answers:
1
(a) MedicineNo
1
(b) Degree= 4 Cardinality =7
1
(c) INSERT INTO medicalstore (MedicineNo, MedicineName, MedCode,Quantity)
VALUES(6647, “Dapsone”, 141,55); 1
(d) DROP TABLE medicalstore;
(e) DESCRIBE medicalstore
23 1
(a) csv.
1
(b) “r”?
1
(c) data = csv.reader(f)
1
(d) f.close()
1
(e) Comma Separated Values
Part – B
24 2
a) 6
b) True
25 SMTP: It is used to send emails. 2
POP3: It is used to receive emails.
1 mark for each correct difference.
OR
1. Firewall
2. User Authentication
.5 mark for any 2 correct answers.
2
a) IPR – Intellectual Property Rights
26 b) SIM – Subscriber‟s Identity Module
c) IMAP – Internet Message Access Protocol
d) HTTP – Hypertext transfer Protocol
2
27 In PYTHON, module is a file consisting of Python code. A module can define 2
functions, classes and variables. A module can also include runnable code.
Functions of Math Module:
ceil(x): Returns the smallest integer greater than or equal to x.
floor(x): Returns the largest integer less than or equal to x.
OR
Positional Arguments: Arguments that are required to be passed to the
function according to their position in the function header. If the sequence is
changed, the result will be changes and if number of arguments are
mismatched, error message will be shown.
Example:
def divi(a, b):
print (a / b)
>>> divi(10, 2)
5.0
>>> divi (20 / 10)
2.0
>>> divi (10)
Error
Default Argument: An argument that is assigned a value in the function
header itself during the function definition. When such function is called
without such argument, this assigned value is used as default value and
function does its processing with this value.
def divi(a, b = 1):
print (a / b)
>>> divi(10, 2)
2
5.0
>>> divi(10)
10.0
def callme(): 2
a= input("Enter a number:")
if (abs(a)== a):
print("You entered a positive number")
else:
a*=-2
print ("Number made positive:" ,a)
3
callme()
29 OUTPUT: (ii) 2
a. Minimum Number = 1
Maximum number = 3
b. Option (iv)
30 Domain of an attribute is the set of values from which a value may come in a 2
column. E.g. Domain of section field may be (A,B,C,D).
fetchall()fetches all the rows of a query result. An empty list is returned if there is no record to 2
31 fetch the cursor.
fetchone() method returns one row or a single record at a time. It will return None if no more
rows / records are available
32 WHERE clause is used to select particular rows that satisfy a condition whereas HAVING 2
clause is used in connection with the aggregate function, GROUP BY clause.
For ex. – select * from stu where marks > 90;
This statement shall display the records for all the students who have scored more than 90
marks.
On the contrary, the statement – select * from stu group by stream having marks > 90; 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 90.
33 hAPPY*nEW*yEAR***** 2
34 def Display (X, n): 3
for i in range(n):
if X[i] % 2 == 0:
X[i] /= 2
else:
X[i] *= 2
print (X)
35 def display (): 3
file = open("test.txt" , "r")
lines = file.readlines()
for l in lines:
if l[0]== "b" or l[0] == "B":
print(l)
file.close()
or
def count_word():
f = open("story.txt", "r")
count = 0
x = f.read()
word = x.split()
for i in word:
if i == "vidyalaya":
count = count + 1
print ("my occurs", count, "times")
4
36 3
(i) 43000
ii)
Max (DOB) Min(DOB)
08-10-1995 05-07-1993
37 def Push(STACK,SET):
for i in SET :
if i%2==0:
STACK.append(i)
OR
def POP(STACK):
if STACK==[] :
print(“Stack is empty”)
else:
print(STACK.pop())
LAYOUT
5
(iii) Switch or Hub
(V)
6
40 5
import pickle
record = []
while True:
rollno = int(input("Enter your rollno: "))
name = input("Enter your name: ")
marks = int(input("enter your marks obtained: "))
data = [rollno, name, marks]
record.append(data)
choice = input("Do you want to enter more records: ")
if choice.upper() == "N":
break;
f1 = open("E:\Student.dat", "wb")
pickle.dump(record, f1)
print ("Records added....")
f1.close()
OR
import pickle
f1 = open("E:\Student.dat", "rb")
Stud_rec = pickle.load(f1)
rno = int(input(“Enter the roll no to search: ”))
flag = 0
for r in Stud_rec:
if rno == r[0]:
print (rollno, name, marks)
flag = 1
if flag == 0:
print(“Record not found…”)
f1.close()
7
KENDRIYA VIDYALAYA SANGATHAN, RAIPUR REGION
SAMPLE PAPER -2
Class: XII
Subject: Computer Science (083)
MARKING SCHEME
MaximumMarks:70 Time Allowed: 3hours
Part – A
Section - I
4 b) < 1
5 3 1
1
Part – A
Section - II
22 1
Answers:
1
i.Degree-4 Cardinility-5
1
ii.AdmissionNo
1
iii.insert into student values(012368,’Kamlesh’,’Sharma’,’2004-01-01’)
1
iv.Delete command
v.Drop table student
(Any 04)
23 1
a) Name the module he should import in Line 1.
1
import csv
1
b) In which mode, Sanjay should open the file to add data into the file
1
a or a+
1
c) Fill in the blank in Line 3 to read the data from a csv file.
reader
d) Fill in the blank in Line 4 to close the file.
close()
a) Write the output he will obtain while executing Line 5.
Atul 1111111111”)
Arun 2222222222”)
Amit 3333333333”)
Part – B
24 2
a.40
b.True
25 Virus: 2
Virus is a computer program or software that connect itself to another software or computer
program to harm computer system. When the computer program runs attached with virus it
perform some action such as deleting a file from the computer system. Virus can‟t be
controlled by remote.
Trojan Horse:
Trojan Horse does not replicate itself like virus and worms. It is a hidden piece of code which
steal the important information of user. For example, Trojan horse software observe the e-mail
ID and password while entering in web browser for logging.
OR
Web Page is a document or a page where there is information. We can see those pages in the
browser. Web Page is a single page with information. It can be in any form like texts, images
or videos.
Whereas the Website is a collection of webpages. The website has its own domain name
which is unique throughout the world. Anything can be stored on a website like photos, videos,
texts etc .Popular example of online shopping : Amazon,Flipcart etc
2
2
½ Mark for each correct expansion
26 Internet Protocol.
Metropolitan Area Network
Network Interface Card
Unshielded Twisted pair
27 The continue statement is used to skip the rest of the code inside a loop for the current 2
iteration only. Loop does not terminate but continues on with the next iteration.
for val in "string":
if val == "i":
continue
print(val)
print("The end")
The break statement terminates the loop containing it. Control of the program flows to the
statement immediately after the body of the loop.
If the break statement is inside a nested loop (loop inside another loop), the break statement
will terminate the innermost loop.
for val in "string":
if val == "i":
break
print(val)
print("The end")
OR
A global variable is a variable that is accessible globally. A local variable is one that is only
accessible to the current scope, such as temporary variables used in a single function
definition.
q = "I love coffee" # global variable
def f():
p = "Me Tarzan, You Jane." # local variable
print p
f()
print q
Rewrite the following Python program after removing all the syntactical errors (if any), 2
underlining each correction:
def Data: # Data( )
w= input("Enter a number") # int(input(“Enter a number”))
if w % 2 =0: #w%2==0
3
print (w, "is even Value")
elseif w<0: # elif
print (w, "should be positive Value")
else; # else:
print (w, "is odd Value”)
29 Maximum value of FROM = 3 2
Maximum value of TO = 4
(ii) 30#40#50#
30 Constraints are the checking condition which we apply on table to ensure the 2
correctness of data . example primary key, nut null, default, unique etc
1 mark for definition. 1 mark for 2 examples.
import mysql.connector as mydb 2
31 conn= mydb.connect(host=”localhost”, user=”root”, passwd=”1234”)
cur=conn.cursor()
cur.execute(“INSERT INTO student values(5,‟Ashok‟,47);”)
cur.commit()
½ mark for import
½ for connection
½ for execute
½ for commit
32 ½ mark for each correct expansion 2
Data Definition Language, Data Manipulation Language
½ mark for each correct example
DDL: create,drop,alter
DML : insert,update,delete
33 15 # 5 2
5 # 10
25 # 5
34 3 marks for correct program, one possible code is below 3
L1= [1,1,2,3,5,8,13,21,34,55,89]
L2= [20,1,2,3,4,5,6,7,8,9,10,11,12,13]
L3=[]
temp_L1=list(set(L1))
temp_L2=list(set(L2))
for i in temp_L1:
for j in range(len(temp_L2)):
if i == temp_L2[j]:
L3.append(i)
#L3=temp_L1+temp_L2
L3=list(set(L3))
L3.sort()
print(L3)
4
35 def COUNT_AND( ): 3
count=0
file=open(„STORY.TXT','r')
line = file.read()
word = line.split()
for w in word:
if w in [„AND‟,‟and‟,‟And‟]:
count=count+1
file.close()
print(count)
(½ Mark for opening the file)
(½ Mark for reading word)
(½ Mark for checking condition)
(½ Mark for printing word)
OR
def DISPLAYWORDS( ):
count=0
file=open(„STORY.TXT','r')
line = file.read()
word = line.split()
for w in word:
if w[0]=="T" or w[0]=="t":
count=count+1
file.close()
print(count)
(½ Mark for opening the file)
(½ Mark for reading word)
(½ Mark for checking condition)
(½ Mark for printing word)
36 3
(i) 200000, 65000
(iii) 101 1
102 2
103 2
5
37 def PUSH(Arr):
s=[]
for x in range(0,len(Arr)):
if Arr[x]%5==0:
s.append(Arr[x])
if len(s)==0:
print("Empty Stack")
else:
print(s)
L=[5,10,15,20,3]
PUSH(L)
OR
if len(st)==0:
print("Underflow")
else:
L = len(st)
val=st[L-1]
print(val)
st.pop(L-1)
popStack(L)
½ marks for correct header
1½ marks for correct logic
½ mark for proper use of append or pop function
½ mark for correct output
38 Answers: 5
i. Suggest the most suitable place (i.e., Block/Center) to install the server of this
organization with a suitable reason.
Balod, Maximum Computers
ii. Suggest an ideal layout for connecting these blocks/centers for a wired
6
connectivity.
Any suitable layout
iii. Which device will you suggest to be placed/installed in each of these offices to
efficiently connect all the computers within these offices?
Switch
iv. Suggest the placement of a Repeater in the network with justification.
Raipur to Bilaspur Block if direct connection is there
v. The organization is planning to connect its new office in Delhi, which is more
than 1250 km current location. Which type of network out of LAN, MAN, or WAN
will be formed? Justify your answer.
WAN: spread over more than one city
7
40 A binary file named “EMP.dat” has some records of the structure 5
[EmpNo, EName, Post, Salary]
(a)Write a user-defined function named NewEmp() to input the details of a new employee
from the user and store it in EMP.dat.
(b) Write a user-defined function named SumSalary(Post) that will accept an argument the
post of employees & read the contents of EMP.dat and calculate the SUM of salary of all
employees of that Post.
Or
A binary file named “TEST.dat” has some records of the structure
[TestId, Subject, MaxMarks, ScoredMarks]
8
OR
9
KENDRIYA VIDYALAYA SANGATHAN, RAIPUR REGION
SAMPLE PAPER -3
Class: XII
Subject: Computer Science (083)
MARKING SCHEME
MaximumMarks:70 Time Allowed: 3hours
Part – A
Section - I
4 c) = < 1
5 wed 1
17 [25, 10] 1
18 >>Select * from Computerlab; 1
19 HTTP HyperText Transfer Protocol. 1
1|Page
20 The PRIMARY KEY constraint uniquely identifies each record in a table. Primary keys must 1
contain UNIQUE values, and cannot contain NULL values .
21 Switch/Hub and Repeaters. 1
Part – A
Section - II
22 1
Answers:
1
(i) Std_id
1
(ii) Create database Raipur
1
(iii) . Insert into Stu_Data Values (6,”Somesh”,”7th”,400,”Raigarh”)
1
(iv) Desc Stu_Data;
(v) Select * from Stu_Data where marks>450;
(Any 04)
23 1
a) import csv
1
b) newFileWriter.writerow([1,'xyz'])
1
c) newFileReader = csv.reader(newFile)
1
d) User_Id Beneficiary
1
1 xyz
e) newFile.close()
Part – B
24 2
a. 14
b. False
25 In packet switching, a fixed size of packet that can be transmitted across the network is 2
specified. All the packets are stored in the main memory instead of disk. As a result accessing
time of packets is reduced. While circuit switched networks are based on the direct connection
of two computers, with the connected computers making exclusive use of a single connecting
link.
Or
The two reasons for networking are:
2|Page
27 Actual parameters are those parameters which are used in function call statement and formal 2
parameters are those parameters which are used in function header (definition).
e.g.
def sum(a,b): # a and b are formal parameters
return a+b
x,y=5,10
res=sum(x,y) #x and y are actual parameters
or
Scope of variables refers to the part of the program where it is visible, i.e, the area where you
can use it
28 Rewrite the following Python program after removing all the syntactical errors (if any), 2
underlining each correction:
a=int(input("ENTER FIRST NUMBER"))
b=int(input("ENTER SECOND NUMBER"))
c=int(input("ENTER THIRD NUMBER"))
if a>b and a>c:
print("A IS GREATER")
if b>a and b>c:
print(" B IS GREATER")
if c>a and c>b:
print(" C IS GREATER ")
29 Correct output (ii) 11@14@18@ 2
Minimum = 11 Maximum = 19
( ½ mark each for minimum and maximum value)
(1 mark for correct option)
30 DDL command are used to create, alter and remove database schemas like table, index 2
etc. Example of DDL Commands are Create Table, Create Index, Drop Table, Alter
Table etc.
DML commands are used to retrieve, insert , delete and update the data of the table.
Example of DML commands are Select, Insert , Delete and Update Command. (1 mark
for each correct definition of DDL and DML)
The MySQLCursor of mysql-connector-python (and similar libraries) is used to execute 2
31 statements to communicate with the MySQL database.
Using the methods of it you can execute SQL statements, fetch data from the result sets, call
procedures.
You can create Cursor object using the cursor() method of the Connection object/class.
3|Page
32 2
Differences between CHAR and VARCHAR in MySQL −
35 def count_digit(): 3
f = open("data.txt")
content = f.read()
count = 0
for ch in content:
if ch in "0123456789":
count += 1
print(count)
f.close()
( ½ mark for opening, ½ mark for initializing and printing count, ½ mark for reading content
and using loop, ½ mark for checking condition)
OR
def count_word():
4|Page
f = open("poem.txt")
words = f.read().split()
count = 0
for word in words:
if word[0] in "sS":
count += 1
print(count)
f.close()
( ½ mark for opening, ½ mark for initializing and printing count, ½ mark for reading content
and using loop, ½ mark for checking condition)
36 3
Write SQL queries (i) to (iii) based on the relation
(i)
Sub Sum(Average)
Physics 195
Comp Sc 130
Chemistry 117
Math 195
(ii) Max(Stipend) Min(Stipend)
500 250
(iii) DIV Count(*)
I 8
II 2
37 def PUSH(stk,item)
stk.append(item)
top=len(stk)-1
print(stk)
Or
def POP(stk):
if stk==[]:
return "Underflow"
else:
item = stk.pop()
print(item)
½ marks for correct header
1½ marks for correct logic
5|Page
½ mark for proper use of append or pop function
½ mark for correct output
38 Answers: 5
(1) Raj
Fazz
Building
Building
Jazz
Harsh Building
Building
2) Most suitable place/building to house the server of this organization would be Raj building, as
this building contains the maximum number of computers, thus decreasing the cabling cost for
most of the computes as well as increasing the efficiency of the maximum computers in the
network.
3) (i) Repeater is not required as the distance between building is less than 100 mts.
(ii) Switch / Hub will be needed in all the buildings, to interconnect the computers in each
building.
5.Ethernet Cable
c) To display the firstname,lastname and total salary of all managers from the tables
Employee and empsalary , where total salary is calculated as salary+benefits.
d) To display Empid, Designation and Salary of all employee from EmpSalary table whose
benefits more than 14000.
>> Select Empid,Designation,Salary from EmpSalary where benefits>14000;
e)To display empid, First Name and city from employees table whose lastname start with s.
6|Page
40 import pickle 5
def Count():
fobj=open("EMPLOYEE.DAT","rb")
num = 0
try:
while True:
rec=pickle.load(fobj)
if rec[2] > 50000:
print(rec[0],rec[1],rec[2],sep="\t")
num = num + 1
except:
fobj.close()
return num
OR
import pickle
def search():
f=open(“emp.dat”,”rb”)
while True:
try:
d=pickle.load(f)
if(d[„sal‟]>=25000 and d[„sal‟]<=30000):
print(d)
except EOFError:
breakf.close()½ mark for
7|Page
KENDRIYA VIDYALAYA SANGATHAN, RAIPUR REGION
SAMPLE PAPER -4
Class: XII
Subject: Computer Science (083)
Maximum Marks:70 Time Allowed: 3hours
__________________________________________________________________________________
_
General Instructions:
1. This question paper contains two parts A and B. Each part is compulsory.
2. Both Part A and Part B have choices.
3. Part-A has 2sections:
a. Section – I is short answer questions, to be answered in one word or one line.
b. Section – II has two case studies questions. Each case study has 4 case-based sub-
parts. An examinee is to attempt any 4 out of the 5 subparts.
4. Part - B is Descriptive Paper.
5. Part- B has three sections
a. Section-I is short answer questions of 2 marks each in which two question have
internal options.
b. Section-II is long answer questions of 3 marks each in which two questions have
internal options.
c. Section-III is very long answer questions of 5 marks each in which one question has
internal option.
6. All programming questions are to be answered using Python Language only
Q.NO Section-I Marks
Select the most appropriate option out of the options given for each question. Attempt allocated
any 15 questions from question no 1 to 21.
1 Which of the following is / are valid identifier/s in Python: 1
3 ……………………is a process of storing data into files and allows to performs various 1
tasks such as read, write, append, search and modify in files.
4 What is the output of the following code : 1
>>> print(9//2)
(A) 4.5
(B) 4.0
(C) 4
(D) Error
5 What is the result of code shown below? 1
tuple1 = (10, 20)
tuple2 = (30, 40)
tuple1, tuple2 = tuple2, tuple1
print(tuple2)
1
print(tuple1)
6 Write a statement in Python to declare a dictionary whose keys are 1
Mon,Tues,Wed,Thur,Fri,Sat and values are “CS”,”Phy”,”Chem”,”Maths” “Eng” and
“Hindi” respectively
7 A tuple is declared as T = (10,20), (10,20,40), (50,30) 1
What will be the value of min(T) ?
8 What are the built-in types of python?. 1
9 A ……………… is a device that works like a bridge but can handle different protocols 1
10 Posing as someone else online and using his/her personal/financial information shopping or 1
posting something is a common type of cyber-crime these days. What are such types of
cyber-crimes collectively called?
11 What is the purpose of using references word in terms of DBMS/RDBMS? 1
12 Which clause of select command is used to group the rows on the basis of common values 1
in a column?
13 Which of the following is/are built in aggregate function in SQL? 1
a) sum
b) min
c)count
d) All
14 Sourabh wants to remove all rows from the table ACCT. But he needs to maintain the 1
structure of the table. Which command is used to implement the same?
15 Write one characteristic each for 2G and 3G mobile technologies. 1
16 What will be the output of the following Python code? 1
S= “Hello Friends”
print S[:-4]
print S[-4:]
17 How many times is the following loop executed? 1
i = 100
while (i<=200):
print i
i + =20
18 While creating table „customer‟, Maneesha forgot to add column „price‟. Which command 1
is used to add new column in the table. Write the command to implement the same.
19 Write two characterstics of Wi-Fi.. 1
20 What is relation? Define the relational data model. 1
21 Identify the Domain name and URL from the following: 1
http://www.income.in/home.aboutus.hml.
Section-II
Both the Case study based questions are compulsory. Attempt any 4 sub parts from
each question. Each question carries 1 mark
22 As a database administrator, answer any 4 of the following questions:
Name of the table : S_DRINK
The attributes are as follows:
Drinkcode, Calories – Integer
Price - Decimal
Dname - Varchar of size 20
2
Drinkcode Dname Price Calories
import #Line 1
f = open(“Games.csv”,”a”)
wobj = csv. (f, delimiter = ‘\t’) # Line 2
3
a) Name the module he should import in Line 1 1
b) To create an object to enable to write in the csv file in Line 2 1
c) To create a sequence of user data in Line 3 1
d) To write a record onto the writer object in Line 4 1
e) Fill in the blank in Line 5 to close the file. 1
Part B
Section-I
24 2
Evaluate the following expressions:
a) (2**2)*(3**3)//(2**4)
b) 2>1 and 1<0 and not 4>2
25 What is the function of Modem? 2
OR
In networking, what is WAN? How is it different from LAN?.
26 2
Expand the following terms:
(a) WLL (b) 5G (c) POP3 (d) Gbps
27 Which string method is used to implement the following: 2
function double(x):
return 2*x
I =int(input())
N = double (I)
if N= 100:
print(“Input is equal to 50”)
else:
print(“Double of the Number”+ I + “is” + N)
29 What are the possible outcome(s) expected from the following python code? Also specify 2
the maximum and minimum values that can be assigned to variable .
import random
def Show():
p = "MY PROGRAM"
i=0
while p[i] != "R":
l = random.randint(0,3) + 5
print(p[l],"-")
i += 1
Show()
(i) R – P – O – R – (ii) P – O – R – Y –
4
(iii) O – R – A – G – (iv) A– G – R – M –
But the query is’nt producing the result. Identify the problem.
Find and write the output of the following python code:
def Find():
33 L = "computer" 2
x=""
count = 1
for i in L:
if i in ['a', 'e',' i', 'o', 'u']:
x=x+i
else:
if (count%2!= 0):
x = x + str(len(L[:count]))
else:
x=x+i
count = count + 1
print(x)
Find()
5
36 Write output for queries (i) to(iii), which are based on the table : 3
Books.
Publishe
Book_id Book_name Author_name r Price Qty
William
F0001 The Tears hopkin NIL 650 20
Brain&
T0001 My First Py Brooke EPB 350 10
A.W.
T0002 Brain works Rossaine TDH 450 15
Thunderbolt
F0002 s Anna Roberts NIL 750 5
JUNIOR
SENIOR
ADMIN HOSTEL
6
Distance between various wings are given below:
1. Suggest the best wired medium and draw the cable layout to efficiently connect various
wings of Happy Home Public School, RAIPUR.
2. Name the most suitable wing where the Server should be installed. Justify
your answer.
3. Suggest a device/software and its placement that would provide data security for the
entire network of the School
4. Suggest a device and the protocol that shall be needed to provide wireless Internet access
to all smartphone/laptop users in the campus of Happy Home Public School,
RAIPUR
5. Suggest the placement of the Hub/Switch device with justification.
39 Write SQL command for (i) to (v) on the basis of the table Trainer & Course 5
Trainer
TID TNAME CITY HIREDATE SALARY
101 SUNANA MUMBAI 1998-10-15 90000
102 ANAMIKA DELHI 1994-12-24 80000
103 DEEPTI CHANDIGARG 2001-12-21 82000
104 MEENAKSHI DELHI 2002-12-25 78000
105 RICHA MUMBAI 1996-01-12 95000
106 MANIPRABHA CHENNAI 2001-12-12 69000
7
Course
a. Display the Trainer Name, City & Salary in descending order of their Hiredate.
b. To display the TNAME and CITY of Trainer who joined the Institute in the month of
December 2001.
c. To display TNAME, HIREDATE, CNAME, STARTDATE from tables TRAINER and
COURSE of all those courses whose FEES is less than or equal to 10000
d. To display number of Trainers from each city.
e. To Display the TID, TNAME and SALARY whose TNAME starts with „M‟.
40 Given a binary file “record.dat” has structure (Emp_id, Emp_name, Emp_Salary). Write 5
a function in Python Rec_count() in Python that would read contents of the file
“record.dat” and display the details of those employee whose salary is less than 20000
OR
(i)Write a function in Python add_record() to input data for a record and add to Stu.dat.
8
KENDRIYA VIDYALAYA SANGATHAN, RAIPUR REGION
SAMPLE PAPER -5
Class: XII
Subject: Computer Science (083)
Maximum Marks:70 Time Allowed: 3hours
__________________________________________________________________________________
_
General Instructions:
1. This question paper contains two parts A and B. Each part is compulsory.
2. Both Part A and Part B have choices.
3. Part-A has 2sections:
a. Section – I is short answer questions, to be answered in one word or one line.
b. Section – II has two case studies questions. Each case study has 4 case-based sub-
parts. An examinee is to attempt any 4 out of the 5 subparts.
4. Part - B is Descriptive Paper.
5. Part- B has three sections
a. Section-I is short answer questions of 2 marks each in which two question have
internal options.
b. Section-II is long answer questions of 3 marks each in which two questions have
internal options.
c. Section-III is very long answer questions of 5 marks each in which one question has
internal option.
6. All programming questions are to be answered using Python Language only
Q.NO Section-I Marks
Select the most appropriate option out of the options given for each question. Attempt allocated
any 15 questions from question no 1 to 21.
1 Out of the following, find those identifiers, which cannot be used for naming Variables 1
or functions in a Python program:
Total * Tax, While, class, Switch, 3rd Row, finally, Column 31, Total
2 What is the output when following code is executed? 1
3 A ___________ is plain text file which contains list of data in tabular form. 1
4 Which of the following is/are valid Membership Operators in Python? 1
a) ? b) < c) not in d) and e) in
5 What will be the output of the following Python code? 1
>>>my_tuple = (1, 2, 3, 4)
>>>my_tuple.append( (5, 6, 7) )
>>>print len(my_tuple)
a) 1
b) 2
c) 5
d) Error
1|Page
6 Given is the following Dictionary dict={1:’A’,2:’B’,3:’C’,6:’D’,4:’E’} ? What is the output 1
of the command print(dict[6])
7 Which of the options out of (i) to (iv) the correct data type for the variable lst is as 1
defined in the following Python statement?
lst = ('A', 'E', 'I', 'O', 'U')
(i) List
(ii) Dictionary
(iii) Tuple
(iv) Array
8 Name the Python Library modules which need to be imported to invoke the following 1
functions :
1. sin() 2. ceil()
9 What is MAC Address? 1
10 Credit card frauds, phishing, cyber bullying, spamming are kind of ………….crime 1
11 Which keyword eliminates redundant data from a query result? 1
12 What are alternate keys? 1
13 What is the use of UNIQUE constraint in MYSQL? 1
14 Which command is used to delete a table schema 1
i) Delete
ii) Drop
iii) Del
iv) Remove
15 What is Baud rate? 1
16 Write the output of the following code of python: 1
A={10:1000,20:2000,30:3000,40:4000,50:5000}
print A.keys()
print A.values()
18 Which is the table constraint used to stop null values to be entered in the field 1
(i) Unique
(ii) Not NULL
(iii) Not Empty
(iv) None
19 Name the media preferably used in the Internet Backbone of Country 1
20 In SQL, write the query to display the list of database in the server. 1
21 10:B4:03:56:2E:DF is an example of ………………………. 1
Section-II
Both the Case study based questions are compulsory. Attempt any 4 sub parts from
each question. Each question carries 1 mark
22 A Ramco Book Shop is considering to maintain their inventory using SQL to store the
data. As a database administer, Neelmadhav has decided that:
• Name of the database -Ramco
• Name of the table -shop
• The attributes of shop are as:
2|Page
ICODE,SCODE,QTY,RATE - numeric
INAME– character of size 25
BUYDATE -date
ICODE INAME SCODE QTY RATE BUYDATE
1005 Note Book 13 120 24 03-May-13
1003 Eraser 12 80 5 07-Aug-13
1002 Pencil 12 300 10 04-Mar-13
1006 Bag 11 70 300 27-Dec-12
1001 Pen 13 250 20 18-Jul-13
1004 Sharpener 12 100 10 23-Jun-13
1009 Box 11 50 80 17-Dec-12
3|Page
Part B
Section-I
24 Evaluate the following expressions: 2
a) 10*1 * 2**4 - 4// 4
b) 1> -1 and 15 < 12 or not 2 > 1
25 Explain LAN, WAN and MAN with examples. 2
OR
Differentiate between Internet and Intranet.
26 Write the full form of the following: 2
(i) LED (ii) Modem ( iii)PPP (iv) ISP
27 What is the difference between built‐in functions and modules?. 2
OR
Write definition of a Method MSEARCH(STATES) to display all the state names from a
list of STATES, which are starting with alphabet M.
For example: If the list STATES contains [“MP’,”UP”,”MH”,”DL”,”MZ”,”WB”] The
following should get displayed MP MH MZ
28 Rewrite the following code in python after removing all syntax error(s).Underline each 2
correction done in the code.
80=T
for i in range(0,T)
if i%2=0:
print(i*10)
Else:
print(i+5)
29 What possible outputs(s) are expected to be displayed on screen at the time of 2
execution of the program from the following code? Also specify the maximum values
that can be assigned to each of the variables Lower and Upper.
import random as r
val = 35
P=7
Num = 0
for i in range(1, 5):
Num = val + r.randint(0, P - 1)
print(Num, " $ ", end = "")
P=P-1
(a) 41 $ 38 $ 38 $ 37 $
(b) 38 $ 40 $ 37 $ 34 $
(c) 36 $ 35 $ 42 $ 37 $
(d) 40 $ 37 $ 39 $ 35 $
30 What is the difference between UNIQUE and PRIMARY KEY constraint. Give a suitable 2
example of both in a table containing some meaningful data..
31 2
Consider the following Python code is written to access the record of CODE
passed to function: Complete the missing statements:
def Search(eno):
#Assume basic setup import, connection and cursor is created
query="select * from emp where empno=________".format(eno)
mycursor.execute(query)
results = mycursor._________
print(results)
4|Page
32 Differentiate between alternate key and candidate key. 2
Write the output of following python code
def result(s):
33 n = len(s) 2
m=''
for i in range(0, n):
if (s[i] >= 'a' and s[i] <= 'm'):
m = m + s[i].upper()
elif (s[i] >= 'n' and s[i] <= 'z'):
m = m + s[i-1]
elif (s[i].isupper()):
m = m + s[i].lower()
else:
m = m + '#'
print(m)
result('Cricket'))
Section -II
34 Write a program to input any string and to find the number of words in the string.. 3
35 Write a function count_is_as() in Python that counts the number of “is” and “as” words 3
present in a text file “STORY.TXT”.
5|Page
36 3
Consider the following tables FACULTY and COURSES. Write SQL commands for the
statements (i) to (iii). FACULTY
F_ID Fname Lname Hire_date Salary
102 Amit Mishra 12-10-1998 12000
103 Nitin Vyas 24-12-1994 8000
104 Rakshit Soni 18-5-2001 14000
105 Rashmi Malhotra 11-9-2004 11000
COURSES
C_ID F_ID Cname Fees
C21 102 Grid Computing 40000
C22 103 System Design 16000
C23 104 Computer Security 8000
C24 103 Human Biology 15000
C25 102 Computer Network 20000
C26 105 Visual Basic 6000
i) Select F_ID, sum(Fees) from COURSES group by F_ID;
ii) Select Max(Salary), Min(Salary) from Faculty;
iii) Select Fname, Lname from FACULTY where Lname like =’M%’;
37 Write PushStk(Car) and PopStk(Car) functions in Python to add a new Car 3
and delete a Car from a list of Car specification, considering them to act as
push and pop operations of the Stack data structure
OR
Write a function in python named Drop_Data(d) where d is a stack
implemented by a list of numbers. The function will display the popped element
after function call.
Section- III
38 Smart Connectivity Association is planning to spread their office in four major cities in 5
India to provide regional IT infrastructure support in the field of Education & Culture. The
company has planned to setup their head office in New Delhi in three locations and have
named their New Delhi offices as “FRONT OFFICE”, “BACK OFFICE”, “WORK
OFFICE”. The company has three more regional offices namely “WEST OFFICE”,
“SOUTH OFFICE”, “EAST OFFICE” Located in other three major cities of India. A rough
layout of the same is as follow:
NEW DELHI
INDIA FRONT BACK
OFFICE
WEST
EAST
OFFICE SOUTH
OFFICE
OFFICE
6|Page
Back Office to Front Office - 10 KM Back Office ----- 100
Back Office to Work Office -70 mtr Front Office ----- 20
Back Office to East Office -1291 KM Work Office ----- 50
Back Office to West Office -790 KM East Office ----- 50
Back Office to South Office -952 KM West Office ----- 50
South Office ----- 50
(i)Suggest network type for connecting each of the following sets of their offices:
(a)Back Office and Work Office
(b) Back Office and South Office
(ii)Which device you will suggest to be produced by the company for connecting all the
computers within each of their offices out of the following devices?
a. Hub/Switch b. Modem c. Telephone
(iii)Which of the following communication medium, you will suggest to be produced by the
company for connecting their local offices in New Delhi for very effective and fast
communication.
a. Telephone cable b. Optical Fiber c. Ethernet Cable
(v) Suggest the type of networking between Back Office to West Office
LAN,MAN,WAN
39 Consider the following tables Shop and answer the following questions: 5
ICODE INAME SCODE QTY RATE BUYDATE
1005 Note Book 13 120 24 03-May-13
1003 Eraser 12 80 5 07-Aug-13
1002 Pencil 12 300 10 04-Mar-13
1006 Bag 11 70 300 27-Dec-12
1001 Pen 13 250 20 18-Jul-13
1004 Sharpener 12 100 10 23-Jun-13
1009 Box 11 50 80 17-Dec-12
Write SQL commands for the following statements:
(i) To display all the details of table shop in ascending order of Buydate.
(ii) To display ICODE and INAME from the table shop whose QTY is
more than 100.
(iii) To display all the details of the table shop whose SCODE is12 and rate
is more than 5
(iv) To display all the details from shop table whose INAME start with B.
(v) To display all the details whose QTY between 80 to 150.
7|Page
OR
8|Page