PODAR WORLD SCHOOL, SHERKHI, VADODARA
Preboard – 1 (2022-23)
Computer Science (083)
STD – XII Set A Marks: 70
Date: Time: 03 Hours
General Instructions:
This question paper contains five sections, Section A to E.
All questions are compulsory.
Section A have 18 questions carrying 01 mark each.
Section B has 07 Very Short Answer type questions carrying 02 marks each.
Section C has 05 Short Answer type questions carrying 03 marks each.
Section D has 03 Long Answer type questions carrying 05 marks each.
Section E has 02 questions carrying 04 marks each. One internal choice is given in Q35
against part c only.
All programming questions are to be answered using Python Language only
Section A
Q1. Which of the following is not a valid keyword? 1
(a) for (b) while
(c) If (d) else
Q2. Which of the following is not a valid data type of Python 1
(a) Set (b) Dictionary
(c) Real (d) List
Q3. Identify the mutable data type from the following given options 1
(a) String (b) List
(c) Integer (d) Tuple
Q4. Python allows us to assign a single value to several variables simultaneously. Ex – 1
a=b=c=15. [True /False]
Q5. Read the following code carefully and predict the output: 1
a = {}
a[1] = 1
a['1'] = 2
a[1]= a[1]+1
count = 0
for i in a:
count += a[i]
print(count)
(a) Error (b) 4
1
(c) 3 (d) None of them
Q6. Consider the following expression: 1
False and not True or True or False
Output will be
(a) True (b) False
(c) None (d) Error
Q7. Which of the following network device is a broadcasting device 1
(a) Hub (b) Switch
(c) Gateway (d) Router
Q8. Which mode of file operation will generate error, if file is not existed 1
(a) Append Mode (b) Writing Mode
(c) Reading Mode (d) Binary Mode
Q9. Which command is used to modify data in a table: 1
(a) Update (b) Alter
(c) Modify (d) Change
Q10 Which command is used to create a new record in table? 1
.
(a) Insert (b) Create
(c) Add (d) Select
Q11 Data = “programming is passion” 1
.
print (Data)
Data = “Python Programming”
Data [0] = “$”
Data = Data + “Language”
print (Data)
In the above code, which statement will cause the error and why
Q12 Fill in the blanks: 1
.
_________ is a non-key attribute, whose values are derived from the primary key
of some other table.
(a) Candidate Key (b) Foreign Key
(c) Alternate Key (d) Primary Key
Q13 ………………… is used to position the file object at a particular position in a file. 1
.
(a) seekp () (b) tellg ()
(c) tell () (d) seek ()
Q14 …………… is used to display records without repetition. 1
.
(a) DISTINCT (b) UNIQUE
(c) PRIMARY KEY (d) None of them
2
Q15 SMTP stands for ……………………………………….. 1
.
(a) Simple Mail Transfer Protocol (b) Systematic Mail Transfer Protocol
(c) Simple Mail Transmit Protocol (d) Simple Multiple Transfer Protocol
1
Q16 Output of following expression will be:
.
26.0 + 8 * 6 - (10*3)
(a) 34.0 (b) 42.0
(c) 44.0 (d) Error
Q17 and 18 are ASSERTION AND REASONING based questions. Mark the
correct choice as
(a) Both A and R are true and R is the correct explanation for A
(b) Both A and R are true and R is not the correct explanation for A
(c) A is True but R is False
(d) A is false but R is True
Q17 Assertion(A): Python overwrites an existing file or creates a non-existing file when 1
. we open a file with ‘w’ mode.
Reason(R): a+ mode is used only for write operations
Q18 Assertion (A): In SQL, the aggregate function Avg() calculates the average 1
. value on a set of values and produce a single result.
Reason (R): The aggregate functions are used to perform some
fundamental arithmetic tasks such as Min(), Max(), Count() etc
1
Section B
Q19 Master Samarjeet Singh Chandel is a student of Python programming language. 2
. He is trying to develop a code to reverse a given number. But system is showing
some errors. Check and rewrite the code after removing all errors.
number = int(input("Enter the integer number: ")
rev_number = 0
while (number > 0)
remainder = number % 10
revs_number = (revs_number * 10) + remainder
number = number / 10
print("The reverse number is : {}".format(revs_number))
Q20 Write any four advantages of networking? 2
.
OR
3
What is Ethernet Hub?
Q21 (a) Write the output of: 1
.
print(mystring[ : : 3])
if the given string is:
mystring = “Master Sarthak Saklani”
(b) Write the output of the code given below: 1
player_data = { “Player_Name”: “Master Bhanu Sharma”, “Score”:525}
player_data [“Score”] = 625
player_data [“Game”] = “Chess”
print (player_data.items())
Q22 Explain the use of “Primary Key” in RDBMS. Justify your answer with an example. 2
.
Q23 Write the full forms of the following:
. a) XML
b) PPP
Q24 What do you mean by keyword argument in python? Describe with example. 2
.
OR
Predict the output of the Python code given below:
tup1 = (101, 220, 303, 44, 555 ,616)
list1 =list(tup1)
new_list = []
for i in list1:
if i%2==0:
new_list.append(i)
new_tuple = tuple(new_list)
print(new_tuple)
Q25 Differentiate between DDL and DML commands. 2
. OR
Categorize the following commands as DDL or DML:
INSERT, UPDATE, ALTER, DROP
4
Section C
Q26 (a) Consider the following tables – students and course 1+2
.
Table – Students
Admn_No Name Course_Code
101 Anurag Sharma C001
102 Bhanu Sharma C002
103 Mahi Tilva C003
104 Tvisha Solanki C001
105 Yash Patil C003
Table – Course
Course_Cod Name
e
C001 Core Python
C002 Python Pandas
C003 Python Matplotlib
What will be the output of following statement:
SELECT * FROM STUDENT NATURAL JOIN COURSE;
(b) Write the output of the queries (i) to (iv) based on the table TECH_COURSE
given below:
Table – Garments
GCode GName Size Colour Price
111 Tshirt XL Red 1400.00
112 Jeans L Blue 1600.00
113 Skirt M Black 1100.00
114 Jacket XL Blue 4000.00
115 Trousers L Brown 1500.00
116 Ladies Top L Pink 1200.00
(a) SELECT DISTINCT SIZE FROM GARMENTS;
(b) SELECT SIZE, COUNT ( * ), MIN (PRICE) FROM GARMENTS GROUP BY SIZE;
(c) SELECT GNAME FROM GARMENTS WHERE PRICE BETWEEN 1500 AND
2500;
(d) SELECT GCODE, GNAME, PRICE, PRICE * 100 “AMMOUNT FOT 100 ITEMS”
FROM GARMENTS WHERE COLOUR IN (“RED”, “PINK”);
Q27 Write a function count_lines() in Python to read lines from a text file 3
. “My_Story.txt” and display how many lines are starting with a vowel.
OR
5
Write a function display_words() in python to read lines from a text file
"mydata.txt", and display those words, which are less than 4 characters.
Q28 Write the outputs of SQL queries (i) to (iii) based on relations Employee:
.
(a) SELECT DEPTNO, AVG (SAL) FROM EMPLOYEE GROUP BY DEPTNO;
(b) SELECT MAX(HIREDATE), MIN(HIREDATE) FROM EMPLOYEE;
(c) SELECT EMPNO, ENAME, SAL, SAL * 12 “ANNUAL SALARY” FROM
EMPLOYEE WHERE COMM IS NULL AND DEPTNO IN (10,20);
Q29 Write a function first_list (N), where N is the list of elements passed as atgument 3
. to the function. The function returns another list names selected_element that
stores the all even values of first_list.
For example: if first_list contains [24,13,18,0,11,25,32] selected_element wil have
[24,18,32].
Q30 A list contains following data of a book: 3
. [book_id, book_name, price]
Write the following user defined functions to perform given operations on the
stack named status:
(i) Push_element() - To Push an object containing name and price of a new book
to the stack
(ii) Pop_element() - To Pop the objects from the stack and display them.
Also, display “Stack Empty” when there are no elements in the stack.
OR
6
Write a function in Python, Push(Pdata) where Pdata is a dictionary
containing the details of stationary items– {Pname:Runs}. The function should
push the names of those players in the stack who have run more than 250. Also
display the count of elements pushed into the stack.
For example:
If the dictionary contains the following data:
Pdata={"Virat":600,"Rahul":759,"Rishabh":180,"Hardik":125}
Section D
Q31 Joy online Education Corporation, a Delhi based IT Training company, is planning 5
. to set up training centres in various cities in next 2 years. Their first campus is
coming up in Lucknow district. At Lucknow campus, they are planning to have 3
different blocks for App development, Web designing and Movie Editing. Each
block has number of computers, which are required to be connected in a network
for communication, data and resource sharing. As a network consultant of this
company, you have to suggest the best network related solutions for them for
issues/problems raised in question nos. (i) to (v), keeping in mind the distances
between various blocks/locations and other given parameters
De
App Movie
Development Editing
Delhi HO
Lucknow
Web Campus
Designing
Distance between various blocks / locations:
Block Distance
App development to Web designing 28 m
App development to Movie editing 55 m
Web designing to Movie editing 32 m
Lucknow Campus to Delhi HO 585 km
No of Computers:
Block Distance
App development 75
Movie editing 80
Web designing 50
7
i. Suggest the most appropriate block/location to house the SERVER in the Lucknow 1
campus (out of the 3 blocks) to get the best and effective connectivity. Justify
your answer.
ii. Suggest a device/software to be installed in the Kashipur Campus to take care of 1
data security.
iii. Suggest the best wired medium and draw the cable layout (Block to Block) to 1
economically connect various blocks within the Kashipur Campus.
iv. Suggest the placement of the following devices with appropriate reasons: 1
a. Switch / Hub
b. Repeater
v. Suggest the protocol that shall be needed to provide Video Conferencing solution 1
between Lucknow Campus and Delhi HO.
Q32 a) Write the output of the following code: 2+3
.
import random
AR = [20,30,40,50,60,70];
FROM=random.randint(1,3)
TO=random.randint(2,4)
for K in range (FROM, TO+1):
print (AR[K], end="#")
1. 10#40#70#
2. 30#40#50#
3. 50#60#70#
4. 40#50#70#
b) The code given below inserts the following record in the table Friends:
sno – integer
Name – string
code – integer
salary – integer
Note the following to establish connectivity between Python and MYSQL:
Username is root
Password is Window
The table exists in a MYSQL database named school.
The details (SNo, Name, Code and Salary) are to be accepted from the user.
import mysql.connector as mysql
def sql_data():
con1=mysql.connect(host="localhost", user="root",password="Window",
database="mydata")
mycursor=_________________ #Statement 1
sno = int (input ("Enter Serial Number:: "))
name = input("Enter name :: ")
code = int(input("Enter code :: "))
salary = int(input("Enter Salary :: "))
8
querry = "insert into friends values({},'{}',{},{})".Format (sno, name, code,
salary)
______________________ #Statement 2
______________________ # Statement 3
print("Data Added successfully")
Write the following missing statements to complete the code:
Statement 1 – to form the cursor object
Statement 2 – to execute the command that inserts the record in the table
Student.
Statement 3 - to add the record permanently in the database
Q33 a) What is the advantage of using a csv file for permanent storage? 5
. b) Write a Program in Python that defines a function ADD() to accept and add
data of a player to a CSV file ‘record.csv’. Each record consists of a list with field
elements as pid, name and score to store player id, player name and score
respectively.
OR
a) Give any one point of difference between a binary file and a csv file.
b) Write a Program in Python that defines a function search() to display the
record of those players who is having score more than 500.
Section E
Q34 Ms Prapti creates a table "Movie" with a set of records to maintain the data of
. movies. After creation of the table, she has entered data of 10 rows in the table.
Table: Movies
Code Name Genres Rent Qty
101 Chennai Express Comedy 60.00 10
102 Raaz Horror 63.00 5
103 3 idiots Drama 75.00 7
104 Ek tha Tiger Action 70.00 8
105 Badhaai ho Comedy 65.00 8
106 1920 A love story Horror 50.00 5
107 Swadesh Drama 55.00 9
108 Khatta Meetha Comedy 45.00 3
Based on the data given above answer the following questions:
i. Identify the most appropriate column, which can be considered as Primary key. 1
ii. If two columns are added and 2 rows are deleted from the table result, what will 1
be the new degree and cardinality of the above table?
iii. Write the statements to: 2
(a) Insert the following record into the table –
113, Dhokha, Action, 63.00, 5
(b) Increase the rent by 5/- for all the movies where genre is comedy.
iv. Master Jatin is a Python programmer. He has written a code and created a binary
9
file "result.dat" with stdid, sname and marks. The file contains 10 records. Now,
he has to find a record based on the student id entered by the user and update
the marks. The updated record is then to be written in the file "temp.dat." The
records which are not to be updated also have to be written to the file
"temp.dat". If the student id is not found, an appropriate message should to be
displayed.
As a Python expert, help him to complete the following code based on the
requirement given above:
import _______ #Statement 1
def update_data():
rec={}
fin=open("result.dat","rb")
fout=open("_____________") #Statement 2
found=False
nid=int(input("Enter student id to update their marks:: "))
while True:
try:
rec=______________ #Statement 3
if rec["sid"]==nid:
found=True
rec["Marks"]=int(input("Enter new marks ::"))
pickle.____________ #Statement 4
else:
pickle.dump(rec,fout)
except:
break
if found==True:
print("The marks of student id ",sid," has been updated.")
else:
print("No student with such id is not found")
fin.close()
fout.close()
i. Which module should be imported in the program? (Statement 1) 1
ii. Write the correct statement required to open a temporary file named temp.dat 1
for writing the updated data. (Statement 2)
iii. Which statement should Jatin fill in Statement 3 to read the data from the binary 2
file, record.dat and in Statement 4 to write the updated data in the file,
temp.dat?
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
10