Sample Paper 2 2023-24

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

Sec on - A

1. State True or False.

range(-1,-5) returns values -1,-2,-3,-4..

2. Rathin wants to create a table Players with a column playerid which should carry non null and unique
values.

Which constraint has to be given to the column?

(A) Primary Key (B) Not null

(C) Default (D) Check

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

6 *3 + 4**2 // 5 - 8

(A) 13 (B) 14 (C) 12 (D) 11

4. Write the output of the following code snippet:

my_dict = {“name”:”Aman”, “age”: 26}

my_dict[‘age’]=27

my_dict[‘address’]=”Delhi”

print(my_dict.items())

(A) dict_items([(‘name’, ‘Aman’), (‘age’,27), (‘address’, ‘delhi’)])


(B) dict_keys([(‘name’, ‘Aman’), (‘age’,27), (‘address’, ‘delhi’)])
(C) dict_values([(‘name’, ‘Aman’), (‘age’,27), (‘address’, ‘delhi’)])
(D) None of these

5. A table student has 15 columns and 100 rows. 10 rows are added later. What is the degree and
cardinality of the table now?

(A) Degree : 5, Cardinality : 110 (B) Degree : 15, Cardinality : 110

(C) Degree : 10, Cardinality : 90 (D) Degree : 150, Cardinality : 90

6. ABC Incorpora on has its 3 offices in the city of Lucknow., connected together in a network. These
offices seprated by a distance of approximately 45-50KM. Which kind of network is formed?
(A) PAN (B) WAN (C) MAN (D) LAN

7. Given is a Python string declara on:


myexam=”@@ CBSE Examina on 2024@@” Write the output of:
print(myexam[::-2])

(A) 20 otnx SC@ (B) @20 mx S@ (C) @20 otnmx SC@ (D) @120 otnmx sc@

8. Consider following list for python language L=[13, 3.45, “Tree”, ‘Amar’, [10, 8.91, “Apple”], 456]

The output of L[-2] will be

(A) (10, 8.91, ‘Apple’) (B) [10, 8.91, ‘Apple’] (C) {10, 8.91, ‘Apple’} (D) None of these
9. Which output lines of the following program will print the same result.
Tup1 = (10, 20, 30, 40, 50, 60, 70, 80, 90)
print(tup1[5:-1]) #1
print(tup1[5]) #2
print(tup1[5:]) #3
print(tup1[-4:8]) #4
(A) (1) and (2) (B) (1) and (4) C) (2) and (3) (D) (1), (3) and (4)

10. What possible output(s) are expected to be displayed on screen at the me of execu on of the
program from the following code? Also specify the maximum values that can be assigned to each of the
variables FROM and TO.

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) 56#60#70# (D) 40#50#70#

11. Fill in the blank:

The protocol used for remote login is ____________

(A) FTP (B) Telnet (C) HTTP (D) IRCP

12. Given the following code. What should be filled in the missing blank for proper execu on of the
code.

def reverse(n): #func on to display the reverse of the number in the parameter
rev=0
while n>0:
d=n%10
rev=______________ + d
n//=10
print(“Reverse:”,rev)

(A) rev/10 (B) rev*10 (C) rev//10 (D) return rev+10

13. State True or False: The code that may generate an excep on, has to be kept inside the try block.

14. Which of the following refers to the a ribute that can uniquely iden fy tuples within the rela on?

(A) Foreign key (B) Consolidate key

(C) Alternate key (D) Primary key

15. Fill the blank: ___________ switching technique follows the store and forward mechanism.

16. Which of the following statements open a csv file “stock.csv” for wri ng records into it?

(A) f=open(“stock.csv”, "w") (B) f=openfile (“stock.csv”, “wb”)

(C) f=open (“stock.csv”, "ab”) (D) f=openfile (“stock.csv”, "r")


Asser on and Reason:

In the following ques ons, A statement of Asser on(A) is following by a statement of Reason(R). Mark the
correct choice as.

(A) Both A and R are true and R is the correct explana on of A.


(B) Both A and R are true and R is not the correct explana on of A.
(C) A is true but R is false.
(D) A is false but R is false.

17. Asser on(A): A func on is a block of organized and reusable code that is used to perform a single, related
ac on.

Reason (R) : Func on provides be er modularity for your applica on and a high degree of code reusability.

18. Asser on (A): Text file store Informa on in ASCII or Unicode characters.
Reason (R) : In text file, there is no delimiter for a line.
Sec on – B

19. (a) Assume that 50 employees are working in an organiza on. Each employee has been allo ed a
separate worksta on to work. In this way, all computer are connected through the server and all these
worksta on are distributed over two floors. In each floor, all the computers are connected to a switch.
Iden fy the type of network?

(b) Given below are two addresses


(i) h p://www.abc.com/index.html
(ii) 182.68.9.165
Iden fy which one of the above is an IP address and which one is URL?
OR
(a) Expand the following terms:
TCP/IP, FTP
(b) Write any two differences between twisted pair cable and coaxial cable.

20. Asish has wri en a code , but I am ge ng some errors while execu ng it. Rewrite the correct code
removing all the errors.

Value = 30
for val in range(0,Value)
if val%4==0
print(val*4)
else if val%5 ==0:
print(val+3)
else
print(val+10)

21. Write the defini on of a method ZeroEnding(SCORES) to add all those values in the list SCORES,
which are ending with Zero(0) and display the sum.
If the SCORES contain SCORES=[200, 456, 300, 100, 234, 678]
The sum should be displayed as 600

OR
Write a func on namely big(LstStr) that reveives a list of string and display those strings that start and
end with a lowercase vowel.
22. Predict the output of the Python code given below:

L1, L2 = [10, 15, 20, 25],[ ]


for i in range(len(L1)):
L2.insert(i, L1.pop())
print(L1, L2,sep=”&”)

23. Write the Python statement for each of the following tasks using BUILT-IN func on/method only.

(i) To add a key :value pair “Email”: sbc@gmil.com to the dic onary Empdict.

(ii) To replicate a list Lstnames=[“Sonia”, “Rahul”, “Siksha”], 5 mes


OR
What will be the output of the following program?
i=5
j=7
x=0
i=i+(j-i)
x=j+i
print(x,”:”,i)
j=j**2
x=j+i
i=i+1
print(i,”:”,j)

24. Abhijit has wri en a query to increase the marks of students of “Science” stream student by 5. But
he is not ge ng the correct output. Help him by the correct query.
Table Student :[Admno, Name, Class, Stream, Marks, DtofAdm]
Query: “Modify student change marks=marks+5 where stream equals “Science”
Then a er wri en a query to remove the column stream from the table
OR
Difference between char(n) and varchar(n) data types with respect to databases.

25. What will be the output of the following Python code?


def displayString():
p=None
q=0
r=””
s=”None”
if p==q:
print(“None is the same as 0”)
elif p==r:
print(“None is the same as empty string”)
elif p==s:
print(“None is the same as the string ‘None’”)
else:
print(“None of the above”)
displayString()
SECTION C

26. Predict the output of the code given below:


string = input(“Enter a String : “)
count = 3
while True:
if string[0] == ‘a’:
string=string[2:]
elif string[-1] ==’b’:
string = string[:2]
else:
count+=1
break
print(string)
print(count)

27. Emp

Eno Ename Dept Desig Dto oin Salary


1 Jack Sales MGR 2012-09-12 89000
2 Priya Accts MGR 2005-04-22 56000
3 Ria Pers CLERK 200-01-09 25000
4 Anil Pers OFFICER 1994-04-03 67000
5 Sumit Sales OFFICER NULL 19000
6 Akash Sales OFFICER NULL 20000

(i) SELECT DEPT, SUM(SAL) FROM EMP GROUP BY DEPT;


(ii) SELECT DESIG, COUNT(*) FROM EMP GROUP BY DESIG;
(iii) SELECT DESIG, COUNT(*) FROM EMP GROUP BY DESIG HAVING COUNT(*) >1;

28. Write a func on in Python that counts the number of “Me” or “My” words present in a text file
“STORY.TXT”.
Example:
If the file content is as follows:
My first book
was Me and
My Family. It
Gave me
Chance to be
Known to the
world.

The output of the func on should be 4

OR

Write a func on to count the number of lines star ng with a digit in a text file “Diary.txt”
29. Consider the table Teacher given below:
TABLE : TEACHER

T_ID NAME AGE DEPARTMENT DATE_OF_JOIN SALARY GENDER


1 ARUNAN 34 COMPUTER SC 2019-01-10 12000 M
2 SAMAN 31 HISTORY 2017-03-24 20000 F
3 RANDEEP 32 MATHEMATICS 2020-12-12 30000 M
4 SAMIRA 35 HISTORY 2018-07-01 40000 F
5 RAMAN 42 MATHEMATICS 2021-09-05 25000 M
6 SHYAM 50 HISTORY 2019-06-27 30000 M
7 SHIV 44 COMPUTER SC 2019-02-25 21000 M
8 SHALAKHA 33 MATHEMATICS 2018-07-31 20000 F

Based on the table write SQL queries for the following:


(i) To display only names of teachers of “History” department.
(ii) To display name, age and department of teachers whose name has “a” as the 2nd le er.
(iii) To increase the salary of Male teachers by 5% who are in “Computer Sc” department.

30. Write a func on in Python , Push(SItem) where, SItem is a dic onary containing the details of
sta onary items – {sname:price}
The func on should push the names of those items in the stack who have price greater than 75. Also
display the count of elements pushed into the stack.

For Example:
If the dic onary contains the following data:
Ditem = {“Pen”:106, “Pencil”:59, “Notebook”:80, “Eraser”:25}
The stack should contain
Notebook
Oen
The output should be:
The count of elements in the stack is 2

SECTION D
31. Write SQL queries for (i) to (iv) based on table EMPLOYEE and DEPARTMENT given below:

Table : SCHOOL

CODE TEACHER SUBJECT DOJ PERIODS EXPERIENCE


1001 RAVI SHANKAR ENGLISH 2000-03-12 24 10
1009 PRIYA RAI PHYSICS 1998-09-03 26 12
1203 LIS ANAND ENGLISH 2000-04-09 27 5
1045 YASHRAJ MATHS 2000-08-24 24 15
1123 GAGAN PHYSICS 1999-07-16 28 3
1167 HARISH B CHEMISTRY 1999-10-19 27 5
1215 UMESH PHYSICS 1998-05-11 22 16

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
(i) To display each designa on and count of each type for designa on where count<2.
(ii) To display the maximum experience.
(iii) To display the name of teachers who have more than 12 years of experience in ascending
order of teacher name
(iv) To display teacher names and corresponding department from both the tables.

32. Rohini is a CS student and has been assigned by her teacher to write func on ADD() and COUNTER()
for working with records of employees.
ADD() – To accept and add data of an employee to CSV file “record.csv” . Each record consists of list
with field elements as empid, name and sal to store employee id, employee name and employee
salary respec vely.

COUNTER() – To count the number of records present in the CSV file named ‘record.csv’.

SECTION E

34. (i) Write any two needs for a data file.

(ii) A file sports.dat contains informa on about a formal Event Par cipant.

Write a func on that would read content from file sports.dat and create a file named Athle cs.dat
copying only those records from sports.dat where event name is “Athle cs”

OR

(i) How will you open a text file text.txt in write and read mode.
Arun, during Prac cal Examina on of Computer Science, has been assigned to write a search()
func on to search a record in a pickled file student.dat. The File student.dat is created by his
teacher and the following informa on is known about the file.
 File contain s details of student in [rollno, name, marks] fromat.
 File contains details of 10 students (i.e. from rollno 1 to 10) and separate list of each
student is wri en in the binary file using dump().
Help Arun in wri ng the code to search for the roll no passed to the func on.

35. (i) Define the term Candidate key with respect to RDBMS.

(ii) Write Python code to create a table loca on with following fields

Id -> Id of the loca on

Bidg_code -> code of the building

Room - > Type of rooms

Capacity -> capacity of the rooms

(i) Which keyword is used to sort the records of a table in descending order?
(ii) Consider the table FACULTY and COURSES with structure as follows.
FACULTY COURCES
F_ID C_ID
Fname F_ID
LName Cname
Hiredate Fees
Salary
Write Python codes to display details of those facul es whose salary is greater than 12000.

You might also like