12 Computer Science SP 01
12 Computer Science SP 01
Maximum Marks: 70
Time Allowed: : 3 hours
General Instructions:
Section A
1. State true or false:
Like while, the for loop also works with conditions and truth values.
a) True
b) False
2. Which of the following sublanguages of SQL is used to query information from the database and to insert tuples into, delete tuples from, and modify tuples in the
database?
a) DDL (Data Definition Language)
b) Query
c) Relational Schema
d) DML (Data Manipulation Language)
3. Which of the following is correct to retrieve any character at index 'i' in string 's'?
a) s.__getitem__(i)
b) s.getitem(i-1)
c) s.__getitem__(i-1)
d) s.getitem(i)
4. What is a variable defined outside all the functions referred to as?
a) A local variable
b) An automatic variable
c) A static variable
d) A global variable
5. Computer communication signal which is in the form of the continuous wave is called
a) modulation signal
b) Binary signal
c) digital signal
d) analog signal
6. Which of the following command is used to open a file "c:\pat.txt" for writing as well reading in binary format only?
a) fout = open("c:\ \pat.txt", "wb+")
b) fout = open("c: \pat.txt", "w")
c) fout = open("c:\ \pat.txt", "wb")
d) fout = open("c: \ pat.txt", "w+")
7. Which of the following is a procedural language?
a) Relational Algebra
b) Query Language
c) Tuple Relational Calculus
d) Domain Relational Calculus
8. A relational database consists of a collection of ________.
a) Attributes
b) Tuples
c) Keys
d) Relations
9. To open a file c:\ss.txt for appending data, we use
a. file = open("c:\ \ss.txt", "a")
b. file = open("c:\ \ss.txt", "rw")
V = 25
def Fun(Ch):
V=50
print (V, end=Ch)
V *= 2
print(V, end=Ch)
print(V, end="*")
Fun("!")
print(V)
a) 25*50!100!100
b) 50*100!100!100
c) 25*50!100!25
d) Error
13. State true or false:
SSL provides a safe passage for data over Internet.
a) True
b) False
14. What is printed by the following statements?
a) False
b) True
c) None of these
d) Error
15. Fill in the blanks:
The SQL ________ clause contains the condition that specifies which rows are to be selected.
16. What is a Firewall in Computer Network?
a) An operating System of Computer Network.
b) A web browsing Software.
c) The physical boundary of Network.
d) A system designed to prevent unauthorized access.
17. Assertion (A): Python does not allow programmers to develop the software for several computing platforms by writing a program only once.
Reason (R): Python is cross platform language.
a) Both A and R are true and R is the correct explanation of A.
b) Both A and R are true but R is not the correct explanation of A.
c) A is true but R is false.
d) A is false but R is true.
18. Assertion (A): The file needs to be properly closed.
Reason (R): If any exception occurs while performing some operations in the file then the program terminates without closing the file.
a) Both A and R are true and R is the correct explanation of A.
b) Both A and R are true but R is not the correct explanation of A.
c) A is true but R is false.
OR
OR
OR
f = open("mytry", "w+")
f.write("0123456789abcdef")
f.seek(-3,2) //statement1
print(f.read(2)) //statement2
A One
B Two
C Three
D Four
2. Find the output of given code.
s = 'Hello'
s1 = '20'
s2 = 'World'
a = 4
b = 6
print(s+s2)
print(a+b+16)
print(s1*a)
print(s*2)
print(s + s2 + s1)
OR
31.
Consider a dictionary with keys as course name and fee as value. Write a program to push course name in stack where fee is more than 10000. Pop and display contents of
stack on the screen
i) Write a code to add the fee and course name to course_dict.
ii) Complete the code to compare the fee of the given key(course).
iii) Write a code to insert the element in the Stack.
iv) Write a code to find the length of the Stack.
32. Consider the following tables ACTIVITY and COACH. Write SQL commands for the following statements
Table: ACTIVITY
Table: COACH
2 Ravinder 1008
3 Janila 1001
4 Naaz 1003
i. To display the names of all activities with their Acodes in descending order.
ii. To display sum of PrizeMoney for the Activities played in each of the Stadium separately.
iii. To display the coach's names and Acodes in ascending order of Acode from the table COACH.
iv. To display the content of all activities for which ScheduleDate is earlier than 01-01-2004 in ascending order of ParticipantsNum.
Expected number of computers to be installed at various locations in the university are as follows:
Office Block 10
Science Block 140
Commerce Block 30
Table: ITEMS
Table: TRADERS
OR
Consider the following tables STOCK and DEALERS and answer (a) and (b) parts of this question:
Table: STOCK
Table: DEALERS
Dcode Dname
relation Teacher
Table: GAMES
To practice more questions & prepare well for exams, download myCBSEguide App. It provides complete study material for CBSE, NCERT, JEE (main),
NEET-UG and NDA exams. Teachers can use Examin8 App to create similar papers with their own name and logo.
Solution
Section A
1. (b) False
Explanation: False
2. (d) DML (Data Manipulation Language)
Explanation: DML (Data Manipulation Language) performs the change in the values of the relation.
3. (a) s.__getitem__(i)
Explanation: It is the correct syntax to call character at index i of string s
4. (d) A global variable
Explanation: A global variable
5. (d) analog signal
Explanation: Analog Signal, a continuous time varying signal, which represents a time varying quantity.
6. (a) fout = open("c:\ \pat.txt", "wb+")
Explanation: fout = open("c:\ \pat.txt", "wb+")
7. (a) Relational Algebra
Explanation: All others are non procedural language.
8. (d) Relations
Explanation: Fields are the column of the relations
9. (c) a, c
Explanation: (a) and (c) statements have the correct syntax to open the file in append mode.
10. (d) program
Explanation: program
11. (b) Top
Explanation: The top is the pointer variable that contains the first or topmost element of the stack.
12. (c) 25*50!100!25
Explanation: 25*50!100!25
13. (a) True
Explanation: True, SSL provides a mechanism for encrypting and authenticating data sent between processes running on a client and server, as well as mediating
the secure exchange of private keys for session encryption through the use of an SSL certificate issued by a trusted certificate authority.
14. (b) True
Explanation: True
15. 1. WHERE
16. (d) A system designed to prevent unauthorized access.
Explanation: A firewall is a network security device that monitors incoming and outgoing network traffic and decides whether to allow or block specific traffic based on a
defined set of security rules.
17. (d) A is false but R is true.
Explanation: We can say that Python is a cross platform language as Python can run on different platforms such as Windows, Linux, UNIX, and Macintosh, etc. It enables
programmers to develop the software for several computing platforms by writing a program only once.
18. (a) Both A and R are true and R is the correct explanation of A.
Explanation: After closing the file, we cannot perform any operation in the file. The file needs to be properly closed. If any exception occurs while performing some
operation in the file then the program terminates without closing the file.
Section B
19. Answer:
1. i. Guided media is a point to point communication to connect computers, it uses cables, whereas unguided media is a wireless communication which transmits
the signal through the air.
ii. In-circuit switching, a dedicated path exists from source to destination while in packet switching, there is no fixed path.
2. OR
i. Modulation is the technique of changing the characteristics of the signal being transmitted so that it carries data and Demodulation is the reverse process of
modulation where data is extracted from the received signal (i.e., from the modulated wave). Another crucial difference between modulation and demodulation
is that modulation is done at the transmitting end while demodulation occurs at the receiving end.
20. import MySQLdb
db=MySQLdb.connect('localhost', 'sales', 'Admin', 'salar345')
cursor= db. cursor (prepared= TRUE)
sql_query= """INSERT INTO order-details (ORDNUMB, PARTNUMB, NUMBORD,QUOTPRIC) VALUES ('%s', '%s', '%s','%s')"""
rec_inst= [('12489', 'AX12', '11','14.95'), ('12491', 'ABT04', '1','402.99'), ('12495', 'BZ66', '1','311.95'),
('12498', 'CX11', '2','57.95')]
try:
cursor. executemany(sql_query, rec_inst)
print(cursor.rowcount, "Record inserted successfully")
'True' String
"False" String
45345 Integer
OR
Output
Enter value of x : 75
Enter value of y : 70
After swapping
The value of x : 70
The value of y : 75
22. Answer:
1. fetchone() method returns the next row from the result set as tuple while fetchall() fetches all the rows of a query result.
2. 'Ushakiran', 42568987036
23. i. List
ii. String
OR
To access the tuple’s elements, index number is used. Use the index operator [ ], elements of a tuple can be accessed. The index should be an integer. Index of 0 refers to
first element, 1 refers to second element and so on. While the index of - 1 refers to the last element, - 2 refers to the second last element and soon.
e.g. t1 = (87, 90, ‘Maths’, ‘English’, 56, 44, 99, ‘Science’, 23)
OR
Statement1 uses seek() method that can be used to position the file object at particular place in the file. It’s syntax is:
FileObject.seek(offset[, from_what])
1 - - -
2 - - -
3 - - -
4 - - -
OR
29. i. my_file =open('poemBTH.txt', 'r') will open the given file in read mode and my_file.read() read the entire file in string form.
ii. my_file = open('poemBTH.txt', 'r') will open the given file in read mode and my_file.read(100) read only the first 100 bytes from the file and store the read bytes in
form of a string.
Arguments y in line 6
Parameters x in line 1
x = 72
Function body in lines 2 and 3
return x + 3
y = 54
Main program in lines 5 and 6
res = processNumber(y)
Section D
31. i) course_dict[course] = fee
ii) course_dict[key]
iii) append(key)
iv) len(STACK)
32. i. SELECT Acode, ActivityName FROM ACTIVITY ORDER BY Acode DESC;
ii. SELECT Stadium, SUM(PrizeMoney) FROM ACTIVITY GROUP BY Stadium;
iii. SELECT Name, Acode FROM COACH ORDER By Acode;
iv. SELECT * FROM ACTIVITY WHERE SchduleDate < '01-Jan-2004' ORDER BY ParticipantsNum;
Section E
33. i.
ii. The most suitable place to house the server is Science Block as it has maximum number of computers. Thus, reducing the cabling cost and increases efficiency of
network.
iii. (b) Switch is the device to be installed in each of the blocks to connect all the computers.
iv. Satellite connection
v. MAN
34. i. SELECT * FROM ITEMS ORDER BY INAME ASC;
ii. SELECT INAME, PRICE FROM ITEMS WHERE PRICE = > 10000 AND PRICE = < 22000;
iii. SELECT TCODE, COUNT (CODE) FROM ITEMS GROUP BY TCODE;
iv. SELECT PRICE, INAME, QTY FROM ITEMS WHERE QTY > 150
OR
1. i. CREATE TABLE Student (Roll_Number NUMBER(5) Primary key, Name CHAR (20), Age Number (2), Marks Number (4));
ii. OUTPUT
i. 3
ii. 35
iii. 0
iv. 0
2. OR
i. SELECT city, 'the highest rating is MAX (rating) FROM customer GROUP BY city ;
To practice more questions & prepare well for exams, download myCBSEguide App. It provides complete study material for CBSE, NCERT, JEE (main),
NEET-UG and NDA exams. Teachers can use Examin8 App to create similar papers with their own name and logo.