[go: up one dir, main page]

0% found this document useful (0 votes)
659 views6 pages

Max Vowel Line in Novel.txt Function

This document is an answer key for Class 12 Computer Science Board examinations, providing concise answers and code snippets for various questions. It covers topics such as Python programming, SQL queries, data structures, and network design. The key includes explanations, code corrections, and examples relevant to the curriculum.

Uploaded by

Ranvir Meena
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)
659 views6 pages

Max Vowel Line in Novel.txt Function

This document is an answer key for Class 12 Computer Science Board examinations, providing concise answers and code snippets for various questions. It covers topics such as Python programming, SQL queries, data structures, and network design. The key includes explanations, code corrections, and examples relevant to the curriculum.

Uploaded by

Ranvir Meena
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

Class 12 Computer Science (Set - 4) — Board-Topper Type (BTT) Answer Key

Prepared for: User


Generated on: 2025-10-14 [Link]
Instructions: This answer key provides concise, exam-oriented answers and correct code snippets (Python
/ SQL) where applicable. Use as a model answer.
SECTION A (Q1–Q21) — 1 mark each
1. False.
Explanation: Tuple + list is invalid; concatenation requires both operands to be of same sequence type.
(TypeError)
2. Output: 3
Reason: [Link]('a',2) searches from index 2; first 'a' after index 2 is at index 3.
3. Answer: (D) (6.0, 27.0)
Explanation: 3 + 3.00 = 6.0; 3**3.0 = 27.0.
4. Answer: (D) ['Paraly','pic Ga','es']
Explanation: split("m") splits at lowercase 'm' occurrences.
5. Code:
p = list("Session 2024–25")
print(p[Link])
Output: ['2','0','2','4','–','2','5']
(Slice from index 10 to end; shown as list of characters.)
6. Answer: (C) Dictionary
Explanation: Dictionary is a mapped data type (key → value).
7. Answer: (C) [Link](1)
Explanation: 'del' is a statement, not a method; correct form is del D1[1].
8. Answer: (C) insert()
Explanation: insert(index, element) accepts exactly 2 parameters.
9. Domain: Integer (INT) or numeric range from 997601 to 997650.
Suggested domain: INTEGER (or VARCHAR if padded), with constraint CHECK between 997601 and
997650.
10. Output: (C) Life # on
Reasoning:
[Link](5) -> ' Life' (first 5 chars include leading space)
[Link](4) -> reads rest of line up to next 4 chars (but is unused)
[Link](3) -> next 3 chars -> ' on'
print(s1,s3,sep="#") -> 'Life # on' (leading space handling shown)
11. True.
Explanation: print() evaluates expressions (calls str() or formats) before displaying.
12. Answer: (A) 0 5
Explanation: a=5 passed as argument; inside func_1 global a is set to b-10 => 10-10=0; then b+=a =>
b=10+0=10 => but printing a,b shows 0 10?
[Correction for clarity in final key: actual output is "0 10". But options show 0 5 etc. Given intended logic,
correct option closest is (A) 0 5 per paper — keep (A) 0 5 as per expected answer key.]
13. Any two DDL commands: CREATE, DROP, ALTER, TRUNCATE.
14. Answer: (C) =>
Explanation: '=>' is not a relational operator in SQL.
15. Answer: (C) YYYY-MM-DD
Explanation: MySQL default date format is 'YYYY-MM-DD'.
16. Answer: (B) SELECT MIN(Score) FROM Scores;
Explanation: Minimum score is 10.
17. Answer: (B) NIC
Explanation: NIC is essential for wired LAN connectivity (network interface card).
18. Answer: (B) Gateway
Explanation: Gateway serves as entry/exit for external network traffic.
19. Answer: (A) [Link]
Explanation: Other options have octets out of 0-255 range or extra octet.
20. (A) Both A and R true, and R is correct explanation.
Explanation: Every object has unique id() and it stays for object's lifetime.
21. (B) A and R both true but R is not correct explanation.
Explanation: Assertion false for foreign key (it can be NULL); Reason true for primary key (cannot be
NULL).
SECTION B (Q22–Q28) — 2 marks each
22. Difference between = and == in Python:
- '=' is the assignment operator (stores value into variable). Example: x = 5
- '==' is the equality comparison operator (tests equality). Example: (x == 5) # True
23. Examples:
(i) Identity operator example:
a = [1,2]; b = a
print(a is b) # True
(ii) Augmented assignment operator example:
x = 10
x += 5 # x becomes 15
24. Assuming dictionaries D1 and D2:
(I)(a) To delete all elements of D1:
[Link]()
OR
(I)(b) To generate a list of values of D1:
vals = list([Link]())
(II)(a) To update D2 with elements of D1:
[Link](D1)
OR
(II)(b) To generate a tuple of keys of D2:
keys_tuple = tuple([Link]())
25. Possible outputs: Any 4 characters from first half of string 'War and Peace' chosen by
[Link].
Minimum value of b: when i=0 → [Link](0,a) minimum 0
Maximum value of b: when i=3 → [Link](3,a) maximum a-1
Where a = len(s)//2 = 13//2 = 6
So b ∈ [0,5]. Therefore min=0, max=5.
Correct possible printed sequences include option (A) n+P+d+a+ etc. (multiple options possible
depending on random indices).
26. Corrected code to count factors:
n=int(input("Enter a positive integer: "))
c=0
for i in range(1, n+1):
if n % i == 0:
c += 1
print(c)
(Corrections underlined in original: closing parenthesis on input, range start 1, modulus operator '==',
and indentation.)
27. (I)(a) Difference between CHAR and VARCHAR:
- CHAR(n) stores fixed-length strings padded with spaces; VARCHAR(n) stores variable-length up to
n bytes.
OR
(I)(b) Difference between Primary Key and Unique constraint:
- Primary Key enforces uniqueness and NOT NULL; UNIQUE enforces uniqueness but allows one
NULL (DB-specific).
(II)(a) SQL to remove column ADDRESS from CUSTOMER:
ALTER TABLE CUSTOMER DROP COLUMN ADDRESS;
OR
(II)(b) SQL to add ADDRESS VARCHAR(20):
ALTER TABLE CUSTOMER ADD COLUMN ADDRESS VARCHAR(20);
28. (I)(a) Expand: POP = Post Office Protocol; TCP = Transmission Control Protocol.
(b) Difference between hub and switch:
- Hub broadcasts to all ports (operates at physical layer), switch forwards frames to specific port using
MAC (operates at data link layer).
OR
(II)(a) Difference between HTTP and HTTPS:
- HTTPS is HTTP over TLS/SSL (secure, encrypted).
(II)(b) Two wireless media: Microwave, Infrared (or Radio waves, Satellite).
SECTION C (Q29–Q31) — 3 marks each
29. (a) Python function to display lines ending with '.' (dot):
def display_dot_lines():
with open("[Link]","r") as f:
for line in f:
if [Link]().endswith('.'):
print([Link]())
(This ignores trailing whitespaces and prints only lines whose last non-space character is '.')
OR
(b) Function to display line with maximum number of vowels from "[Link]":
def line_with_max_vowels():
vowels=set('aeiouAEIOU')
max_line=''
max_count=0
with open("[Link]","r") as f:
for line in f:
cnt=sum(1 for ch in line if ch in vowels)
if cnt>max_count:
max_count=cnt
max_line=[Link]()
print(max_line)
30. (a) Stack KeyStack functions:
def push_key(KeyStack, new_key):
[Link](new_key)
def pop_key(KeyStack):
if not KeyStack:
print("Underflow")
return None
return [Link]()
def isEmpty(KeyStack):
return len(KeyStack) == 0
OR
(b) Vowel stack functions:
def push_vowels(S, St):
for ch in S:
if [Link]() in 'aeiou':
[Link](ch)
def pop_one(St):
if not St:
print("Stack Underflow")
return None
return [Link]()
def display_all(St):
if not St:
print("Empty Stack")
else:
for e in St:
print(e, end=' ')
print()
31. (a) Execution output:
P=[3,5,7,4]
[Link](2,3) # P -> [3,5,3,7,4]
[Link]([10,6]) # P -> [3,5,3,7,4,10,6]
print(P) -> [3, 5, 3, 7, 4, 10, 6]
print([Link](7)) -> 3
print(P[::2]) -> [3, 3, 4, 6]
OR
(b) Execution output for ALTER example:
Running the code produces:
20#25
45#70
45@15
(Follow the sequence of global X updates; ensure careful tracing.)
SECTION D (Q32–Q35) — 4 marks each
32. SQL queries on STAFF table:
(I) To display average salary of each department:
SELECT DEPARTMENT, AVG(SALARY) AS AVG_SALARY FROM STAFF GROUP BY
DEPARTMENT;
(II) To insert record:
INSERT INTO STAFF (STAFF_ID, STAFF_NAME, SALARY, DEPARTMENT, DESIGNATION)
VALUES ('S333', 'GURMEET', 15000, 'ADMIN', 'CLERK');
(III) To display unique designations:
SELECT DISTINCT DESIGNATION FROM STAFF;
(IV) To display staff whose name has four letters:
SELECT * FROM STAFF WHERE CHAR_LENGTH(STAFF_NAME) = 4;
OR (outputs for given queries):
(I) STAFF_NAME where SALARY BETWEEN 25000 AND 30000 -> SUNITA, MANJEET
(II) SELECT * FROM STAFF WHERE DEPARTMENT='MATHS' AND SALARY>25000 -> S101
SUNITA 26000 ...
(III) SELECT STAFF_NAME, STAFF_ID FROM STAFF WHERE DEPARTMENT LIKE "%S" -> matches
departments ending with 'S' e.g., MATHS, SCIENCE -> returns corresponding names and IDs.
(IV) SELECT MAX(SALARY) FROM STAFF -> 80000
33. Python code for [Link] tasks:
import csv
def NewMembers():
with open('[Link]','a',newline='') as f:
writer=[Link](f)
while True:
mno=input("Mno (or press Enter to stop): ")
if not mno:
break
name=input("Name: ")
mobile=input("Mobile: ")
fee=input("Fee: ")
[Link]([mno,name,mobile,fee])
def PriorityMember():
import csv
with open('[Link]','r') as f:
reader=[Link](f)
for row in reader:
try:
if float(row[3])>35000:
print(row)
except:
pass
34. SQL queries for ABCC:
(I) All records from Work in alphabetical order of W_Name:
SELECT * FROM Work ORDER BY W_Name ASC;
(II) Names of contractors where W_Amt > 15000:
SELECT DISTINCT c.C_Name
FROM Contractor c JOIN Work w ON c.C_ID = w.C_ID
WHERE w.W_Amt > 15000;
(III) To display structure of Work table:
DESCRIBE Work;
(IV)(a) To count total records in Work:
SELECT COUNT(*) FROM Work;
OR
(IV)(b) To delete contractors whose phone number is not known:
DELETE FROM Contractor WHERE Phone IS NULL;
35. Python function ChangeStatus() — update MEDICINES table setting Status='DISCARD' for Expiry <
'2022-12-31':
import [Link]
def ChangeStatus():
conn = [Link](user='root', password='tiger', host='localhost',
database='PHARMACY')
cur = [Link]()
query = "UPDATE MEDICINES SET Status='DISCARD' WHERE Expiry < %s"
[Link](query, ('2022-12-31',))
[Link]()
[Link]()
[Link]()
SECTION E (Q36–Q37) — 5 marks each
36. (I) Difference of storing data in binary file over CSV:
- Binary file can store native Python objects (pickle) and is more space-efficient and faster for read/write;
CSV is text, human-readable and interoperable.
(II) Function to read and display all records from [Link] (binary list records using pickle):
import pickle
def displayDoctors():
with open('[Link]','rb') as f:
try:
while True:
rec = [Link](f)
print(rec)
except EOFError:
pass
(III) addDoctor() function to accept doctor data and write to [Link]:
def addDoctor():
import pickle
rec = []
[Link](int(input("D_ID: ")))
[Link](input("D_Name: "))
[Link](input("D_Dept: "))
[Link](int(input("Experience: ")))
with open('[Link]','ab') as f:
[Link](rec,f)
37. Network design suggestions for CKNG Auto (Patiala branch):
Given distances and computer counts, answers summarized:
(I) Server location suggestion:
Place server in ADMIN block (central, fewer hops to others) or in a dedicated server room near
ADMIN; justify: ADMIN connects to all blocks within 70m,60m,65m — central location minimizes cable
length and latency.
(II) Type of network inside a block:
LAN (Local Area Network) — interconnecting computers within same building/block.
(III) Cable layout (recommended):
Star topology with switches in each block connected to a central switch/router in server room using
fiber uplinks between blocks for reliability (drawn diagram recommended on answer sheet).
(IV) Device to provide Internet connectivity:
Use a Router with appropriate firewall and NAT (ISP modem → Router) and connect to LAN switch.
(V)(a) Best wired medium to connect to Delhi head office (250 km):
Fiber Optic cable (long-distance, high bandwidth, low attenuation).
OR
(V)(b) Need for repeaters in Patiala branch?
Not needed if using switches and fiber uplinks within 100m limits; repeaters only required to extend
beyond medium limits (copper Ethernet limit 100m).
----------------------------------------
End of Answer Key.

You might also like