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

BHARATIYA VIDYA BHAVAN, KOCHI

TERM END EVALUATION 2023-24


COMPUTER SCIENCE(083)
STD XII TIME : 3 Hours
MARK : 70
SECTION - A
1 Consider the following code: 1
with open(‘main’,’wt’) as f:
f.write(‘Bye’)

If the file “main” contains ’Good’ before execution of the program, what will be the
contents of the file after execution?

2 Multiple values returned from a function are returned as a __________ . 1

3 The readlines ( ) method returns a __________ 1


a. String b. A list of integers
c. A list of strings d. A Tuple of strings

4 When is the ‘finally’ block executed? 1


a. When there is no exception
b. When there is an exception
c. Only if some condition that has been specified is satisfied
d. Always

5 Which of the following statement(s) are wrong ? 1


a. When you open a file for reading, if the file does not exist, an error occurs
b. When you open a file for writing, if the file does not exist, a new file is created.
c.When you open a file for writing, if the file exists, the existing file gets overwritten
d. When you open a file in 'X" mode, if the file exists, it will overwrite the file.

6 1

Observe the diagram given above and identify the correct option to open the file
named “one.txt” using absolute path ?
a. F = open (‘one.txt’)
b. F = open( ‘C:\\tom\\data\\one.txt’)
c. F = open( ‘..\\data\one.txt’)
d. F = None of the above

7 Which one of the following is incorrect? 1


a. The variables used inside the function are called local variables.
b. The local variables of a particular function can be used inside other functions,
but these cannot be used in global space
c. The variables used outside function are called global variables
d. In order to change the value of global variable inside function, keyword global is
used.

8 Which of the following symbols are used for passing parameterized query for 1
execution using the cursor?
a. % b. { } c. $ d. Both a & b

9 Which argument of open() is used to suppress the EOL character in an CSV file ? 1
a. delimiter b. with c. newline d. writer ( )

10 Consider the following table Customer and choose the correct output for the query 1
given below

Select avg(discount) from Customer where CID>=30;


a) 150 b) 90 c) 116.7 d)175

11 State whether the following statement is True or False: 1


An exception may be raised even if the program is syntactically correct.

12 Which of the following statements is FALSE about keys in a relational database? 1


a. Any candidate key is eligible to become a primary key.
b. A primary key uniquely identifies the tuples in a relation.
c. A candidate key that is not a primary key is a foreign key.
d. A foreign key is an attribute whose value is derived from the primary key of
another relation.

13 When a file is opened using ‘a’ file mode, the file pointer is at the ______________ 1
of the file.

14 If a binary file is opened using the file object fin, which of the following is a valid 1
statement ?
a. fin.load( L ) b. pickle.load(fin, L )
c. L = pickle.load ( fin ) d. L = fin.load ( )

15 The command to display list of databases in Mysql is ___________ 1


16 Consider the tables ‘emp’ and ‘dept’ and answer the question given below: 1

What is the degree and cardinality of the resultant table obtained by the following
query ?
select * from emp natural join dept;

17 Assertion (A) - If the arguments in the function call statement match the number and order 1
of arguments as defined in the function definition, such arguments are called positional
arguments.

Reasoning (R) - During a function call, the argument list first contains default argument(s)
followed by the positional argument(s).

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

18 Assertion (A) - A Stack follows LIFO structure. 1

Reasoning (R) - An element can be deleted only from the Top of the Stack.

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
SECTION - B
19 Ameya is a programmer and she wrote a python code to find the sum of even 2
elements in a list. She encountered some syntactical errors in her program. Help
her to correct the code. Rewrite the corrected code and also underline the
corrections made
l=[10,20,30,40,50]
def sumlist ( )
s=0
for i in range ( 0 : 5 : 1 ) :
a=l(i)
if a%2 = 0 :
s=s+a
print ( s )

20 a. A list contains the following record of students ([studname , mark]). Write the 3
following user defined functions to perform given operations on stack named
‘stud’.
i) push_stud() - To push students names to stack whose mark is more
than 250
ii) pop_stud() - To pop the names of students from stack and display them.
Also display “Underflow” when there are no students in the stack.
Example:
If the list contains:
[[‘Rahul’,450],[‘Deepa’,200],[‘Uma’,400],[‘Sidharth’,230]]
The stack should contain
Rahul
Uma
The output should be:
Uma
Rahul
Underflow
OR
Write a function in Python Push(student), where student is a dictionary containing
details of students {student_name:stream}. The function should push the names of
students who belong to Science stream to the stack ( Consider the case )
Example:
If the dictionary contains the following data :
student={‘Amal’:’Science’,’Julian’:’Commerce’,’Veena:’SCIENCE’,’Thara’:’Humaniti
es’}
The stack should contain
Amal
Veena

b. Expand LIFO and list any two applications of Stack 2

21 What will be the output of the following code segment ? 2


a=10
lst= [ 3 , 2 , 5 , 6 ]
def exec1( ) :
a=5
lst[1]=lst[1]+a
lst[2]=lst[2]+a
print(lst)
exec2()
def exec2 ( ) :
global a
lst[3]=lst[3]+a
print(lst)
exec1()

22 Assume that a file is opened using the file object “File”, Write commands to do the 2
following :
a. Place the file handle at the end of the file.
b. Print the current position of the file handle.

23 Write a program in Python to increase the salary of all employees by 1000 in the 4
table Emp which contains the following table structure.
Eno - integer , Ename - string ,Salary - integer
Note the following to establish connectivity between Python and MySQL:
host is "localhost" , User name is "root" , Password is "root", Table name is Emp
database name is "Employee"

24 Write a program in python that defines and calls the following user defined 4
functions:
a. Add_Cust() : Takes details of a customer and adds them to a csv file
‘Cust.csv’. Details of customer - cust_no, cust_name, pending_amount
b. Search_Cust() : Takes customer number as input and displays
corresponding pending_amount to be paid
OR
Write a program in python that defines and calls the following user defined
functions:
c. Add_Match ( ) : Takes details of a football match ( Date, Teams, Stadium )
and adds them to a csv file Football.csv’.
d. Display_Stadium ( ) : The function takes the stadium as an argument and
displays the dates on which the matches are played at the corresponding
stadium.

25 Write a function to do the following : 2


a. To count the number of words which contains the letter ‘a’ in a text file
‘read.txt’.
b. To display all lines which starts and ends with the word ‘The’ in a file 2
named ‘news.txt’

26 Explain the difference between a text file and a binary file . 2

27 a. What is Pickling or Serialization ? 1

b. Consider a binary file ‘Netflix.dat’ which contains the information SeriesID, 5


Series Name, Actor and Language. Write a program in Python that defines and
calls the following user defined functions
Add_Series ( ) - function which accepts the details of Series and writes them into
the file Netflix.dat
Search_Series() - function which takes the Language as argument and prints all
the Series Names in the corresponding language

28 Write a function in Python named Shift() which will shift all elements in a list 3
towards the left. First element in the list will be placed as the last element.
Example:
Consider the list - [10,4,2,7,8,1]
Final list should be - [4,2,7,8,1,10]

SECTION - C
29 Sumitha, a database administrator, is working on a project. She wrote a query for 1
her project and found that it is not giving the expected result. Help her to correct
her query. The query is as follows:
Select * from items where comp_name =null;

30 Consider the table Teacher and write the queries for the following questions: 9

a. Display name and age of teachers whose salary is between 30000 and 40000
(both inclusive)
b. Display number of departments
c. Display details of teachers whose name ends with ‘a’
d. Display the total salary of all departments along with department name
e. Display names and salary of teachers in descending order of their age
f. Give an increment of 5000/- in their salary for all Computer teachers
g. Remove all teachers from the table whose age is below 30
Consider the above table and write the output for the following queries:
h. Select Tname from Teacher where Dept in(‘Maths’,’Computer’);
i. Select Tname,salary+5000 from Teacher Where age > 40 and
Dept=’English’;

31 Adithya is asked to store salary details of employees in a company. He created a 5


table Payroll. Based on the table he has created, help him to find out the queries
for the following:
a. To identify the attributes which can be made candidate keys
b. To insert a new record with appropriate data
c. To display the annual salary with the heading ‘Annual Salary’ for
employees who are not getting commission
d. To remove primary key constraint for the attribute EID
e. To delete the table Payroll

32 Consider the tables ‘emp’ and ‘dept’ and answer the question given below:

a. Identify the primary key and foreign key of table Emp 1


b. Write query to display employee name, salary and department name of those
employees whose salary is more than 30000 1
c. Write output for the following query:
Select min(salary),max(salary) from Emp,dept where Emp.dno=dept.dno and
dname=’Sales; 1
ALL KERALA BHAVANS MODEL EXAMINATION 2023-24
Computer Science Marks: 70
Class: XII Time: 3 Hrs.

General Instructions:
 Please check this question paper contains 35 questions.
 The paper is divided into 4 Sections- A, B, C, D and E.
 Section A, consists of 18 questions (1 to 18). Each question carries 1 Mark.
 Section B, consists of 7 questions (19 to 25). Each question carries 2 Marks.
 Section C, consists of 5 questions (26 to 30). Each question carries 3 Marks.
 Section D, consists of 2 questions (31 to 32). Each question carries 4 Marks.
 Section E, consists of 3 questions (33 to 35). Each question carries 5 Marks.
 All programming questions are to be answered using Python Language only.

SECTION A

1. State True or False.


“In a Python program, if a break statement is given in a nested loop, it terminates the
execution of all loops in one go.”

2. Given the following dictionary


Day={1:"January", 2: "Febuary", 3: "March"}
Which statement will return "March".
(a) Day.pop() (b) Day.pop(2) (c) Day.pop(1) (d)
Day.pop("Tuesday")

3. What will be the output of the following statement.


print(5-2**2**2+77/11)
a. 4 b. 4.0 c. -4.0 d. Error

4.Which keyword can be used to return only different values in a particular column or a
whole
table?
(a) WHERE (b) DISTINCT (c) ALL (d) BETWEEN

5. Which of the following is not a tuple function ?


(a) min ( ) (b) max( ) (c) update( ) (d) count( )

6. Carefully observe the code and give the answer :-


def functions1(a) :
a= a+ ‘1’
a=a*2
function1 (“hello”)
(a) Indentation Error (b) hello2
(c) cannot perform mathematical operation on strings (d) hello2hello2

7. Which of the following statement(s) would give an error during execution of the
following code?
tup = (20,30,40,50,80,79)
print(tup) #Statement 1
print(tup[3]+50) #Statement 2
print(max(tup)) #Statement 3
tup[4]=80 #Statement 4

(a) Statement 1 (b) Statement 2 (c) Statement 3 (d) Statement 4

8. To delete all the records from a table “Product” the command will be
(a) DEL FROM Product; (b) DELETE FROM Product;
(c) REMOVE ALL FROM Product; (d) DELETE ALL;

9. Choose the correct output for the following stack operation


Push(5)
Push(8)
Pop()
Push(2)
Push(5)
Pop()
Push(1)
(a) 8 5 2 5 1 (b) 8 5 5 2 1 (c) 2 5 5 1 (d) 5 2 1

10. Study the following program and select the possible output(s) and write maximum and
minimum value assigned to the variable y
import random
x=random.random( )
y=random.randint(0,4)
print(int(x),”:”,y+int(x))
(a) 0:0 (b) 1: 6 (c) 2:4 (d) 0:3

11. What will be the output of the following statement given:


txt="cbse. sample paper 2024"
print(txt.capitalize())
a) Cbse. sample paper 2024 b) CBSE. SAMPLE SAPER 2024
c) cbse. sample paper 2024 d) Cbse. Sample Paper 2024

12. The values being passed through a function call statements are called
(a) Actual parameter (b) Formal parameter (c) default parameter (d) None of
these

13. Write a statement to send the file pointer position 10 bytes forward from current location
of file, consider fp as file object.
a) fp.seek(10) b) fp.seek(10,1) c) fp.tell(10) d) fp.seek(1,10)

14. In order to open a connection with MySQL database from within Python using
mysql.connector
package, __________ function is used.
(a) open (b) connect (c) database() (d) connectdb()
15. What is the csv method that is used to read the csv file.
(a) readcsv() (b) read_csv( ) (c) reader( ) (d) read( )

16. Consider the following query


SELECT name FROM stu WHERE subject LIKE ‘_______ Computer Science’;
Which one of the following has to be added into the blank space to select the
subject which has Computer Science as its ending string?
(a) $ (b) _ (c) || (d) %

17. Assertion(A) : All candidate keys can be used as a primary key


Reasoning (R) : We can use more than one candidate key as a primary key
(a) Both (A) and (R) are correct (b) Both (A) and (R) are incorrect
(c) (A) is correct but (R) is incorrect (d) (A) is incoorect but (R) is correct

18. Assertion(A) : Stack is a linear data structure which works on FIFO principle.
Reasoning (R) : Stack is implemented using lists in Python with some restrictions.
(a) Both (A) and (R) are correct (b) Both (A) and (R) are incorrect
(c) (A) is correct but (R) is incorrect (d) (A) is incoorect but (R) is correct

SECTION B

19. Give any two characteristics of stacks.

20. A resultset is extracted from the database using the cursor object (that has been already
created) by giving the following statement.
Mydata=cursor.fetchone()
(a)How many records will be returned by fetchone() method?
(b)What will be the datatype of Mydata object after the given command is executed?

21. Differentiate between local variable and global variable with a suitable example for
each.

22. Write any two aggregate functions used in SQL.

23. Expand the following terms:


a.SMTP b. XML c. LAN d. IPR

24. Differentiate between equi –join and natural join in SQL with appropriate example.
OR
Categorize the following commands as DDL or DML:
INSERT, UPDATE, ALTER, DROP

25. Write a function, lenWords(Str), that takes a string as an argument and returns a tuple
containing length of each word of a string. For example, if the string is "Come let us have
some fun", the tuple will have (4, 3, 2, 4, 4, 3)
SECTION C

26. Predict the output of the code given below:


s = 'MoHaN dAs GaNdHi'
i=0
while i<len(s):
if (s[i].islower()):
print(s[i].upper(),end=' ')
if (s[i].isupper()):
print(s[i].lower(),end=' ')
else:
print(‘#’,end=' ')
i += 1

27.What will be the output of the following statement?

(i) SELECT * FROM Uniform NATURAL JOIN Cost;


(ii) SELECT Uname, Ucolour, Size FROM Uniform, Cost where
Uniform.Ucode=Cost.Ucode;
(iii) Select distinct(Price) from Cost;

28. Write a function countINDIA() which read a text file ‘myfile.txt’ and print the frequency
of the words ‘India’ in it (ignoring case of the word).
Example: If the file content is as follows:
INDIA is my country. I live in India. India has many states.
The countIndia() function should display the output as:
Frequency of India is 3
OR
Write a function countVowel() in Python, which should read each character of a text file
“myfile.txt” and then count and display the count of occurrence of vowels (including small
cases and upper case).
Example:
If the file content is as follows:
INDIA is my country. I live in India. India has many states.
The countVowel() function should display the output as:
Total number of vowels are : 20

29. Consider the following tables BOOKS and ISSUED in a database named “LIBRARY”.
Write SQL commands for the statements

(i) Display book name and author name and price of computer type books.
(ii) To increase the price of all history books by Rs 50.
(iii) Show the details of all books in ascending order of their prices.
OR
(iii) To display book id, book name and quantity issued for all books which have been
issued.

30. Write a function in Python PUSH(mydict),where mydict is a dictionary of phone


book(name and mobile numbers), from this dictionary push only phone numbers having 10
digits into a stack implemented by using list . Display the stack if it has at least one element,
otherwise display “stack empty” message.
>>>mydict={1234567890:"Shyam",94567892:"Ram",8657456789012:"Karun",
9674123789:"Tharun"}
>>> push(mydict)
Digit of phone number 8
Phone number: 94567892 doesn't have 10 digits, which can't be pushed
Digit of phone number 13
Phone number: 8657456789012 doesn't have 10 digits, which can't be pushed
Stack elements after push operation : [9674123789, 1234567890]
SECTION D

31. Write the SQL statements for the queries given below based on the following tables.

(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.

32.Write a Program in Python that defines and calls the following user defined functions:
(i) ADDR() – To accept and add data of a student to a CSV file‘ record.csv’ . Each record
consists of a list with field elements as rollno, name and mobile to store roll number name
and mobile no of student respectively.
(ii)COUNTR() – To count the number of records present in the CSV file named ‘
record.csv’

SECTION E

33. FutureTech Corporation, a Bihar based IT training and development company, is


planning to set up training centers in various cities in the coming year. Their first center is
coming up in Surajpur district. At Surajpur center, they are planning to have 3 different
blocks - one for Admin, one for Training and one for Development. Each block has number
of computers, which are required to be connected in a network for communication, data and
resource sharing. As a network consultant of this company, you have to suggest the best
network related solutions for them for issues/problems raised in question nos. (i) to (v),
keeping in mind the distances between various blocks/locations and other given parameters.
(i) Suggest the most appropriate block/location to house the SERVER in the Surajpur
center (out of the 3 blocks) to get the best and effective connectivity. Justify your answer.
(ii) Suggest why should a firewall be installed at the Surajpur Center?
(iii) Suggest the best wired medium and draw the cable layout (Block to Block) to most
efficiently connect various blocks within the Surajpur Center.
(iv) Suggest the placement of the following devices with appropriate reasons:
a) Switch/Hub b) Router
(v) Suggest the best possible way to provide wireless connectivity between Surajpur Center
and Raipur Center.

34.(i)Differentiate between r+ and w+ file modes in Python.


(ii) Consider a file, SPORT.DAT, containing records of the following structure:
[SportName, TeamName, No_Players]
Write a function, copyData(), that reads contents from the file SPORT.DAT and copies the
records with Sport name as “Basket Ball” to the file named BASKET.DAT. The function
should return the total number of records copied to the file BASKET.DAT.
OR
(i) How are csv different from binary files?
(ii) A Binary file, CINEMA.DAT has the following structure:
{MNO:[MNAME, MTYPE]}
Where
MNO – Movie Number
MNAME – Movie Name
MTYPE is Movie Type
Write a user defined function, findType(mtype), that accepts mtype as parameter and
displaysall the records from the binary file CINEMA.DAT, that have the value of Movie
Type as mtype.
35.(i)Define the term Domain with respect to RDBMS. Give one example to support your
answer.
(ii) Write a python code that reads records from the table named student and displays only
those records who have marks greater than 75. The structure of a record of table Student is:
RollNo – integer; Name – string; Clas – integer; Marks – integer
Note the following to establish connectivity between Python and MYSQL:
• Username is root
• Password is abc
• The table exists in a MYSQL database named school.
• The details (RollNo, Name, Clas and Marks) are to be accepted from the user.
BHARATIYA VIDYA BHAVAN, KOCHI
FIRST MODEL EXAMINATION
2023-2024
Std : XII COMPUTER SCIENCE( 083) Max. Marks:70
Time: 3 hrs
SET-4
General Instructions:
• Please check this question paper contains 35 questions.
• The paper is divided into 5 Sections- A, B, C, D and E.
• Section A, consists of 18 questions (1 to 18). Each question carries 1 Mark.
• Section B, consists of 7 questions (19 to 25). Each question carries 2 Marks.
• Section C, consists of 5 questions (26 to 30). Each question carries 3 Marks.
• Section D, consists of 2 questions (31 to 32). Each question carries 4 Marks.
• Section E, consists of 3 questions (33 to 35). Each question carries 5 Marks.
• All programming questions are to be answered using Python Language only.

Q no Question Mark
SECTION A
1 State True or False: 1
“The else part of a loop gets executed only when a break statement terminates it.”

2 Relation R1 has 10 tuples and 5 attributes. Relation R2 has 2 tuples and 7 attributes. 1
When a CROSS JOIN (Cartesian Product) is achieved between R1 and R2, how many
tuples would the resultant set have?

a)20 b)12 c)35 d)12


3 Evaluate the following expression and identify the correct answer. 1
5-(2+3)*99/11+2**3**2

a)472 b)472.0 c)24.0 d)24


4 Select the correct output of the code: 1
s="G20 summit 2023"
a=s.partition(" ")
print(a)

a) (‘G20’,’summit’,’20) b) (‘G20’,’summit’,’20)
c) ['G20', ' ', 'summit 2023'] d) ('G20', ' ', 'summit 2023')
5 In SQL, name the clause and keyword that is used to display the tuples in descending 1
order of an attribute.
a)Order By,Desc b)Group By ,Desc
c)Order BY,Asc d)Sort By,Desc

1
6 Two schools in the same city wanted to transfer e-learning information. Which type of 1
network will be used to implement the same?

a)PAN b)MAN c)LAN d)WAN


7 If we have a dictionary D1={1:"Gagan",2:"Ria",3:"Raj"}, What does the command 1
print(D1.popitem()) return?

a)Raj b)[3:’Raj’] c) (3, 'Raj') d)3 Raj


8 Consider the statements given below and then choose the correct output from the given 1
options:
s="GOOD MORNING"
print(s.title(),s.capitalize(),sep="!")

a)Good Morning!Good morning b)Good Morning!Good morning!


c)Good Morning Good Morning! d)Good Morning Good morning!

9 Which of the following statement(s) would give an error during execution of the 1
following code?
p1=["pass","fail"] #statement 1
p2=tuple(p1) #statement 2
p2[0]='redo'+'2' #statement 3
print(p2) #statement 4

a)statement 1 b)statement 2 c)statement 3 d)statement 4


10 What possible outputs(s) are expected to be displayed on screen at the time of execution 1
of the program from the following code?
import random
AR=[20,30,40,50,60,70];
FROM=random.randint(1,3)
TO=random.randint(2,4)
for K in range(FROM,TO+1):
print (AR[K],end="#")

a) 10#40#70# b) 30#40#50# c) 50#60#70# d)40#50#70#


11 Deepthy is in charge of Knowledge centre in ABC school, recently discovered that the 1
communication between her centre and the primary block of the school is extremely
slow and signals drop quite frequently. The distance between these two blocks is 140
meters. Name the device which may be used for smooth communication.
12 Consider the following function definition. 1
def sample(a,b=9,c=2):
a=a+1
b=b+5
print(a,b)
Which of the following statement is the correct function call for the above function.
a)sample(c=20) b)sample(b=10,c=9,6) c)sample(b=9) d)sample(b=7,a=9)

2
13 State whether the following statement is True or False: 1
Which of the following statements is true?
a) The standard exceptions are automatically imported into Python programs
b) All raised standard exceptions must be handled in Python
c) When there is a deviation from the rules of a programming language, a semantic error
is thrown
d) If any exception is thrown in try block, else block is executed

14 A _____________ makes sure that the values present in the foreign key column must 1
exist in the primary key column of the parent table.

15 Fill in the blank: 1


______________ is the protocol used to send emails.

16 What is the return type of readlines() function of text file? 1


a)string b)tuple c)list d)list of strings

Q17 and 18 are ASSERTION AND REASONING 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

17 Assertion(A):You can add an element in a dictionary using key:value pair 1


Reasoning (R): A new (key:value) pair is added only when the same key doesn’t exist
in the dictionary. If the key is already present, then the existing key gets updated and no
new entry will be made in the dictionary.

18 Assertion(A): Python Standard Library consists of various modules. 1


Reasoning(R): A function in a module is used to simplify the code and avoids
repetition.

SECTION B
19 i)Expand the following:- 1+1=2
a)WIMAX b)TCP/IP
ii)Give 2 differences between IP address and MAC address.

OR
i)Define the term baud.
ii)Explain URL and domain name with an example.

20 Find errors, underline them and rewrite the same after correcting the following code: 2
d1=dict[]
i=1
n=input("Enter number of entries:")
3
while i<=n:
a=input("Enter name:")
b=input("Enter age:")
d1(a)=b
i+=1
l=d1.key()
for i in l:
print(i,'\t',d1[i])
21 Write a python function to count the number of characters(character frequency) in a 2
string and store it in a dictionary. The function accepts string as an argument and return
the dictionary.
Consider the following string
S=”google.com”
Expected output is
{'g': 2, 'o': 3, 'l': 1, 'e': 1, '.': 1, 'c': 1, 'm': 1}

OR
Write a python function which takes list of strings as argument and display the
palindromic words from the list of strings separated by #.
Consider the following list
l=['mom','dad','hello','hai','malayalam']
Expected output is
mom#dad#malayalam#

22 Find the output of the following code: 2


def fun(s,l):
d={}
for i in range(len(s)):
if i%2!=0:
d[l.pop()]=s[i]
else:
d[l.pop()]=i+2
return d

s="Hello"
l=[11,12,14,13,20]
d=fun(s,l)
for i in d.values():
print(i,sep='*',end='!')

23 Write the Python statement for each of the following tasks using BUILT-IN 1+1=2
functions/methods only:
i) To Join all items in a tuple( t) into a string( x ), using a hash character as
separator:
ii) To sort a list (L1) in descending order and returns a new sorted list (L2)
without changing the original list.

4
OR
i) A list named studentAge stores age of students of a class. Write the Python
command to import the required module and (using built-in function) to
display the most common age value from the given list.
24 Riya is working on RDBMS. Help her to perform the following task: 1+1=2
i) To delete a column named Dept from the table Emp.
ii) To add a primary key to the Empno column of the table Emp.
OR
i) Rayan is working in a database named SPORT, in which he has created a table
named “Sports” containing columns SportId, SportName, no_of_players, and
category. After creating the table, he realized that the attribute, category has
to be deleted from the table and a new attribute TypeSport of data type string
has to be added. This attribute TypeSport cannot be left blank. Help Rayan
write the commands to complete both the tasks.
25 Predict the output of the following code: 2
p=5
def calc(q,r=2):
global p
p+=q+r
print(p, end= '#')

a=30
b=10
calc(a,b)
print(p,end='@')
calc(r=5,q=1)
SECTION C
26 Predict the output of the following code: 3
s="First Model 2023"
r=' '
for i in range(len(s)):
if s[i].isupper():
r=r+s[i].lower()
elif s[i].islower():
r=r+s[i].upper()
elif i%2==0:
r=r+s[i-1]
else:
r=r+'&'
print(r)
27 Consider the table MED_REPORT given below and write the output of the SQL 1x3=3
queries that follow.
STU_ID STU_NAME BLOOD_GROUP HEIGHT WEIGHT AGE
S101 Amrita O+ 151 55 16
S102 Bindhu A+ 162 65 17
S103 Radhika AB+ 170 45 16
5
S104 Rani O+ 155 50 15
S105 Sandra A+ 175 40 17

i) SELECT COUNT(DISTINCT BLOOD_GROUP) “COUNT” FROM


MED_REPORT;
ii) SELECT STU_NAME,BLOOD_GROUP FROM MED_REPORT WHERE
BLOOD_GROUP LIKE ‘A%’;
iii) SELECT STU_ID,STU_NAME FROM MED_REPORT WHERE WEIGHT
BETWEEN 45 AND 65;
28 Write a function(method)in python to read from a text file “INDIA.TXT”, and display 3
the number of occurrences of the word “India”.

OR

Write a function(method) in python to read the text file “MYNOTES.TXT”, to find and
display the lines not starting with vowel.
29 Consider the table given below: 1x3=3
Table:Result

Name Stipend Subject Average Class


Amal 200 English 38 Third
Uma Mathematics 67 First
Tharun 300 Physics 55 Second
Vijay 550 Chemistry 88 First
Vinayak Physics 62 First
Alok 600 Computer 90 First
Beena 450 Mathematics 58 Second
Based on the given table, write SQL queries for the following:

1) Delete the rows whose stipend is not entered.


2) Increase the stipend by 7% for the subject Computer.
3) Display the sum of stipend of all the students getting First class.Give column heading
as “SUM STIPEND”.

30 A list, Player contains following record of cricket players as list elements: 3


[Playername, Country, Age] Each of these records are nested together to form a nested
list.
Write the following user defined functions in Python to perform the specified operations
on the stack named cricket.
(i) Push_element(Player): It takes the nested list as an argument and pushes a list
object containing name of the player and country, whose age is less than 30.
(ii) Pop_element(): It pops the objects from the stack and displays them. Also, the
function should display “Stack Empty” when there are no elements in the stack.

For example
If the list Player contains
6
Player=[['aaa','India',30],['bbb','India',20],['ccc','Srilanka',28]]

The Output of pop_element must be


['ccc', 'Srilanka']
['bbb', 'India']
Stack Empty

SECTION D
31 Consider the following tables CABHUB and CUSTOMER. Write SQL commands for 1x4=4
the questions (i) to (iv)
Table: CABHUB

VCode VehicleName Make Colour Capacity Charges

100 Innova Toyota WHITE 7 15

101 SX4 Suzuki BLUE 4 14

104 C Class Mercedes RED 4 35

105 A-Star Suzuki WHITE 3 14

108 Indigo Tata SILVER 3 12

Table: CUSTOMER

CCode CName VCode

1 Hemant Sahu 101

2 Raj Lal 108

3 Feroza Shah 105

4 Ketan Dhal 104

i) To display the name of vehicle, make and capacity of vehicles in ascending


order of their seating capacity.
ii) To display the vehicle name and the customer name of all customers where the
vehicle name is ‘Innova’ or ‘Indigo’.
iii) To display the vehicle Code, Name of the vehicle, Customer Name,Make and
Colour of the Vehicle.
iv) To display the number of vehicles make wise.

32 Shyam is a Python programmer working in a school. For the Model Exam, he has created 4
a csv file named Result.csv, to store the marks of computer science of n students.

The structure of Result.csv is : [St_Id, St_Name, Mark,Grade]

7
Shyam wants to write the following user defined functions:
Accept() – to accept the details of n students and add it to the file Result.csv. The column
headings should also be added on top of the csv file.

Display() – to display the details of students who have scored ‘A’ Grade.
As a Python expert, help him to complete the task.

SECTION E
33 Delhi Public School is setting up its branch office in Hyderabad with four departments 1+1+
for Computer, Mathematics and FA along with an administrative office in separate 1+2=5
buildings. The physical distances between these department buildings and the number
of computers to be installed in these departments and administrative office are given
as follows. You as a network expert have to answer the queries as raised by them in
(i) to (iv).

Administrative Computer
office dept.

FA dept. Mathematics
dept.

Shortest distances between various locations in metres:


Administrative Office to Computer Dept. 54
Mathematics Dept. to Administrative Office 30
Computer Dept. to Mathematics Dept. 70
FA Dept. to Mathematics Dept. 50
FA Dept. to Administrative Office 40
FA Dept. to Computer Dept. 110
Number of Computers installed at the various departments are as follows:

Computer Dept 40
Administrative Office 140
Mathematics Dept 50
FA Dept 80

i) Suggest the most suitable location to house the server of this institution.
Justify the answer.
ii) Suggest the best cable layout for effective network connectivity of the
departments.
iii) Suggest the devices to be installed in each of these buildings for connecting
computers installed within the departments out of the following:
• Gateway
• Modem
• Switch
8
iv) Suggest the topology of the network and network cable for efficiently
connecting each computer installed in each of the departments out of the
following:
Topologies: Bus Topology, Star Topology
Network Cable: Ethernet Cable, Single Pair Telephone Cable, Coaxial Cable
34 i) Differentiate between seek() and tell() methods? 2+3=5
ii) Consider a Binary File Emp.dat, containing records of the following
structure:[Empno,Empname,Salary]
Write a function EmpUpdate(), to update the salary of an employee whose
employee number is accepted from the user.If the employee number is not
found, an appropriate message should be displayed.
OR
i) How are text files different from binary files?
ii) A Binary file, employee.dat containing Empno,Ename,Salary as
dictionary.
Write a user defined function, Search(), that displays the records from the
binary file employee.dat whose salary is greater than 30000.
35 i) Define the terms attribute and tuple with respect to RDBMS. Explain with 1+4=5
an example.
ii) Mr. xyz wants to write a program in Python to insert the following record
in the table named Student in MYSQL database, SCHOOL:
• rno(Roll number )- integer
• name(Name) – string
• DOB (Date of birth) – Date
• Fee – float
Note the following to establish connectivity between Python and MySQL:
• Username – root • Password - tiger • Host – localhost
The values of fields rno, name, DOB and fee has to be accepted from the
user. Help him to write the program in Python.
OR
i) Differentiate update command and alter command in RDBMS.
ii) Mr. ABC wants to write a program in Python to insert the following record
in the table named Student in MYSQL database, SCHOOL:
• rno(Roll number )- integer
• name(Name) – string
• DOB (Date of birth) – Date
• Fee – float
Note the following to establish connectivity between Python and MySQL:
• Username – root • Password - tiger • Host – localhost
Mr. ABC wants to display the records of students whose fee is more than
5000. Help him to write the program in Python

*******************************

You might also like