selfstudys_com_file (17)
selfstudys_com_file (17)
a) Attributes b) Tuples
c) Keys d) Relations
3. What does the special file called data dictionary contains? [1]
a) The data types of all data in all b) The names of all fields in all
files. files.
4. Given a function that does not return any value, what value is thrown by default [1]
when executed in shell?
a) void b) None
c) bool d) int
5. Out of the following, find those identifiers, which cannot be used for naming [1]
Variables or Functions in a Python program:
Price*Qty, class, For, do, 4thCol, totally, Row31, _Amount
a) accepted b) resend
7. Raghav is trying to write an object obj1 = (1,2,3,4,5) on a binary file “test.bin”. [1]
Consider the following code written by him.
import pickle
obj1 = (1,2,3,4,5) myfile = open(“test.bin”.‘wb’)
pickle.________ #Statement 1
myfile.close()
Identify the missing code in Statement 1.
a) dump(myfile.obj1) b) write(obj1.myfile)
c) dump(obj1.myfile) d) load(myfile.obj1)
8. ________ operation is required when you want to create your records into a [1]
database table.
a) Insert b) Read
c) Update d) Delete
a) Dept b) ID
a) push b) insert
c) top d) pop
13. What is data redundancy? What are the problems associated with it? [1]
14. The ________ translates internet domain and hostnames to IP address. [1]
15. Which two lines of code are valid strings in Python? [1]
A. This is a string
B. 'This is a string'
C. (This is a string)
D. "This is a string"
a) A, C b) B, D
c) A, D d) C, D
16. Which of the following clauses in SQL is most appropriate to use to select [1]
matching tuples in a specific range of values?
a) IS b) BETWEEN
c) IN d) LIKE
17. In computer, process of superimposing a low frequency signal over a high [1]
frequency signal is called
c) modulation d) demodulation
18. An eight wired connector that is used to connect computers on a local area [1]
network?
a) RJ-45 b) Ethernet Card
c) Switch d) Modem
19. Assertion (A): When the comparison operator is directly applied to a series object, [1]
it returns a filtered result containing the value that returns true.
Reason (R): Applying comparison operator on series works in vectorized way.
a) Both A and R are true and R is b) Both A and R are true but R is
the correct explanation of A. not the correct explanation of
A.
20. Assertion (A): Python provides the remove() method which is used to remove the [1]
file pointer.
Reason (R): The mkdir() method is used to create the directories in the current
working directory.
a) Both A and R are true and R is b) Both A and R are true but R is
the correct explanation of A. not the correct explanation of
A.
21. Assertion (A): The enumerate() function takes a collection (e.g. a tuple) and [1]
returns it as an enumerate object.
Reason (R): The enumerate() adds a counter as the key of the enumerated object.
a) Both A and R are true and R is b) Both A and R are true but R is
the correct explanation of A. not the correct explanation of
A.
Section B
22. What is collision in a network? How does it impact the performance of a network? [2]
23. Write the code to create a table Product in database Inventory with following fields: [2]
Fields Datatype
PID varchar(5)
PName char(30)
Price float
Rank varchar(2)
24. In the below given code fragments, indicate the data type of each bold part by [2]
choosing the correct type of data from the following type.
a. int
b. float
c. bool
d. str
e. function
f. list of int
g. list of str
i. L = inputline.split( )
while L != ( ) :
print(L)
L = L[1 :]
ii. L = ['Hiya', 'Zoya', 'Preet']
print(L[0] + L[1])
OR
Underline the run-time error in the following program.
a = int(input("Enter a : "))
b=0
c = a/b
25. What are data types? What are the main objectives of datatypes? [2]
26. Find the errors in following code and write the correct code. [2]
if v < 5:
for j in range(v):
print "ABC"
else:
print "XYZ"
i. Underline the corrections
ii. Write the reason!error next to it in comment form.
OR
Write the suitable method's name for the below conditions.
i. Adds an element in the end of list.
ii. Returns the index of first occurrence.
iii. Adds contents of list2 to the end of list1.
OR
Read the code given below and answer the question:
fh = open ("main, txt", "w")
fh.write("Bye")
fh.close()
If the file contains "GOOD" before execution, what will be the contents of the file after
execution of this code?
Section C
29. What is the difference between a local variable and a global variable? Also, give a [3]
suitable Python code to illustrate both.
OR
Trace the flow of execution for following programs:
i. 1 def power(b., p):
2 r = b ** p
3 return r
4
5 def cpower(a):
6a=a+2
7 a = power(a, 0.5)
8 return a
9
10 n = 5
11 result = cpower(n)
12 print (result)
ii. 1. def increment(x)
2. x = x + 1
3.
4. # main program
5. x = 3
6. print(x)
7. increment(x)
8. print(x)
iii. 1. def increment(x):
2. z = 45
3. x = x + 1
4. return x
5.
6. # main
7. y = 3
8. print(y)
9. y = increment(y)
10. print(y)
11. q = 77
12. print(q)
13. increment(q)
14. print(q)
15. print(x)
16. print(z)
30. Give a suitable example of a table with sample data and illustrate Primary and [3]
Alternate Keys in it.
OR
Write the output of the SQL queries (a) and (b) based on the following two tables
FLIGHT and PASSENGER belonging to the same database:
Table: FLIGHT
FNO DEPART ARRIVE FARE
F101 DELHI CHENNAI 4500
F102 DELHI BENGALURU 4000
F103 MUMBAI CHENNAI 5500
F104 DELHI MUMBAI 4500
F105 MUMBAI BENGALURU 5000
Table: FLIGHT
PNO NAME FLIGHTDATE FNO
P1 PRAKASH 2021-12-25 F101
P2 NOOR 2021-11-20 F103
P3 HARMEET 2020-12-10 NULL
P$ ANNIE 2019-12-20 F105
a. SELECT NAME, DEPART FROM FLIGHT
NATURAL JOIN PASSENGER;
b. SELECT NAME, FARE
FROM PASSENGER P, FLIGHT F
WHERE F.FNO = P.FNO AND F.DEPART = 'MUMBAI';
31. Write definition of a method OddSum(NUMBERS) to add those values in the list [3]
of NUMBERS, which are not even.
OR
What are different types of arguments/parameters that a function can have?
Section D
32. A linear stack called status contains the following information: [4]
Phone number of Employee
Name of Employee
Write the following methods to perform given operations on the stack status:
i. Push_element () To Push an object containing Phone number of Employee and
Name of Employee into the stack.
ii. Pop_element () To Pop an object from the stack and to release the memory.
OR
Write a program that depends upon the user's choice, either pushes or pops an element
in a stack.
33. Write a program with method countand() to count the word 'and' or 'And as an [4]
independent word in a text file "status.txt". e.g. if the content of the file "status, txt"
is as follows:
Welcome to your one-step solutions for all your study, practice and assessment
needs for various competitive & recruitment examinations and school segment. We
have been working tirelessly for over a decade to make sure that you have best in
class study resources because you deserve SUCCESS AND NOTHING LESS...
Then the output of the program should be:
Count of _and_ in file is/are: 3
34. Write SQL queries for (i) to (iv) and find outputs for SQL queries (v) to (viii), [4]
which are based on the table.
TABLE: ACCOUNT
ANO ANAME ADDRESS
101 Nirja Singh Bangalore
102 Rohan Gupta Chennai
103 Ali Reza Hyderabad
104 Rishabh Jain Chennai
105 Simian Kaur Chandigarh
TABLE: TRANSACT
TRNO ANO AMOUNT TYPE DOT
T001 101 2500 Withdraw 2017-12-21
T002 103 3000 Deposit 2017-06-01
T003 102 2000 Withdraw 2017-06-12
T004 103 1000 Deposit 2017-10-22
T005 101 12000 Deposit 2017-11-06
i. To display details of all transactions of TYPE Deposit from Table TRANSACT
ii. To display the ANO and AMOUNT of all Deposits and Withdrawals done in the
month of October 2017 from table TRANSACT
iii. To display the last date of transaction (DOT) from the table TRANSACT for the
Accounts having ANO as 103.
iv. To display all ANO, ANAME and DOT of those persons from tables ACCOUNT
and TRANSACT who have done transactions less than or equal to 3000.
v. SELECT ANO, ANAME FROM ACCOUNT WHERE ADDRESS NOT IN
(CHENNAI BANGALORE);
vi. SELECT DISTINCT ANO FROM TRANSACT
vii. SELECT ANO. COUNT (*), MIN (AMOUNT) FROM TRANSACT GROUP
BY ANO HAVING COUNT (*) > 1
viii. SELECT COUNT (*), SUM (AMOUNT) FROM TRANSACT WHERE DOT <
= '2017-06-01'
OR
Give output for following SQL queries as per given table(s) :
Table : Books
Book_Id Book_Name Author_Name Publishers Price Type Qty.
William
F0001 The Tears First publ. 750 Fiction 10
Hopkins
: Anna Roberts
F0002 Thunderbolts Fist Publ. 700 Fiction 5
i
Brian and
T0001 My first C++ EPB 250 Text 10
Brooke
C++
T0002 A.W. Rossaine TDH 325 Text 5
Brainworks
C0001 Fast cook Lata Kapoor EPB 350 Cookery 8
Table : Issued
Book_Id Quantity_Issued
F0001 3
T0001 1
C0001 5
i. SELECT COUNT (DISTINCT Publishers) FROM Books.
ii. SELECT SUM(Price) FROM Books WHERE Quantity > 5.
iii. SELECT Book_Name, Author_Name FROM Books WHERE Price < 500.
iv. SELECT COUNT (*) FROM Books.
35. Consider the table product and client with structures as follows: [4]
Product client
ProductName ClientName
Manufacturer City
Price P_ID
Write Python codes for the following:
i. To display the details of those clients whose city is Delhi.
ii. To display the details of products whose price is in range of 50 to 100 (Both
values included)
iii. To display the Client Name, City from table Client.
iv. To display the price of all the items by the manufacturer ABC.
v. To display the product name and 4 items its price from the product table.
Section E
36. Great Studies University is setting up its Academic schools at Sunder Nagar and [5]
planning to set up a network. The university has 3 academic schools and one
administration centre as shown in the diagram below:
37. Write SQL commands for the queries (i) to (iv) and output for (v) to (viii) based on [5]
the tables 'Watches' and Sale given below.
Watches
Watchid WatchName Price Type Qty_Store
W001 High Time 10000 Unisex 100
W002 Life Time 15000 Ladies 150
W003 Wave 20000 Gents 200
W004 High Fashion 7000 Unisex 250
W005 Golden Time 25000 Gents 100
Sale
Watchid Qty_Sold Quarter
W001 10 1
W003 5 1
W002 20 2
W003 10 2
W001 15 3
W002 20 3
W005 10 3
W003 15 4
i. TO DISPLAY ALL THE DETAILS OF THOSE WATCHES WHOSE NAME
ENDS WITH TIME.
ii. TO DISPLAY WATCH'S NAME AND PRICE OF THOSE WATCHES WHICH
HAVE PRICE RANGE IN BETWEEN 5000-15000.
iii. TO DISPLAY TOTAL QUANTITY IN-STORE OF UNISEX TYPE WATCHES.
iv. TO DISPLAY WATCH NAME AND THEIR QUANTITY SOLD IN the FIRST
QUARTER.
v. SELECT MAX (PRICE), MIN(QTY_STORE) FROM WATCHES;
vi. SELECT QUARTER, SUM(QTY_SOLD) FROM SALE GROUP BY
QUARTER;
vii. SELECT WATCHNAME, PRICE, TYPE FROM WATCHES W, SALE S
WHERE W. WATCHID!= S.WATCHID;
viii. SELECT WATCHNAME, QTYSTORE, SUM (QTYSOLD), QTY_STORE -
SUM (QTY_SOLD) "STOCK" FROM WATCHES W, SALE S WHERE W.
WATCHID = S.WATCHID GROUP BY S.WATCHID;
OR
Write SQL queries for (i) to (iv) and find outputs for SQL queries (v) to (viii), which
are based on the tables:
DVD
DCODE DTITLE DTYPE
F101 Henry Martin Folk
Cl 02 Dhrupad Classical
C101 The Planets Classical
F102 Universal Soldier Folk
R102 A day in the life Rock
MEMBER
MID NAME DCODE ISSUEDATE
101 AGAM SINGH R102 2017-11-30
103 ARTH JOSEPH F102 2016-12-13
102 NISHA HANS C101 2017-07-24
i. To display all details from the table MEMBER in descending order of ISSUEDATE.
ii. To display the DCODE and DTITLE of all Folk Type DVDs from the table DVD.
iii. To display the Dtype and number of DVDs in each DTYPE from the table DVD.
iv. To display all NAME and ISSUEDATE of those members from the table MEMBER
who have DVDs issued (i.e., ISSUEDATE) in the year 2017.
v. SELECT MIN (ISSUEDATE) FROM MEMBER;
vi. SELECT DISTINCT DTYPE FROM DVD;
vii. SELECT D.DCODE. NAME, DTITLE: FROM DVD D, MEMBER M WHERE
D.DCODE=M.DCODE;
viii. SELECT DTITLE FROM DVD WHERE DTYPE NOT IN ("Folk", "Classical");
Solution
SAMPLE QUESTION PAPER - 4
Computer Science (083)
Class XII (2024-25)
Section A
1.
(b) False
Explanation:
False
2.
(d) Relations
Explanation:
Fields are the column of the relations
3.
(c) All of these
Explanation:
The data dictionary is structured in tables and views just like other database data.
4.
(b) None
Explanation:
When no value is returned by function in Python, it returns None object by default.
5. Price*Qty, class, 4thCol cannot be used for naming variables/functions in a Python
program:
6. (a) accepted
Explanation:
A checksum is a value used to verify the integrity of a file or a data transfer. In other
words, it is a sum that checks the validity of data. Checksums are typically used to
compare two sets of data to make sure they are the same.
7.
(c) dump(obj1.myfile)
Explanation:
The pickle.dump(obj1, myfile) line serializes the tuple obj1 and writes it to the file.
8. (a) Insert
Explanation:
Insert
9.
(b) ID
Explanation:
ID, A primary key is a key that is unique for each record.
10. mkdir() method of the OS module is used to create a directory in the current directory. We
pass an argument to this method which contains the name of the directory to be created.
mkdir() method raise FileExistsError if the directory to be created already exists.
11.
(b) False
Explanation:
We can skip default parameters in the function call. They will take the default value
assigned to them in the function definition.
12. (a) push
Explanation:
The insertion operation in the stack is called push operation.
13. Data redundancy means having multiple copies of the same data in the database. It leads to
problems like wastage of space and data inconsistency.
14.
(d) domain name system
Explanation:
The domain names systems matches the name of website to ip addresses of the website.
15.
(b) B, D
Explanation:
B, D, In Python string is the collection of the characters surrounded by single quotes,
double quotes, or triple quotes.
16.
(b) BETWEEN
Explanation:
BETWEEN
17. (a) frequency modulation
Explanation:
frequency modulation is process of superimposing a low frequency signal over a high
frequency signal.
18. (a) RJ-45
Explanation:
Registered Jack 45 is an eight wired connector that is used to connect computers on a local
area network(LAN), especially Ethernet.
19.
(d) A is false but R is true.
Explanation:
Applying comparison operator on series works in vectorized way i.e applies this check on
each element and then return true/ false for each element.
20.
(d) A is false but R is true.
Explanation:
The os module provides the remove() method which is used to remove the specified file,
not the file pointer. The mkdir() method is used to create the directories in the current
working directory.
21.
(b) Both A and R are true but R is not the correct explanation of A.
Explanation:
The enumerate() is a buit-in function available with the Python that takes a collection (e.g.
a tuple) and returns it as an enumerated object. The enumerate() function adds a counter as
the key of the enumerated object.
Example :
students = ['X', 'Y' ,'Z']
students_list = enumerate(students)
print(list(students_list))
will print [(0, 'X'), (1, 'Y'), (2, 'Z')]
Section B
22. In a computer network, collision is a specific condition that occurs when two or more
nodes on a network transmit data at the same time. For example, if two computers on an
Ethernet network send data at the same moment, the data will "collide" and not finish
transmitting. In case of a collision, the data gets garbled and cannot be read. Also, it may
hamper the overall performance of the network as collisions often lead to more
retransmissions which clog the network and deteriorate the overall performance of the
network.
23. import mysql.connector
mycon = mysql.connector.connect(host = "localhost", user = "system",passwd = "hello",dat
cur = mycon.cursor()
db = cur.execute("CREATE TABLE Production(PID varchar (5) Primary key, PName char
mycon.close()
24. i. List
ii. String
OR
a = int(input("Enter a : "))
b=0
c = a/b # Division by zero
iii. Keyword Arguments: Also called named arguments, the Keyword arguments are
passed by it's name instead of their position as opposed to positional arguments in the
function call and the position of arguments is irrelevant when calling a function, e.g.,
def add(a, b):
return a + b
add(b = 5, a = 7)
Section D
32. def Push_element(Status, Top):
phone_no = int(input("Enter phone number:"))
emp_name = input("Enter employee name:")
St = (phone_no, emp_name)
Status.append(St)
Top = Top + 1
return Top
def Pop_element(Status, Top):
Slen = len(Status)
if (Slen <= 0):
print("Status is empty")
else:
phone_no, emp_name = Status.Pop()
Top = Top-1
print("Phone number %s and name %s deleted"%(phone_no, emp_name))
return Top
OR
push and pop operation into the stack:-
MAX_SIZE = 1000
stack = [0 for i in range(MAX_SIZE)] -
top = 0
def push():
global stack, top
x = int( input ("Enter element to push into stack: " ))
if top >= MAX_SIZE:
print("Cannot push. Stack is full. Overflow!")
else:
stack[top] = x
top += 1
def pop():
global stack, top
if top == 0:
print("Cannot pop. Stack is empty. Underflow!")
else:
top -= 1
def printStack():
print(stack[:top])
# __main__
while True:
print("Please choose operation")
print("1. Push")
print("2. Pop")
print("3. Print")
print("4. Exit")
choice = int(input("Please enter 1/2/3 : " ))
if choice == 4:
break
elif choice == 3:
printStack()
elif choice == 2:
pop( )
elif choice == 1:
push()
else:
print("Please give a correct input")
33. import os
def countand():
if os.path.isfile("status.txt"):
fob=open("status.txt", 'r')
c=0
while True:
Str=fob.readline()
if not Str:
break
Str=Str.rstrip().lower().split()
for i in range(len(Str)):
if(Str[i]=='and' or Str[i]== 'AND'):
c=c+1
print("Count of_and_in file is/are: ", c)
else:
print("File does not exist")
countand()
v. ANO ANAME
103 Ali Reza
105 Simran Kaur
vi. DISTINCT ANO
101
102
103