Computer Science_sr Centum Work Sheet
Computer Science_sr Centum Work Sheet
Computer Science_sr Centum Work Sheet
SECTION-A
I. Answer the following questions 1x6=6
1. Which of the following is an invalid variable?
a) to_day_3 b) 2nd_day c) Day_four d) _2
2. Which of these is not a core data type?
a) Lists b) Dictionary c) Tuples d) Class
3. What will be the value of the expression 14+13%15
a) 15 b) 27 c) 12 d) 1
4. Which value type does input () return?
a) Boolean b) String c) Int d) Float
Directions: In the following questions, two statements are given- one labelled Assertion (A) and the
other labelled Reason (R). Select the correct answer to these questions from the codes (a), (b), (c) and
(d) as given below.
a) Both Assertion and Reason are true and Reason is the correct explanation of Assertion.
b) Both Assertion and Reason are true but reason is not the correct explanation of Assertion.
c) Assertion is true but Reason is false.
d) Assertion is false but Reason is true.
SECTION-A
I. Answer the following questions 1x6=6
1. The numbered position of a letter in a string is called
a) Position b) Integer position c) Index d) Location
2. The keys of a dictionary must be of ______ type
a) Integer b) Mutable c) Immutable d) Any of these
a) Print T 1
b) T 2 29
c) Print max T d) Print len T
4. What is the output of this code?
>>> int (“3” + “4”)
a) “7” b) “34” c) 34 d) 24
Directions: In the following questions, two statements are given- one labelled Assertion (A) and the
other labelled Reason (R). Select the correct answer to these questions from the codes (a), (b), (c) and
(d) as given below.
a) Both Assertion and Reason are true and Reason is the correct explanation of Assertion.
b) Both Assertion and Reason are true but reason is not the correct explanation of Assertion.
c) Assertion is true but Reason is false.
d) Assertion is false but Reason is true.
5. Consider the following dictionary
Chandrayan = 11:12,12:13,13:14,14:15
SECTION-B
II. Answer the following questions 2x2=4
7. What is indexing in Python string? Why is it also two – way indexing.
8. How are tuples different from lists when both are sequence.
(OR)
What is the output produced by the following code snippet?
Lst = [ 1, 2, 3, 4, 5, 6, 7, 8, 9]
Lst[: :2] = 10, 2, 30, 40, 50, 60
Print (Lst)
SECTION-C
III. Answer the following questions 3x2=6
9. What will be the output produced by following code fragments?
a) y str 123
x "hello" *3
Print x, y
Print y, x
b) x "hello" \
"to python " \
" world "
For char in x :
y char
Print y,': ', end " "
10. Predict the output of the following code snippet?
a) arr 1,2,3,4,5,6
for i in range 1,6 :
arr i 1 arr i
for I in range 0,6 :
print arr i , end " "
b) Numbers = 9,18,27,36
for Num in Numbers:
for N in range 1, Num%8 :
print
(OR)
Explain the characteristics of Dictionary
SECTION-D
IV. Answer the following questions 5x1=5
11. Explain any five dictionary functions and methods.
(OR)
Write a program to sort a list using Bubble sort.
SECTION-E
V. Answer the following 4x1=4
12. a) What is a string? 1M
b) What is traversing a string? 1M
c) What is appending and updating element to a list? 2M
(OR)
c) Name the function/method required to 2M
a) Check if a string contains only upper case letters.
b) Gives the total length of the list.
.
Section –A
Q PAR Mar
QUESTION
. T. ks
S
N NO
O
a. sub program
b. functions
c. class
>>>print(20/4 *5+8-10)
a. 1
b. 23
c. 23.0
d. 24
4 Which of the following data types in Python supports concatenation? 1
d1={1:2,3:4,5:6}
d2=d1.popitem()
print(d2)
(a) state [-5:] (b) state [4:] (c) state [:4] (d) state [:-4]
7 Which of the following data type in python is used to represent any real number : 1
8 Suppose a tuple Tup is declared as Tup = (12, 15, 63, 80) which of the following is 1
incorrect?
a. 0 b. 1 c. 2 d. 3
1 Which of the following commands is used to open a file “c:\test.txt” for reading and 1
2 writing data in binary format only.
res = calculate(7, 7)
print(res)
a. (14,0) b. [14, 0] c. 14 d. 0
for n in range(2,5,2):
print(random.randrange(1,n,end=’*’)
(a)1*3 (b) 2*3 (c) 1*3*4 (d)1*4
1 Assertion(A) : The tell method will stores/get the current location of the file pointer 1
7
Reasoning(R): Python seek method returns the current position of the file read/write
pointer with the file.
1 Assertion: The function header ‘def read (a=2, b=5, c):’ is not correct. 1
8
Reason: Non default arguments can’t follow default arguments.
Please choose the correct choice out of the four options given below:
a. Both Assertion and reason are true and reason is the correct explanation of
assertion.
b. Assertion and reason both are true but reason is not the correct explanation of
assertion.
Section –B
dict['address'] = "Chennai"
print(dict.items())
2 Predict the output of the Python code given below: 2
0
tuple1 = (7, 14, 21, 28, 35, 42)
list1 =list(tuple1)
listNew = []
if item %2==0:
listNew.append(item)
tupleNew = tuple(listNew)
print(tupleNew)
def sum(r,s=5):
p=r+s
q=[r,s]
print(p, q, sep='@')
sum(3,4)
print(p, q, sep='@')
for i in T2:
if i in 'aeiou':
j=T1.index(i)
new_list+=[j]
print(new_list)
2 Write a function line count() in python which reads a file ‘data.txt’ and counts the 2
3 number of lines starting with character ‘P’.
2 Write any two differences between text file and binary file? 2
4
Section – C
Each question carries 3 marks
while N1:
a=N1.pop()
if a%5>2:
print(a,end='@')
else:
break
NUM=[13,24,12,53,34]
Alpha(NUM),print(NUM)
2 Kohit has written a code to input a number and find a new number Reverse from 3
7 Number with each of the digits of Number in reversed order and display.
Def REVERSE(Number):
S=0
while Number>0:
S=S*10+Number/10
Number=Number//10
print(S)
D={'month':"DECEMBER",'exam':'[PREBOARD1'}
D['month']='JANUARY'
D['EXAM']='PRE2'
print(D.items())
def fun(L):
for i in range(len(L)):
L[i]=L[i]+1
return(L)
k=fun(L)
print(k)
3 write a function countmy() in python to read the text file "DATA.TXT" and count the 3
0 number of times "my" occurs in the file.
OR
Write a function countVowels() in Python, which should read each character of a text
file “myfile.txt”, count the number of vowels and display the count. Example: If the
contents are as follows:
Section –D
ii. Write a function Economic() in Python that would read contents of the file
“ITEMS.DAT” and display the details of those ITEMS whose cost is greater than 2500.
def sum(q,r=2):
global p
p=r-q*2
print(p, end='#')
a=20
b=10
sum(a,b)
sum(r=15,q=10)
(b) Write a function in python to count the number of lowercase and uppercase
characters in a text file “Story.txt”.
3 (a) Predict the output of the Python code given below: 2+3
3
def Display(str):
m=" "
if(str[i].isupper()):
m=m+str[i].lower()
elif str[i].islower():
m=m+str[i].upper()
elif i%2==0:
m=m+str[i-1]
else:
m=m+"#"
print(m)
Display('Welcome@Python3.0')
(b) Consider the code given below and fill in the blanks.
try:
quotient=(num1/num2)
else:
Section –E
L=[]
if 'o' in v:
L.append(k)
print(L)
T = (9,18,27,36,45,54)
L=list(T)
L1 = []
for i in L:
if i%6==0:
L1.append(i)
T1 = tuple(L1)
print(T1)
3 (a) Swetha is learning Python and working with Binary Files. Her teacher has given her the 4
5 following incomplete, which is creating a binary file “Student.dat” which contains
student’s details (RNo, Name and Marks) in the form of List.She now has to open the
file, search for the Roll No., which will be entered by the user and display the Student’s
Details, if roll no. found otherwise print the message “Roll Number Not Found”.
As a Python programmer, help her to complete the following code based on the
requirement given below:
def ReadData():
rec=[]
fin.open(________________________) # Statement 2
found=False
while True:
try:
rec=__________________ # Statement 3
if ______________ : # Statement 4
found=True
print(“Student Name=”,rec[1])
except:
if found==False:
fin.close()
(ii) Write the correct statement to open the file Student.dat in the required mode.
(Statement 2)
(iii) Write the correct statement to read the data from the binary file and store it in rec.
(Statement 3)
(iv) Write the correct condition to match the Roll no of the student in the file with the
Roll no. entered by the user.
SECTION – A
I. Choose the correct answer (5*1=5)
1. The separator character of CSV files is called________.
(a) reader (b) writer (c) delimiter (d) newline
2. In CSV file ________ method is used to write a multiple rows of data.
(a) write() (b) writerow() (c) writerows() (d) writer()
3. In a stack, all insertions take place at _______ end(s)
(a) rear (b) front (c) top (d) any
4. WAN stands for______.
(a) World Area Network (b) Wise Area Network
(c ) Wide Area Network (d) Wireless Area Network
5. Central computer which is powerful than other computers in the network is called________.
(a) client (b) server (c) hub (d) switch
SECTION – B
II. Answer the following questions. (5*2=10)
6. What are CSV files? What does CSV.writer object do?
7. Write a program to count the number of records present in “data.csv” file.
8. Write a functions in python for pushS(List) and for popS(List) for performing Push and Pop
Operations with a stack of list containing integers.
9. Enlist the applications of a stack.
10. Explain the types of networks based on geographical scope.
SECTION – C
III. Answer the following questions. (Answer any 2 questions) (2*3=6)
11. Observe the following code and fill in the given blanks. (The file name is “data.csv”)
import csv
with open(“data.csv”) as f:
r = csv.______(f) # statement 1
for row in ______: # statement 2
print(_____) # statement 3
12. Write the difference between Circuit switching and Packet switching.
13. Write a function in python, MakePush(package) and MakePop(package) to add a new package
And delete a package from a list of package description, Considering them to act as push and pop
Operations of the stack data structure.
SECTION – D
IV. Case based study question. (1*4=4)
14. Software development company has set up its new centre at rajpur for its office and web based activities. It
has 4 blocks of buildings named Block A, Block B, Block C, Block D.
Number of computers Shortest distance between various blocks in metres
BLOCKA 25 BLOCK A to BLOCK B 60m
BLOCK B 50 BLOCK B to BLOCK C 40m
BLOCK C 125 BLOCK C to BLOCK A 30m
BLOCK D 10 BLOCK D to BLOCK C 50m
(i)Suggest the most suitable place (i.e block) to house the server of this company with a
Suitable reason.
(ii) Suggest the type of network to connect all the blocks with suitable reason.
(iii) The company is planning to link all the blocks through a secure and high speed wired medium.
Suggest a way to connect all the blocks.
(iv) Suggest the most suitable wired medium for efficiently connecting each computer installed in
Every block out of the following network cables:
(a) Coaxial cable (b) Ethernet cable (c) single pair telephone cable.
SECTION – E
V. Answer the following questions. (Answer any 2 questions) (2*5=10)
15. Write a program to create a CSV file to store student data (Roll no, Name, Marks). Obtain data from
User and write 5 records into the file.
16. Write a python program that defines and calls the following user defined functions.
(a) add() to accept and add data of an employee to a CSV file ‘furdata .csv’. Each record consists
Of a list with field elements as fid, fname and fprice to store furniture id, furniture name and
furniture price respectively.
(b) Search() to display the records of the furniture whose price is more than 10000.
17. Explain the different types of switching techniques with a diagram.
*******
I. Choose the correct answer (8 × 1= 8)
1. The separator character of CSV files is called________.
(a) reader (b) writer (c) delimiter (d) newline
2. In CSV file ________ method is used to write a multiple rows of data.
(a) write() (b) writerow() (c) writerows() (d) writer()
3. In a stack, all deletion take place at _______ end(s)
(a) rear (b) front (c) top (d) any
4. LAN stands for______.
(a) Local Area Network (b) Line Area Network (c ) Land Area Network (d) Low Area Network
5. Central computer which is powerful than other computers in the network is called________.
(a) client (b) server (c) hub (d) switch
6. Which transmission media is capable of having a much higher bandwidth?
(a) coaxial (b) twisted cable (c) untwisted cable (d) fiber optic
7. A combination of bus and star topologies is called a _____ topology.
(a) combination (b) Hybrid (c) busstar (d) Tree
8. Which of the following is the odd one out? FTP, HTTP, IMAP, HTTPS
(a) IMAP (b) FTP (c) HTTPS (d) HTTP
a) f.read()
b) f.readlines()
c) f.read(n)
d) f.readlines()
2. Puru wants to close a file after reading operation for the file object f. Suggest the correct
function to him.
a) f.close()
b) f.close
c) f.quit()
d) f.exit()
3. Network in which every computer is capable of playing the role of a client, or a server or both at
same time is called
a) peer-to-peer network
b) local area network
c) dedicated server network
d) wide area network
SECTION-B
7 . Write a query that selects all orders (Order table) except those with zeros or NULLS in the
amt field.
Table : placement
SECTION –D
1×4=4 M
Block Distance
No. of computer:
App Development 75
Web Designing 50
Movie Editing 80
(i) Suggest the most appropriate block/location to house the SERVER in the Kashipur campus (out
of the 3 blocks) to get the best and effective connectivity. Justify your answer.
(ii) Suggest a device/software to be installed in the Kashipur Campus to take care of data security.
(iii) Suggest the best wired medium and draw the cable layout (Block to Block) to economically
connect various blocks within the Kashipur Campus.
(iv) Suggest the placement of the following devices with appropriate reasons:
a. Switch / Hub
b. Repeater
SECTION –E
Result is result of the game whose value can be either 'Won', 'Lost' or 'Tie'
For efficiently maintaining data of the event, Vedansh wants to write the
following user defined functions:
Accept()–to accept a record from the user and add it to the file
csv file.
wonCount()–to count the number of students who have won any
event.
As a Python expert, help him complete the task.
16. Explain the different types of switching techniques with a diagram.