Class XII CS MS Set-1
Class XII CS MS Set-1
10 b) fun( p = -1 , q = 2 , 1 ) 1
11 True 1
12 a) Number of attributes in the relation. 1
13 b) Circuit switching 1
16 d) 5,3 1
17 a) MAX(DOJ) 1
18 b) Downloading emails from a server to a local client 1
19 b) Increased bandwidth due to reduced collisions 1
20 (A) Both A and R are true and R is the correct explanation for A 1
21 (C) A is true, but R is false 1
Q. SECTION B (2 Marks each) Marks
Page 1 of 10
No.
22 Implicit type conversion Explicit type conversion 2 marks
This is automatically performed This is performed by the (½ marks
by Python when it converts one programmer using built-in for each
data type to another without any functions to convert one data definition
explicit instruction from the type to another. and ½
programmer. marks for
This usually occurs when It requires a specific function call each
combining different data types to initiate the conversion example)
in an operation
Example: When an integer is Example: Using functions like
added to a float, Python int(), float(), str(), etc., to convert
implicitly converts the integer to data types.
a float to perform the operation.
num_int = 5 num_str = "10"
num_float = 3.2 num_int = int(num_str) #
result = num_int + num_float Converting string to integer
# num_int is converted to float print(num_int) # Output: 10
print(result) # Output: 8.2
23 augmented assignment operators (½ x 4 = 2
a) *= d) %= Marks for
each
relational operators correct
b) != c) >= operator)
24 a) 5.5 b) 6 1 mark
each
25 I) 1 mark
a) capital.popitem() each
OR
b) capital.pop(‘Assam’)
II)
a) capital.update( {'Rajasthan' : 'Jaipur'} )
OR
b) print( capital.setdefault( 'Kerala' ) )
Page 2 of 10
a) UNIQUE
OR
b) CHECK constraint
II)
a) ALTER TABLE SALESMAN ADD EMAILID VARCHAR(50)
AFTER SALARY;
OR
b) ALTER TABLE SALESMAN DROP COMMISSION;
28 a) 2
OR
b)
URL - Uniform Resource Locator (1/2 mark for expansion)
Q. Marks
SECTION C (3 Marks each)
No.
29 a) 3
Page 3 of 10
def extract_unique_name( ): # function heading ½ mark
with open('Names.txt', 'r') as file: # file opening ½ mark
content = file.read()
words = content.split(‘\n’)
# reading & splitting words ½ mark
unique_words = []
for word in words:
if word.lower() not in unique_words:
unique_words.append(word.lower())
# finding unique name ½ mark
unique_words.sort() # sorting ½ mark
print(unique_words) # printing output ½ mark
extract_unique_name( )
OR
def find_longest_word(filename):
with open(filename, 'r') as file:
content = file.read()
words = content.split('\n')
longest_word = ""
for word in words:
if len(word) > len(longest_word):
longest_word = word
print("The longest word is: ",longest_word)
print("length of word: ",len(longest_word))
find_longest_word("words.txt")
(½ marks each for function header , file opening, reading words,
traversing words, finding longest word, printing result)
stack = []
cur_page =""
def Push_link():
global stack,cur_page
link = input("Enter the url: ")
if cur_page == "":
cur_page = link
else:
stack.append(cur_page)
cur_page = link
def Pop_link():
global stack,cur_page
if len(stack) == 0 and cur_page != "":
Page 4 of 10
cur_page = ""
print("Blank page")
elif len(stack) == 0 and cur_page == "":
print("No more pages")
else:
cur_page = stack.pop()
print(cur_page)
while True:
print("1. Click")
print("2. Go Back")
print("3. Close")
choice = input("Enter your choice: ")
if choice == '1':
Push_link()
elif choice == '2':
Pop_link()
elif choice == '3':
break
else:
print("Invalid Choice")
OR
1 ½ mark for correct implementation of push_even( EVENSTRINGS,
N) function
1 ½ mark for correct implementation of pop_even( EVENSTRINGS)
function
def push_even(EVENSTRINGS,N):
for string in N:
if len(string) % 2 == 0:
EVENSTRINGS.append(string)
print("stack: ",EVENSTRINGS)
def pop_even(EVENSTRINGS) :
count = 0
while EVENSTRINGS:
string = EVENSTRINGS.pop()
print(string)
if len(string) == 4:
count += 1
print("Strings with length 4: ",count)
car_names =
["Toyota","Honda","Ford","Nissan","BMW","Audi","Maruti"]
EVENSTRINGS = []
push_even(EVENSTRINGS,car_names)
pop_even(EVENSTRINGS)
31 a)
bkilueberrwi
Page 5 of 10
b)
-8
-12
-5
Q. Marks
SECTION D (4 Marks each)
No.
32 I) 1 mark
a) SELECT s.supplier_name FROM customer c , supplier s WHERE each
c.sid = s.sid AND c.city = ‘Mumbai’;
b) SELECT city, COUNT(*) as ‘No of customers’ FROM customer
GROUP BY city;
c) SELECT * FROM customer order by customer_name;
d) SELECT s.supplier_name, COUNT(c.cid) FROM customer c ,
supplier s WHERE c.sid = s.sid group by s.supplier_name HAVING
COUNT(c.cid) >1;
II)
a)
customer_name supplier_name
Aarav Patel ABC Traders
Priya Sharma DEF Exports
Rohan Gupta ABC Traders
Neha Reddy XYZ Industries
Vikram Singh GHI Supplies
b)
sid count(cid)
1 2
3 1
2 2
4 1
c)
customer_name city
Aarav Patel Mumbai
Priya Sharma Bengaluru
d)
supplier_name
ABC Traders
XYZ Industries
Page 6 of 10
def add_data(filename):
student_id = input("Enter student ID: ")
name = input("Enter student name: ")
class_ = input("Enter class: ")
div = input("Enter division: ")
subject = input("Enter subject: ")
score = float(input("Enter score: "))
grade_level = input("Enter grade level: ")
data = [student_id, name, class_, div, subject, score, grade_level]
with open(filename, mode='a', newline='') as file:
writer = csv.writer(file)
writer.writerow(data)
def display_data(filename):
subject = input("Enter subject name: ")
cls = input("Enter class: ")
div = input("Enter division: ")
count = 0
sum = 0
with open(filename, mode='r') as file:
reader = csv.reader(file)
for row in reader:
if row[2] == cls and row[3] == div and row[4] == subject:
sum = sum + float(row[5])
count +=1
print("Average score of subject is :",sum/count)
35 2 mark
import mysql.connector as mq each
def Add_pet():
mydb=mq.connect( host="localhost", user="root",
passwd="Tiger", database = 'PETDATA')
mycursor = mydb.cursor()
pet = int(input("enter the pet ID: "))
name = input("enter the pet name: ")
breed = input("enter the Breed: ")
life = int(input("enter the Life span: "))
price = int(input("enter the Price: "))
dis = int(input("enter the Discount: "))
sql = "insert into MYPETS
values({},'{}','{}',{},{},{})".format(pet,name,breed,life,price,dis)
Page 7 of 10
mycursor.execute(sql)
mydb.commit()
mydb.close()
def Display_petdetails():
mydb=mq.connect( host="localhost", user="root",
passwd="Tiger", database = 'PETDATA')
mycursor = mydb.cursor()
pet = input("enter the pet name: ")
mycursor.execute( "Select * from employee where Pet_name =
{}",format(pet))
result = mycursor.fetchall()
for i in result:
print(i)
mydb.close()
Q. Marks
SECTION E (5 Marks each)
No.
36 ( 2 marks for correct implementation of ADD_STOCK() function ) 2 + 2 +1
( 2 marks for correct implementation of UPDATE_STOCK() function)
( 1 mark for correct implementation of DISPLAY_STOCK() function )
Menu driven program for calling the functions is not necessary.
Implementation of function only is needed.
import pickle
def ADD_STOCK():
date_of_arrival = input("Enter the date of arrival (YYYY-MM-DD):
")
item_name = input("Enter item name: ")
quantity = int(input("Enter quantity: "))
total_amount = float(input("Enter total amount: "))
stock_record = {
'date_of_arrival': date_of_arrival,
'item_name': item_name,
'quantity_received': quantity,
'total_amount': total_amount,
'balance_quantity': quantity,
'last_date_of_consumption': date_of_arrival
Page 8 of 10
}
def UPDATE_STOCK():
item_name = input("Enter the item name to update: ")
quantity_consumed = int(input("Enter quantity consumed: "))
date_consumption = input("Enter the date of consumption (YYYY-
MM-DD): ")
records_updated = False
updated_records = []
try:
with open('stock.dat', 'rb') as file:
while True:
stock_record = pickle.load(file)
if stock_record['item_name'] == item_name:
if stock_record['balance_quantity'] >=
quantity_consumed:
stock_record['balance_quantity'] -= quantity_consumed
stock_record['last_date_of_consumption'] =
date_consumption
records_updated = True
print(f"Updated record for {item_name}:")
print(stock_record)
else:
print("Insufficient balance quantity for ",item_name)
updated_records.append(stock_record)
except EOFError:
pass
except FileNotFoundError:
print("No stock records found.")
def DISPLAY_STOCK():
print("Current stock records (Item Name and Balance Quantity):")
try:
with open('stock.dat', 'rb') as file:
while True:
stock_record = pickle.load(file)
print(f"Item Name: {stock_record['item_name']}, Balance
Page 9 of 10
Quantity: {stock_record['balance_quantity']}")
except EOFError:
pass
except FileNotFoundError:
print("No stock records found.")
while True:
print("\nMenu:")
print("1. Add Stock")
print("2. Update Stock")
print("3. Display Stock")
print("4. Exit")
choice = input("Choose an option: ")
if choice == '1':
ADD_STOCK()
elif choice == '2':
UPDATE_STOCK()
elif choice == '3':
DISPLAY_STOCK()
elif choice == '4':
break
else:
print("Invalid choice. Please try again.")
37 1 mark for each question 5 marks
I) (a) Back Office and Work Office - LAN
(b) Back Office and South Office – WAN
II) Work Office, because work office contains the most number of
computers among other offices.
V) a)
Page 10 of 10