Set 1 First Model Examination Cs
Set 1 First Model Examination Cs
General Instructions:
1. This question paper contains five sections, Section A to E.
2. All questions are compulsory.
3. Section A have 18 questions carrying 01 mark each.
4. Section B has 07 Very Short Answer type questions carrying 02 marks each.
5. Section C has 05 Short Answer type questions carrying 03 marks each.
6. Section D has 03 Long Answer type questions carrying 05 marks each.
7. Section E has 02 questions carrying 04 marks each. One internal choice is
given in Q34 & Q35 against part c only.
8. All programming questions are to be answered using Python Language and
MySQL commands only.
1. Find the valid identifier from the following
(a) Tot$balance (b) TRUE (c) 4thdata (d) break 1
2. Given a string S = “ComPUterSciEnce”, write the output of 1
print(S[3:10:2])
3. Identify the valid declaration of T: 1
T = {“Roll”:123, “Name”: “Hiya”, “Class”:12, “Subject” : ”Computer
Science”}
a. dictionary b. string c. tuple d. list
4. Identify the valid relational operator in Python from the following.
(a) ? (b) => (c) != (d) in 1
5. What is the output of the following code?
S1=”Computer2023”
S2=”2023” 1
print(S1.isdigit(), S2.isdigit())
a)False True b) False False c) True False d) True True
6. The ‘r+’ mode will: 1
(A) Enable both reading and writing. (B) Raise an error if the file doesn’t
exist.
(C) Over write the already existing file. (D) Both (A) & (B)
7. Which of the following is a DML command ? 1
(a) DROP (b) INSERT (c) ALTER (d) CREATE
8. Which among the following are valid table constraints? 1
a) Candidate Key b) NULL c) Distinct d) Primary Key
11. Which of the following options can be used to read the first line of a text 1
file
“Myfile.txt”?
(A) myfile = open(‘Myfile.txt’); myfile.read()
(B) myfile = open(‘Myfile.txt’,’r’); myfile.read(n)
(C) myfile = open(‘Myfile.txt’); myfile.readline()
(D) myfile = open(‘Myfile.txt’); myfile.readlines()
12. Consider the following query 1
Select * from employee order by salary ____________, name ____________ ;
To display the salary from greater to smaller and name in alphabetical
order which of the following option should be used?
a)ascending, descending b)asc,desc c)desc,asc
d)Descending,Ascending
13. A distributed network configuration in which all data/information pass 1
through a central computer is _____ network:
a)ring b)bus c)star d)mesh
14. What will the following expression be evaluated to in Python? 1
print((4.00/(2.0+2.0)))
a)Error b)1.0 c)1.00 d)1
15. Which operator checks a value’s presence in a list of values?
a)between b)like c)in d)not 1
16. In order to open a connection with MySQL , database from within Python 1
using
mysql.connector package,________________ function is used.
a)open() b)database() c)connect() d)connectdb()
Q17 and 18 are ASSERTION AND REASONING based questions. Mark the correct choice
as
i. Both A and R are true and R is the correct explanation for A
ii. Both A and R are true and R is not the correct explanation for A
iii. A is True but R is False
iv. iv. A is false but R is True
17. Assertion (A):- Strings are immutable.
Reason (R):- Individual elements can not be changed in string in place. 1
18. Assertion (A):- open() is a method of python. 1
Reason (R):- open() method is used to open a file in Python and itreturns
a file object called file handle. The file handle is used to transfer data to
and from the file by calling the function defined in Python’s io module.
PART B
19. Rewrite the following code in Python after removing all syntax error(s).
Underline
each correction done in the code. 2
STRING=""WELCOME
NOTE = " "
for S in range(0,8):
if STRING[S]= ’E’:
print(STRING(S))
Else:
print “NO”
20. Differentiate between Spam and Trojan horse in context of networking 2
and data
communication threats.
OR
Differentiate between URL and Domain name. Explain with help of a
suitable
example.
21. (a) If the following code is executed, what will be the output of the 1
following code ?
Lt=[1,”Computer”,2,”Science”,10,”PRE”,30,”BOARD”]
print(Lt[3:])
(b) Identify the output of the following Python statements.
x = [[10.0, 11.0, 12.0],[13.0, 14.0, 15.0]]
y = x[1][2]
print(y)
a. 12.0 b. 13.0 c. 14.0 d. 15.0 1
22. What do you understand by Candidate Keys in a table? Give a suitable
example of Candidate Keys from a table containing some meaningful 2
data.
23. Expand the following terms: 2
a. FTP b. HTML c. PAN d. GPRS
24. What will be the output of following Python Code:
def change(num):
for x in range(0,len(num),2):
num[x], num[x+1]=num[x+1], num[x] 2
data=[10,20,30,40,50,60]
change(data)
print(data)
OR
Find the output of the following code:
def change (p, q=50):
p = p+q
q = p-q
print(p, '#', q)
return (p)
r = 300
s = 150
r = change (r,s)
print(r,"#",s)
s = change(s)
25. Anjali writes the following commands with respect to a table employee
having
fields, empno, name, department, commission. 2
Command1 : Select count(*) from employee;
Command2: Select count(commission) from employee; She gets the
output as 4 for the first command but gets an output 3 for the second
command. Explain the output with justification.
OR
Which of the following is not a DML command? Also write the full form of
DML command.
DELETE FROM, DROP TABLE, CREATE TABLE, INSERT INTO
SECTION C
26. a) Write the outputs of the SQL queries (i) based on relations EMP and DESIG given
below:
i)
1+2
b)Write the outputs of the SQL queries (i) to (iv) based on table EMP given below:
i)
2+1
a.
(i) To display the content of WORKERS table in ascending order of LASTNAME.
(ii) To display First Name, Worker ID and Address of male Workers only.
(iii) To display the Minimum salary among Managers and Clerks from the table DESIG.
(iv) To display First Name and Salary from Workers and Designaion Table for each worker.
a)Suggest the
most suitable place (i.e.,Unit/Building) to install the server of this
Institute.
b) Suggest an ideal layout for connecting these Unit/Building for a wired
connectivity.
c) Suggest the devices to be installed in each of these buildings for
connecting
computers installed within each of the units out of the following :
Modem, Switch, Gateway, Router
d) Suggest an efficient as well as economic wired medium to be used
within each
unit for connecting computer systems out of the following network cable :
Co-axial Cable, Ethernet Cable, Single Pair Telephone Cable.
e) The institute is planning to connect its admission office in Bangalore,
which is
1960km from institute. Which type of network out of LAN, MAN or WAN
will be
formed ? Justify your answer.
32. a) Write the output given by following Python code.
x=1
def fun1():
x=3
x=x+1
print(x)
def fun2(): 5
global x
x=x+2
print(x)
fun1()
fun2()
b)The code given below inserts the following record in the table Employee:
Eid – integer
Name – string
DeptID – integer
Salary – integer
Note the following to establish connectivity between Python and MYSQL:
Username is root
Password is tiger
The table exists in a MYSQL database named Company.
The details (Eid, Name, DeptID and Salary) are to be accepted from the user.
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 Employee.
Statement 3- to add the record permanently in the database
import mysql.connector as mysql
def sql_data():
con1=mysql.connect(host="localhost",user="root",password="tiger", database =
company")
mycursor=_________________ #Statement 1
rno=int(input("Enter Employee ID :: "))
name=input("Enter name :: ")
class=int(input("Enter Department ID :: "))
marks=int(input("Enter Salary :: "))
querry="insert into employee
values({},'{}',{},{})".format(eid,name,deptid,salary)
______________________ #Statement 2
______________________ # Statement 3
print("Data Added successfully")
OR
b) The code given below reads the following record from the table named student
and displays only those records where students name starts with ‘A’:
RollNo – integer
Name – string
Clas – integer
Marks – integer
Note the following to establish connectivity between Python and MYSQL:
Username is root
Password is tiger
The table exists in a MYSQL database named school. Write the following missing
statements to complete the code:
Statement 1 – to form the cursor object
Statement 2 – to execute the query that extracts records of those students where
students name starts with ‘A’.
Statement 3- to read the complete result of the query (records where students name
starts with ‘A’) into the object named data, from the table student in the database.
import mysql.connector as mysql
def sql_data():
con1=mysql.connect(host="localhost",user="root", password="tiger",
database="school")
mycursor=_______________ #Statement 1
print("Students where students name starts with ‘A’: ")
_________________________ #Statement 2
data=__________________ #Statement 3
for i in data:
print(i)
print()
33. Give any one point of difference between a binary file and a csv file. What
is the advantage of using a csv file for permanent storage? Write a
Program in Python that defines and calls the following user defined
functions: 1+2
(i) ADD() – To accept and add data of an employee to a CSV file +2
‘record.csv’. Each record consists of a list with field elements as empid,
name and mobile to store employee id, employee name and employee
salary respectively.
(ii) COUNTR() – To count the number of records present in the CSV file
named ‘record.csv’.
OR
Write a Program in Python that defines and calls the following user
defined functions:
(i) add() – To accept and add data of an employee to a CSV file
‘furdata.csv’. Each record consists of a list with field elements as fid,
fname and fprice to store furniture id, furniture name and furniture price
respectively.
(ii) search()- To display the records of the furniture whose price is more
than 10000.
SECTION – E
1+1
+2
AddStudents()
GetStudents()
i)Which module should be imported in the program? (Statement 1)
ii)Write code to open the binary file to write data. (Statement 2)
iii) Write statement to write the list L into the file. (Statement 3)
OR
iii) Write statement to read from the file. (Statement 4)