Grade12 Computer Set1 AK Sahodaya
Grade12 Computer Set1 AK Sahodaya
ASSOCIATION
ANSWER KEY
SECTION - A
SL. ANSWER M
NO
1 True 1
2 d) Drop 1
3 c) 6.3 1
4 15 1
7 b. del D1["Orange"] 1
8 Show tables; 1
11 WAN 1
12 Primary key 1
1
13 False 1
15 b) Master-Slave network 1
16 a, a+ modes 1
17 a) 1
18 a) 1
SECTION - B
19 i) 1+1=2
a. SMTP – Simple Mail Transfer Protocol
b. PPP – Point to Point Protocol
ii) Telnet is used for remote connection
(OR)
i)
a. VOIP- Voice Over Internet Protocol
b. TCP – Transmission Control Protocol
ii)
PAN:
• It stands for Personal Area Network
• It spans over a few meters.
LAN:
• It stands for Local Area Network
• It spans over a few Km.
20 2
21 def count(CITIES): 2
for city_name, city_info in CITIES.items():
if len(city_name) > 5:
print(city_name.upper())
CITIES={1:"Delhi",2:"MUMBAI",3:"CHENNAI",4:"KOLKATA"}
count(CITIES)
2
function definition – ½ mark
checking the condition using length function – 1 mark
calling the function – ½ mark
(OR)
def length(words):
word_list = words.split()
word_lengths = [len(word) for word in word_list]
return word_lengths
ii) if message.endswith('.'):
else:
(Each 1 mark)
SECTION - C
26 ***** 3
3
27 i. Item code 3
ii. INSERT INTO FRESH (ITEMCODE, ITEMNAME, SCODE) VALUES
(1007,”GINGER”,15)
iii. ALTER TABLE FRESH ADD COLUMN PRICE FLOAT;
28 def display(file_path): 3
vowels = ['a', 'e', 'i', 'o', 'u']
try:
with open(file_path, 'r') as file:
for line in file:
line = line.strip() # Remove leading and trailing whitespaces
if line and line[0].lower() in vowels:
print(line)
except FileNotFoundError:
print(f"File '{file_path}' not found.")
except Exception as e:
print(f"An error occurred: {e}")
file_path = 'sample.txt'
display_lines_starting_with_vowel(file_path)
(OR)
def count_words(file_path):
try:
with open(file_path, 'r') as file:
text = file.read()
words = text.split()
num_words = len(words)
print(f"Number of words in '{file_path}': {num_words}")
except FileNotFoundError:
print(f"File '{file_path}' not found.")
except Exception as e:
print(f"An error occurred: {e}")
# Example usage:
file_path = 'sample.txt'
4
count_words(file_path)
i.
ii.
iii.
30 3
5
(Mark can be awarded to any program that does the Push and pop operation of a
stack)
SECTION - D
31 4
i.
ii.
iii.
iv.
32 4
SECTION- E
6
34 i) “w” mode in python represents, write which erases the previous data and the new data is 2+3
copied. The file pointer of write mode will be at the beginning. If the file is not present in
w mode the program will not give any error instead the file will be automatically created
with the name specified.
In append mode ‘a’, the data will not be erased, the new data will be copied to the end of
the file. The file pointer in append mode will be at the end.
ii)
import pickle
def copy(input_filename, output_filename):
total_records_copied = 0
try:
with open(input_filename, 'rb') as infile, open(output_filename, 'wb') as outfile:
for line in infile:
movie_name, movie_id, no_of_theatres = line.strip().split(', ')
if movie_name == "KAALAI":
outfile.write(f"{movie_name}, {movie_id}, {no_of_theatres}\n")
total_records_copied += 1
except FileNotFoundError:
print(f"File '{input_filename}' not found.")
except Exception as e:
print(f"An error occurred: {e)
return total_records_copied
input_file = "CINEMA.DAT"
output_file = "CINEMA_COPY.DAT"
records_copied = copy(input_file, output_file)
print(f"Total records copied: {records_copied}")
7
• By using seek() method, we can manipulate the reading position of the file’s
content
tell():
• used to return the position of the file cursor
• takes no parameter
• by using tell() method, we can get only the position of the file cursor.
ii)
import pickle
def findType(mtype):
try:
# Example usage:
mtype_to_find = "Action"
findType(mtype_to_find)
8
(OR)
a) c&&vVpP
b)
mycursor=con1.cursor()
mycursor.execute(“select * from student where marks>90”)
mycursor.fetchall()