Section A (1 Mark Each)
Question 1
Answer
False
Question 2
Answer
#THONPROGRAM
Question 3
Answer
not(True) and False
Question 4
Answer
['I', 'ter', 'atio',
'al']
Question 5
Answer
Output
ce lo
Question 6
Answer
False
Question 7
Answer
print(my_dict['apple', 'banana'])
Question 8
Answer
Removes the first occurrence of value x from the list.
Question 9
Answer
3
Question 10
Answer
file.seek(0)
Question 11
Answer
False
Question 12
Answer
12#15%
Question 13
Answer
The SQL command that can change the
degree of an existing relation (table) is ALTER TABLE.
Question 14
Answer
Details of all products whose names start with 'App'
Question 15
Answer
CHAR
Question 16
Answer
count()
Question 17
Answer
FTP
Question 18
Answer
Gateway
Question 19
Answer
Packet switching
Question 20
Answer
A is true but R is false.
Question 21
Answer
A is true but R is false.
Section B (2 Marks Each)
Question 22
Answer
In Python, a mutable object can be changed after it is
created (e.g., lists, dictionaries), while an immutable object cannot be
modified after its creation (e.g., tuples, strings).
An example of a mutable object from the given options is [1,
2] (list) and {1:1, 2:2} (dictionary).
An example of an immutable object from the options is '123'
(string) and (1, 2) (tuple).
Question 23
Answer
- Arithmetic Operators — +, -
- Relational Operators — >, ==
Question 24
Answer
- (a) L1.count(4)
OR
(b) L1.sort() - L1.extend(L2)
OR
(b) L2.reverse()
Question 25
Answer
W#, W#s#
Minimum and maximum possible values
of the variable b is 1, 6.
Question 26
Answer
def swap_first_last(tup) # Error 1
if len(tup) < 2:
return tup # Error 2
new_tup =
(tup[-1],) + tup[1:-1]
+
(tup[0]) # Error 3
return new_tup
result = swap_first_last((1,
2,
3,
4))
print("Swapped tuple: " result) # Error 4
Error 1 — The function header is missing a colon (:) at the
end, which is required to define a function in Python.
Error 2 — The return statement
needs to be indented because it is the part of the if block.
Error 3 — Comma should be added
after tup[0] to ensure it is treated as a tuple. Without the
comma, (tup[0]) is treated as an integer.
Error 4 — Comma should be added in the print statement to
properly separate the string from the variable.
The corrected code is:
def swap_first_last(tup):
if len(tup) < 2:
return tup
new_tup =
(tup[-1],) + tup[1:-1]
+
(tup[0],)
return new_tup
result = swap_first_last((1,
2,
3,
4))
print("Swapped tuple: ", result)
Question 27-I(a)
Answer
To prevent duplicate values in a
table column while allowing NULL values, we should use the UNIQUE constraint.
The UNIQUE constraint ensures that all values in the specified
column are different, but it permits multiple NULLs since NULL is considered
distinct from any other value.
Question 27-I(b)
Answer
To ensure that NULL values are not
allowed in a table column while allowing duplicate values, we should use
the NOT NULL constraint. The NOT NULL constraint
ensures that every entry in the specified column must have a value (i.e., it
cannot be NULL), but it allows duplicate values.
Question 27-II(a)
Answer
ALTER TABLE MOBILE
DROP
PRIMARY KEY;
Question 27-II(b)
Answer
ALTER TABLE MOBILE
ADD
PRIMARY KEY
(M_ID);
Question 28(a)
Answer
Advantage
Ease of service — Network extension is easy.
Disadvantage
Central node dependency — Failure of switch/hub results in
failure of the network.
Question 28(b)
Answer
SMTP stands for Simple Mail Transfer Protocol.
It is the standard protocol for sending emails across the
Internet.
Section C (3 Marks Each)
Question 29(a)
Answer
Suppose the file "Emails.txt" contains the
following text:
jagan@cmail.com
aliya@gmail.com
def display_words():
file =
open("Emails.txt", 'r')
content =
file.read()
words =
content.split()
for word in
words:
if '@cmail' in word:
print(word, end = ' ')
file.close()
display_words()
Output
jagan@cmail.com
Question 29(b)
Answer
Suppose the file "Words.txt" contains the
following text:
The quick brown fox jumps over the lazy dog and runs swiftly
through the forest
def display():
file =
open("Words.txt", 'r')
content =
file.read()
words =
content.split()
for word in
words:
if len(word) > 5:
print(word, end = ' ')
file.close()
display()
Output
swiftly through forest
Question 30(a)
Answer
1.
def push_book(BooksStack, new_book):
BooksStack.append(new_book)
2.
def pop_book(BooksStack):
if not BooksStack:
print("Underflow")
else:
return(BookStack.pop())
3.
def peep(BooksStack):
if not BooksStack:
print("None")
else:
print(BookStack[-1])
Question 30(b)
Answer
def push_even(N):
EvenNumbers = []
for num in
N:
if num %
2 == 0:
EvenNumbers.append(num)
return EvenNumbers
VALUES =
[]
for i in range(5):
VALUES.append(int(input("Enter an integer:
")))
EvenNumbers =
push_even(VALUES)
def pop_even():
if not EvenNumbers:
print("Underflow")
else:
print(EvenNumbers.pop())
pop_even()
def Disp_even():
if not EvenNumbers:
print("None")
else:
print(EvenNumbers[-1])
Disp_even()
Output
Enter an integer: 10
Enter an integer: 5
Enter an integer: 8
Enter an integer: 3
Enter an integer: 12
12
8
Question 31(a)
Answer
Output
15@
7@
9@
Question 31(b)
Answer
Output
1 #2 #3 #
1 #2 #3 #
1 #
Section D (4 Marks Each)
Question 32
Answer
(A)
(I)
SELECT Product, SUM(Quantity)
FROM ORDERS
GROUP BY Product
HAVING SUM(Quantity) >= 5;
(II)
SELECT *
FROM ORDERS
ORDER BY Price DESC;
(III)
SELECT DISTINCT C_Name
FROM ORDERS;
(IV)
SELECT SUM(Price) AS Total_Price
FROM ORDERS
WHERE Quantity IS NULL;
OR
(B)
(I) Select c_name, sum(quantity) as
total_quantity from orders group by c_name;
Output
+----------+----------------+
| c_name | total_quantity
|
+----------+----------------+
| Jitendra |
1 |
| Mustafa | 2 |
| Dhwani | 1 |
+----------+----------------+
(II) Select * from orders where product like
'%phone%';
Output
+------+---------+------------+----------+-------+
| O_Id | C_Name |
Product | Quantity | Price |
+------+---------+------------+----------+-------+
| 1002 | Mustafa | Smartphone | 2 | 10000 |
| 1003 | Dhwani |
Headphone | 1 |
1500 |
+------+---------+------------+----------+-------+
(III) Select o_id, c_name, product, quantity,
price from orders where price between 1500 and 12000;
Output
+------+----------+------------+----------+-------+
| o_id | c_name |
product | quantity | price |
+------+----------+------------+----------+-------+
| 1001 | Jitendra | Laptop
| 1 | 12000 |
| 1002 | Mustafa |
Smartphone | 2 | 10000 |
| 1003 | Dhwani |
Headphone | 1 |
1500 |
+------+----------+------------+----------+-------+
(IV) Select max(price) from orders;
Output
+------------+
| max(price) |
+------------+
| 12000 |
+------------+
Question 33
Answer
Let the "Happiness.csv" file contain the following
data:
Signiland, 5673000, 5000, 3426
Happiland, 4500000, 4000, 3200
Joyland, 8000000, 6000, 5000
Cheerland, 3000000, 3500, 2500
(I)
def show():
file =
open("Happiness.csv",'r')
records=csv.reader(file)
for i in
records:
if int(i[1])>5000000:
print(i)
file.close()
Output
['Signiland', '5673000', '5000', '3426']
['Joyland', '8000000', '6000', '5000']
(II)
def Count_records():
f =
open("Happiness.csv",'r')
records=csv.reader(f)
count=0
for i in
records:
count+=1
print(count)
f.close()
Output
4
Question 34
Answer
(I)
SELECT *
FROM
FACULTY, COURSES
WHERE Salary < 12000 AND FACULTY.F_ID = COURSES.F_ID;
(II)
SELECT *
FROM COURSES
WHERE Fees BETWEEN 20000 AND 50000;
(III)
UPDATE COURSES
SET Fees = Fees + 500
WHERE CName LIKE '%Computer%';
(IV)
(A)
SELECT FName, LName
FROM FACULTY, COURSES
WHERE CName = 'System Design' AND
FACULTY.F_ID =
COURSES.F_ID;
OR
(B)
SELECT *
FROM FACULTY, COURSES;
Question 35
Answer
import mysql.connector
def AddAndDisplay():
db =
mysql.connector.connect(
host="localhost",
user="root",
password="Pencil",
database="ITEMDB"
)
cursor =
db.cursor()
item_no =
int(input("Enter Item Number: "))
item_name = input("Enter Item Name: ")
price =
float(input("Enter Price: "))
qty =
int(input("Enter Quantity: "))
insert_query = "INSERT INTO STATIONERY
VALUES ({}, {}, {}, {})"
insert_query = insert_query.format(item_no, item_name,
price, qty)
cursor.execute(insert_query)
db.commit()
select_query = "SELECT * FROM
STATIONERY WHERE price > 120"
cursor.execute(select_query)
results =
cursor.fetchall()
for record in
results:
print(record)
AddAndDisplay()
Section E (5 Marks Each)
Question 36
Answer
(I)
import pickle
def input_candidates():
candidates = []
n =
int(input("Enter the number of candidates you want to add: "))
for i in
range(n):
candidate_id = int(input("Enter Candidate ID:
"))
candidate_name = input("Enter Candidate Name:
")
designation = input("Enter Designation:
")
experience = float(input("Enter Experience (in
years): "))
candidates.append([candidate_id, candidate_name, designation,
experience])
return candidates
candidates_list
= input_candidates()
def append_candidate_data(candidates):
with open('candidates.bin', 'ab') as file:
for candidate in candidates:
pickle.dump(candidate,
file)
print("Candidate data appended
successfully.")
append_candidate_data(candidates_list)
(II)
import pickle
def update_senior_manager():
updated_candidates = []
try:
with open('candidates.bin', 'rb') as file:
while True:
try:
candidate = pickle.load(file)
if candidate[3] > 10: # If experience > 10 years
candidate[2] = 'Senior Manager'
updated_candidates.append(candidate)
except EOFError:
break # End of file reached
except FileNotFoundError:
print("No candidate data
found. Please add candidates first.")
return
with open('candidates.bin', 'wb') as file:
for candidate in updated_candidates:
pickle.dump(candidate,
file)
print("Candidates updated to
Senior Manager where applicable.")
update_senior_manager()
(III)
import pickle
def display_non_senior_managers():
try:
with open('candidates.bin', 'rb') as file:
while True:
try:
candidate = pickle.load(file)
if candidate[2] != 'Senior Manager': # Check if not Senior Manager
print(f"Candidate ID: {candidate[0]}")
print(f"Candidate Name: {candidate[1]}")
print(f"Designation: {candidate[2]}")
print(f"Experience: {candidate[3]}")
print("--------------------")
except EOFError:
break # End of file reached
except FileNotFoundError:
print("No candidate data
found. Please add candidates first.")
display_non_senior_managers()
Question 37
Answer
(I) The most appropriate location for the server inside the
MUMBAI campus is ADMIN block because it has maximum number of computers.
(II) Switch is used to connect all the computers within each
building.
(III) Cable layout connecting various buildings within the
MUMBAI campus is shown below:
For the most efficient data transfer over the network,
optical fiber cables are recommended.
(IV) There is no requirement for a repeater as optical fiber
cables can transmit signals over longer distances.
(V)
(A) Video Conferencing
Video conferencing is recommended for live communication
between the Mumbai and Delhi offices due to its real-time interaction and
flexibility making it ideal for effective discussions across distant locations.
OR
(B) The type of network that will be set up among the
computers connected in the MUMBAI campus is LAN (Local Area Network).
No comments:
Post a Comment