[go: up one dir, main page]

0% found this document useful (0 votes)
38 views10 pages

Set 4-MS

Uploaded by

akilasathish79
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views10 pages

Set 4-MS

Uploaded by

akilasathish79
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

FULL PORTION EXAMINATION – IV

(2024- 25)
Class : XII Total Mark : 70
Subject : Computer Science Subject Code : 083
Duration : 3 Hrs

General Instructions:
Please check this question paper contains 37 questions.
The paper is divided into 5 Sections- A, B, C, D and E.
Section A, consists of 21 questions (1 to 21). Each question carries 1 Mark.
Section B, consists of 7 questions (22 to 28). Each question carries 2 Marks.
Section C, consists of 3 questions (29 to 31). Each question carries 3 Marks.
Section D, consists of 4 questions (32 to 35). Each question carries 4 Marks.
Section E, consists of 2 questions (36 to 37). Each question carries 5 Marks.
Section-A (21 x 1 = 21 Marks)
1 State True or False: The Python statement print(„Alpha‟ * “Beta” ) is example of TypeError Error 1
2 What will be the output of the following code? 1
D1={1: “One”,2: “Two”, 3: “C”}
D2={4: “Four”,5: “Five”}
D1.update(D2)
print (D1)
(A) {4:‟Four‟,5: „Five‟} (B) Method update() doesn‟t exist for dictionary
(C) {1: “One”,2: “Two”, 3: “C”} (D) {1: “One”,2: “Two”, 3: “C”,4: „Four‟,5: „Five‟}
3 Predict the output of following python code. 1
SS="PYTHON"
print( SS[:4:])
(A) THON (B) PYT(C) PYTH(D) HON
4 A Python List is declared as 1
Stud_Name = ['Aditya', 'aman', 'Aditi','abhay']
What will be the value of max(Stud_Name)?
(A) abhay(B) Aditya (C) Aditi(D) aman
5 The SELECT statement when combined with ………….clause,return records without repletion. 1
(A) NULL(B)UNIQUE(C)ALL(D) DISTINCT
6 Given the following dictionary 1
Day={1:"Monday", 2: "Tuesday", 3: "Wednesday"}
Which statement will return "Tuesday".
(A) Day.pop() (B) Day.pop(2) (C) Day.pop(1) (D) Day.pop("Tuesday")
7 Consider the given expression : 1
7<4 or 6>3 and not 10==10 or 17>4
Which of the following will be the correct output if the given expression is evaluated ?
(A) True (B) False (C) NONE (D) NULL
8 Select the correct output of the code : 1
S="Amrit Mahotsav @ 75"
A=S.split(" ",1)
print(A)
(A) ('Amrit', 'Mahotsav','@','75') (B) ['Amrit','Mahotsav','@ 75']
(C) ('Amrit', 'Mahotsav','@75') (D) ['Amrit', 'Mahotsav @ 75']
9 Which of the following modes in Python creates a new file, if file does not exist and overwrites the 1
content, if the file exists ?
(A) r+ (B) r (C) w (D) a
10 Which of the following functions is a valid built-in function for both list and dictionary datatype ? 1
(A) items() (B) len() (C) update() (D) values()
11 State whether the following statement is True or False: 1
In Python, if an exception is raised inside a try block and not handled, the program will terminate
without executing any remaining code in the finally block.
12 What will the following expression be evaluated to in Python ? 1
print(6/3 + 4**3//8-4)
(A) 6.5 (B) 4.0 (C) 6.0 (D) 4
13 fetchone() method fetches only one row in a ResultSet and returns a __________. 1
(A) Tuple (B) List (C) Dictionary (D) String
14 Which command is used to add a new constraint in existing table in SQL. 1
(A) insert into(B) alter table(C) add into(D) create table
15 Consider the following statement: 1
SELECT * FROM PRODUCT ORDER BY RATE………, ITEM_NAME ………
Which of the following option should be used to display the rate from greater to smaller and name in
alphabetical order?
(A) ASC, DESC(B) DESC, ASC(C) Descending, Ascending (D) Ascending, Descending
16 The function of a repeater is to take a weak signals and ……………… it. 1
(A) Restore(B) Regenerate(C) Reroute(D) Drop
17 Which protocol is used to send e-mail over internet? 1
(A) FTP (B) TCP (C) SMTP (D) SNMP
18 Fill in the blank : 1
_________ statement of SQL is used to add new tuple in a table.
(A) ALTER (B) UPDATE (C) INSERT (D) CREATE
19 Fill in the blank : 1
In a relational model, tables are called _________, that store data for different columns.
(A) Attributes (B) Degrees (C) Relations (D) Tuples
Q20 and Q21 are Assertion(A) and Reason(R) based questions. Mark the correct choice as:
(A) Both A and R are true and R is the correct explanation for A
(B) Both A and R are true and R is not the correct explanation for A
(C) A is True but R is False
(D) A is False but R is True
20 Assertion (A) : readlines() reads all the lines from a text file and returns the lines along with newline 1
as a list of strings.
Reasoning (R) : readline() can read the entire text file line by line without using any looping
statements. C) A is True but R is False
21 Assertion (A): A GROUP BY clause in SQL can be used without any aggregate functions. 1
Reasoning (R): The GROUP BY clause is used to group rows that have the same values in specified
columns and must always be paired with aggregate functions.
C) A is True but R is False
Section-B ( 7 x 2=14 Marks)
22 If L1=[5,3,7,1,3,9,2,3] L2=[„apple‟,‟banana‟,‟cherry‟.] then (Answer using built-in functions only) 2
Write a statement to, count the occurrences of 3 in L1.
Write the statement to find the maximum element in list L1.
Write a statement to extend L1 by appending all elements from L2.
Write a statement to sort the elements of L2 in alphabetical order.
Count Occurences of 3 in L1: Count_of_3 = L1.count(3)
Find maximum element in L1: max_element = max(L1)
L1.extend(L2)
L2.sort
23 Give examples for each of the following types of operators in Python: 2
(I) Assignment Operators (II) Identity Operators
Assignment Operators:
1. Example 1: = (Simple Assignment) Usage: x = 5 (assigns the value 5 to x)
2. Example 2: += (Add and Assign) : Usage: x += 3 (equivalent to x = x + 3)
Identity Operators: ( 1 Marks for any one of them )
1. Example 1: is , Usage: x is y (checks if x and y refer to the same object)
2. Example 2: is not : Usage: x is not y (checks if x and y do not refer to the same object)
24 If L1 = [10, 20, 30, 40, 20, 10, ...] and L2 = [5, 15, 25, ...], then: 2
(Answer using builtin functions only)
(I) A) Write a statement to count the occurrences of 20 in L1. OR B) Write a statement to find the
minimum value in L1.
(II) A) Write a statement to extend L1 with all elements from L2. OR B) Write a statement to get a
new list that contains the unique elements from L1.
I ( A) : count_20 = L1.count(20) (B) : min_value = min(L1)
II (A) : L1.extend(L2) (B) : unique_elements = list(set(L1))

25 Ravi, a Python programmer, is working on a project in which he wants to write a function 2


to count the number of even and odd values in the list. He has written the following code but his
code is having errors. Rewrite the correct code and underline the corrections made.
define EOCOUNT(L):
even_no=odd_no=0
for i in range(0,len(L))
if L[i]%2=0:
even_no+=1
Else:
odd_no+=1
print(even_no, odd_no)

def EOCOUNT(L):
even_no=odd_no=0
for i in range(0,len(L)):
if L[i]%2==0:
even_no+=1
else:
odd_no+=1
print(even_no, odd_no)
26 Write the output of the queries (i) to (iv) based on the table, GARMENT given below : 2
TABLE : GARMENT

(i) SELECT DISTINCT(COUNT(FCODE))FROM GARMENT;

(ii) SELECT FCODE, COUNT(*), MIN(PRICE) FROM GARMENT GROUP BY FCODE


HAVING COUNT(*)>1;

(iii) SELECT TYPE FROM GARMENT WHERE ODR_DATE >'2021-02-01' AND PRICE
<1500;
(iv) SELECT * FROM GARMENT WHERE TYPE LIKE 'F%';

27 i)Explain the difference between implicit and explicit type conversion. 2


Given the following Python expressions, identify whether the conversion is implicit or explicit.
A) a = 6+5.8 B) b = int(8.5) C) c = str(100) D) d = 8/4
Implicit conversion converts one data type to another without user intervention.
Explicit conversion converts one datatype to another using
a) a=6+5.8 - Implicit conversion b) int(8.5) - Explicit conversion
c) c=str(100) - Implicit conversion d) d=8/4 - Implicit conversion
ii)Give two examples for each of the following:
Logical errors ii) Run-time errors
i) Logical errors:
1. Incorrect calculation:
def calculate_average(numbers):
total = 0
for number in numbers:
total += number
return total #Missing division by the number of elements
Problem: The function forgets to divide the sum by the number of elements in the list.
2. Wrong Conditional logic
temp = 10
if temp>0:
print(“Temperature is below freezing”) # Incorrect message
Problem: The condition checks if the temperature is greater than o, but the print statement
incorrectly states that temperature is below freezing.
ii) Run-time errors 1. Division by zero:
# Raises a zero division error. Problem: Division by zero causes a ZeroDivisionError. 2. Calling a
function that does not exist:(½ mark) myfunction() #NameError Problem: Raises a NameError if
my_function has not been identified.
28 i) Explain one advantage and one disadvantage of mesh topology in computer networks. 2
Advantage of Mesh Topology: High redundancy; if one connection
fails, data can still be transmitted through other nodes.
Disadvantage of Mesh Topology: Complexity and high cost; requires
more cabling and configuration compared to simpler topologies.
ii) Expand the term DNS. What role does DNS play in the functioning of the Internet?
DNS stands for Domain Name System. It translates humanreadable domain names (like
www.example.com) into IP addresses that computers use to identify each other on the
network.
Section-C ( 3 x 3 = 9 Marks)
29 A) Write a Python function that extracts and displays all the words present in a text file 3
“Vocab.txt” that begins with a vowel.
def display_words_starting_with_vowel():
vowels = 'AEIOUaeiou'
with open('Vocab.txt', 'r') as file:
words = file.read().split()
# Loop through the words and check if the first letter is a vowel
for word in words:
if word[0] in vowels:
print(word)
B)Write a function RevString() to read a textfile “Input.txt” and prints the words starting
with „O‟ in reverse order. The rest of the content is displayed normally.
Example :
If content in the text file is :
UBUNTU IS AN OPEN SOURCE OPERATING SYSTEM
Output will be :
UBUNTU IS AN NEPO SOURCE GNITAREPO SYSTEM
(words „OPEN‟ and „OPERATING‟ are displayed in reverse order)
def RevString():
fin=open('Input.txt')
S=fin.read()
for w in S.split():
if w[0]=='O':
print(w[::-1],end=' ') #ignore end
else:
print(w,end=' ') #ignore end
fin.close()
30 Predict the output for the following 3
data = [3, 5, 7, 2] x ='pen,note-book,eraser,bag'
result = "" y = x.split(', ')
for num in data: for z in y:
for i in range(num): if z < 'm':
result += str(i) + "*" print(str.lower(z))
result = result[:-1] else:
print(result) print(str.upper(z))
Output 01201234012345601 PEN,NOTE-BOOK,ERASER,BAG
31 You have a stack named MovieStack that contains records of movies. Each movie record is 3
represented as a list containing movie_title, director_name, and release_year. Write the following
user-defined functions in Python to perform the specified operations on the stack MovieStack:
(I) push_movie(MovieStack, new_movie): This function takes the stack MovieStack
and a new movie record new_movie as arguments and pushes the new movie record onto the stack.
(II) pop_movie(MovieStack): This function pops the topmost movie record from the
stack and returns it. If the stack is empty, the function should display "Stack is empty".
(III) peek_movie(MovieStack): This function displays the topmost movie record from the stack
without deleting it. If the stack is empty, the function should display "None".
def push_movie(movie_stack, new_movie):
movie_stack.append(new_movie)
def peek_movie(movie_stack):
print("Peek of the stack",movie_stack[len(movie_stack)-1])
def pop_movie(movie_stack):
while True:
if movie_stack==[]:
print("Stack is empty")
break
else:
print(movie_stack.pop())

movie_stack=[]
ans='y'
while ans=='y':
movie_title=input("enter movie title")
director_name=input("enter director name")
release_year=int(input("enter release_year"))
new_movie=[movie_title,director_name,release_year]
push_movie(movie_stack, new_movie)
ans=input("Do you want add more y/n?")
peek_movie(movie_stack)
pop_movie(movie_stack)
Section-D ( 4 x 4 = 16 Marks)
32 Write a point of difference between append (a) and write (w) modes in a text file. 4
a (append) mode - To open the file to write the content at the bottom(or end) of
existing content. It also creates the file, if it does not exist.
whereas
w (write) mode - To create a new file to write the content in it. It overwrites the file, if
it already exists.
Write a program in Python that defines and calls the following user defined functions :
(i) Add_Teacher() : It accepts the values from the user and inserts record of a teacher
to a csv file „Teacher.csv‟. Each record consists of a list with field elements as
T_id,Tname and desig to store teacher ID, teacher name and designation respectively.
(ii) Search_Teacher() : To display the records of all the PGT (designation) teachers
import csv
def Add_Teacher():
fout=open("Teacher.csv","a",newline="\n")
csvw=csv.writer(fout)
ans='y'
while ans=='y':
T_id=int(input("Enter Teacher id: "))
Tname=input("Enter Teacher name:")
desig=input("Enter Designation: ")
rec=[T_id,Tname,desig]
csvw.writerow(rec)
ans=input("do you want add more:y/n")
fout.close()
def Search_Teacher():
fin=open("Teacher.csv")
csvr=csv.reader(fin)
for record in csvr:
if record[2]=="PGT":
print(record)
fin.close()
Add_Teacher()
Search_Teacher()
33 The ABC Company is considering to maintain their salespersons records using SQL to store data. 4
As a database administrator, Alia created the table Salesperson and also entered the data of 5
Salespersons.

a. Identify the attribute that is best suited to be the Primary Key and why ?
Primary key: S_ID As it is non-repeating value and not expected to repeat for new rows too.
Note:
S_NAME should also be considered as a Primary Key
b. The Company has asked Alia to add another attribute in the table. What will be the new
degree and cardinality of the above table ? Degree = 6 and Cardinality = 5
c.Write the statements to : i) Insert details of one salesman with appropriate data.
INSERT INTO SALESPERSON VALUES ("S006","JAYA",23,34000,'SOUTH');
ii) Change the Region of salesman „SHYAM‟ to „SOUTH‟ in the table Salesperson.
UPDATE SALESPERSON SET REGION='SOUTH' WHERE S_NAME="SHYAM";
d.Write the statement to :
i) Delete the record of salesman RISHABH, as he has left the company.
ii) Remove an attribute REGION from the table.
DELETE FROM SALESPERSON WHERE S_NAME="RISHABH";
ALTER TABLE SALESPERSON DROP COLUMN REGION;
34 The table Bookshop in MySQL contains the following attributes : 4
B_code – Integer B_name – String Qty – Integer Price - Integer
Note the following to establish connectivity between Python and MySQL on a „localhost‟ :
● Username is „shop‟
● Password is „Book‟
● The table exists in a MySQL database named Bstore.
Write the python interface code to updates the records from the table Bookshop in MySQL.
that updates the Qty to 20 of the records whose B_code is 105 in the table.
import mysql.connector as mysql
def update_book():
mydb=mysql.connect(host="localhost",user="shop",passwd="Book",database="Bstore")
mycursor=mydb.cursor()
qry= "update Bookshop set Qty=20 where B_code=105"
mycursor.execute(qry)
mydb.commit()
mydb.close()
update_book()
35 Consider the following tables EMPLOYEE and DEPARTMENT and answer (a) and (b) parts of 4
this question.
Table: EMPLOYEE
TCode TName DCode Sal Age JoinDate
15 Sameer 23 7500 39 01-Apr-2007
21 Ragu 01 8500 29 11-Nov-2005
34 Ram 19 5250 43 03-Mar-2010
46 Meena 03 6700 38 12-Jul-2004
77 Kumar 03 6300 55 25-Nov-2000
81 Rajesh 19 7450 48 11-Dec-2008
89 Sanjai 01 9260 54 12-Jan-2009
93 Pragya 23 3200 29 05-Aug-2006

Table: DEPARTMENT
DCode DName HOD
01 ACCOUNTS Raj
03 HR Singh
23 RESEARCH Vijay
19 TRANSPORT Yogesh

i. To display all DName along with the DCode in descending order of DCode.
ii. To display the average age of Employees in DCode as 103.
iii. To display the name of HOD of the Employee named "Sanjai"
iv. To display the details of all employees who have joined before 2007 from the EMPLOYEE
table.
i. SELECT DName, DCode FROM DEPARTMENT ORDER BY DCode DESC;
ii. Select AVG (Age) from EMPLOYEE WHERE DCode = 103 ;
iii. SELECT HOD FROM DEPARTMENT WHERE EMPLOYEE.TName="Sanjai" AND
EMPLOYEE. DCode = DEPARTMENT. DCode;
iv. SELECT * FROM EMPLOYEE WHERE joinDate < '01-JAN-2007' ;
b.Give the output of the following SQL queries:
i. SELECT COUNT (DISTINCT DCode) FROM EMPLOYEE;
ii. SELECT MAX(JoinDate), MIN (JointDate) FROM EMPLOYEE;
iii. SELECT TName, HOD FROM EMPLOYEE E, DEPARTMENT D WHERE E.DCode
=D.DCode;
iv. SELECT COUNT (*) FROM EMPLOYEE WHERE Sal > 6000 AND Age > 30;

SECTION E (2 X5 = 10 Marks)
36 Raj is a supervisor at a software development company. He needs to manage the 5
records of various employees. For this, he wants the following information of each
employee to be stored:
Employee_ID – integer
Employee_Name – string
Position – string
Salary – float
You, as a programmer of the company, have been assigned to do this job for Raj.
(I) Write a function to input the data of an employee and append it to a binary file.
(II) Write a function to update the data of employees whose salary is greater than 50000 and
change their position to "Team Lead".
(III) Write a function to read the data from the binary file and display the data of all those
employees who are not "Team Lead".
import pickle
def input_data():
f1=open("emp.dat","wb")
ans="y"
while ans=="y":
empid=int(input("enter the empid"))
empname=input("enter the name")
position=input("enter the position")
salary=int(input("enter the salary"))
L=[empid,empname,position,salary]
pickle.dump(L,f1)
ans=input("do u want to add more?y/n")
f1.close()
input_data()
def update_data():
emp=[]
with open("emp.dat","rb")as f2:
try:
while True:
emp.append(pickle.load(f2))
except EOFError:
pass
for i in range(len(emp)):
if emp[i][3]>50000:
emp[i][2]="Team Lead"
with open("emp.dat",'wb')as f3:
for employee in emp:
print(employee)
pickle.dump(employee,f3)
update_data()
def display_non_team_leads():
print("\nEmployees who are not Team Leads:")
with open("emp.dat",'rb') as f4:
try:
while True:
employee = pickle.load(f4)
if employee[2] != "Team Lead":
print(employee)
except EOFError:
pass

display_non_team_leads()
37 ABC Consultants are setting up a secure network for their office campus at Noida for their day-to- 5
day office and web-based activities. They are planning to have connectivity between three
buildings and the head office situated in Bengaluru. As a network consultant, give solutions to the
questions (i) to (v), after going through the building locations and other details which are given
below :
1. Suggest the most suitable place to install the server for this organization. Also, give reason to
justify your suggested location
Building 3 It has maximum number of computers
2. Draw the cable layout

3. Suggest the placement of the following devices with justification:


● Switch ● Repeater
Switch to be placed in each building for establishing connection
Repeater to be placed between Building 1 and Building 3 because distance is more than
100 meters between these two buildings.
However, if the second layout given in this marking scheme is considered, repeater will
not be required at all.
4. The organization is planning to provide a high-speed link with the head office situated in
Bengaluru, using a wired connection. Suggest a suitable wired medium for the same.
Optical Fibre
5.The System Administrator does remote login to any PC, if any requirement arises. Name
the protocol, which is used for the same.
Telnet

You might also like