0% found this document useful (0 votes)
38 views10 pages

Class XII CS MS Set-1

Hi

Uploaded by

xyz2007sk
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views10 pages

Class XII CS MS Set-1

Hi

Uploaded by

xyz2007sk
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

नवोदय ववद्यालय सविवि

NAVODAYA VIDYALAYA SAMITI


PRE BOARD-1 - 2024-25 SET -1
ANSWER KEY
CLASS : XII COMPUTER SCIENCE (083)
Time allowed: 3 Hours Maximum Marks: 70
Q. Marks
SECTION A (1 Mark each)
No.
1 False 1
2 a) CBSE 1
CBSE
CBSE
CBSE
3 b) Division operation performed when divisor is zero (division by 1
zero)
4 a) 1
[11, 72, 53, '2', '4']
[11, 72, 53, '2', '4']
5 iH 1
6 c) d = { [1] : 'NVS' , [2] : 'JNV' , [3] : 'NLI' } 1

7 d) d = dict.fromkeys( [ 'model' , 'year' ] , [ 'TATA' , 2024 ] ) 1


print(d)

8 d) Program will end in Error as exception not handled 1


9 a) 20$50$50$ 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

14 b) Display details of employees in ascending order of designation and 1


arranges data with same designations in descending order of ename.

15 b) An exact match is not possible in a SELECT statement. 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' ) )

26 def count_character_occurrences(input_string): ½ mark


char_count = {} for each
for char in input_string : # added missing : error
if char in char_count:
char_count[char] += 1 # ( ) replaced with [ ]
else: #elif changed to else
char_count[char] = 1
total_unique = len(char_count) #changed indentation
return (char_count, total_unique)

input_string = input("Enter the string: ")


result = count_character_occurrences(input_string)
print(result)
27 1 mark
I) each

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

Static Web Pages Dynamic Web Pages


The content on Static web pages Dynamic web page is
remains the same unless behavioral. The content of pages
someone explicitly makes any is capable of differing for
changes different visitors. It keeps
changing with time and other
parameters.
Content and information rarely The content and information
change on a static web page change frequently on a dynamic
web page.
Static web pages take a very These web pages take longer to
short time to load as compared load as compared to the static
to the dynamic web pages. ones.
static web pages generally do not The dynamic web pages use
use databases databases

<any two differences 1 mark each>

OR
b)
URL - Uniform Resource Locator (1/2 mark for expansion)

Format of URL have 3 parts


Format: protocol://domain//path
Example:
https://cbseacademic.nic.in/web_material/Manuals/NEP.php
in the example,
Protocol is https
Domain is cbseacademic.nic.in
Path is web_material/Manuals/NEP.php

(1 mark for parts of URL, ½ mark for example)

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)

30 1 ½ mark for correct implementation of Push_link() function 3


1 ½ mark for correct implementation of Pop_link() function

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

33 2 marks for correct implementation of each function. 4


Sample program given
import csv

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)

34 a) alter table ITEM add Discount int; 1 mark


b) update ITEM set Price = 7500 where Itemname =’Sofa’; each
c) select Itemname from ITEM where price is NULL;
d)
i) select Itemname from ITEM where Stockdate < ‘2020-12-31’;
OR
ii) select max(Price) from ITEM where Type = ‘Kitchen’;

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()

(½ mark for correctly creating the connection and cursor object)


(½ mark for correctly inputting the data)
(½ mark for correct creation of query)
(½ mark for correct executing query with commit)

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()

(½ mark for correctly creating the connection and cursor object)


(½ mark for correctly inputting the data)
(½ mark for correct creation of query)
(½ mark for correctly displaying the data)

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
}

with open('stock.dat', 'ab') as file:


pickle.dump(stock_record, file)
print("Stock added successfully.")

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.")

# Write updated records back to the binary file


if records_updated:
with open('stock.dat', 'wb') as file:
for record in updated_records:
pickle.dump(record, file)

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.

III) Switch / Hub


IV) Ethernet cables.

V) a)

b) Yes, repeater is needed between Work Office and Front Office as


the distance between the office is greater than 100 m.

Page 10 of 10

You might also like