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

Set 1 First Model Examination Cs

The document is an examination question paper divided into five sections (A to E) covering various topics in programming, SQL, and networking. It includes multiple-choice questions, short answer questions, and programming tasks primarily focused on Python and MySQL. Each section has specific instructions regarding the number of questions and marks allocated.

Uploaded by

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

Set 1 First Model Examination Cs

The document is an examination question paper divided into five sections (A to E) covering various topics in programming, SQL, and networking. It includes multiple-choice questions, short answer questions, and programming tasks primarily focused on Python and MySQL. Each section has specific instructions regarding the number of questions and marks allocated.

Uploaded by

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

PART A

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

9. Suppose a tuple T is declared as T=(10,20,30) and a list L=["mon", "tue",


"wed", 1
"thu", "fri", "sat", "sun"], which of the following is incorrect ?
a) min(L) b) L[2] = 40 c) T[3] = “thurs” d) print( min(T))
10. The statement in SQL which allows to change the definition of a table is
(a) Alter. (b) Update. (c) Create. (d) select. 1

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

SELECT EMP.Name, EMP.Designation,DESIG.Salary FROM EMP, DESIG


WHERE EMP.E_ID = DESIG.E_ID AND EMP.Age>35;

b)Write the outputs of the SQL queries (i) to (iv) based on table EMP given below:

i)

SELECT Designation, count(*) FROM EMP GROUP BY Designation;


ii) SELECT AVG(Age) FROM EMP;
iii) SELECT Name,Designation,Gender FROM EMP where Gender=’F’ order by
name;
iv) SELECT distinct(Designation) from EMP;
27. Write a method cnt_M() in Python to read lines from a text file
MYNOTES.TXT’,
and display those lines, which are starting with the alphabet ‘M’‖. 3
If the “MYNOTES.TXT” contents are as follows:
My first book was
Me and My Family.
It gave me chance to be
Known to the world.
The output of the function should be:
Count of lines starting with M is: 2
OR
Write a method/function BIGWORDS() in Python to read contents from a
text file
CODE.TXT, to count and display the occurrence of those words, which are
having 7 or more alphabets.
For example :
If the content of the file is
ME AND MY FRIENDS
ENSURE SAFETY AND SECURITY OF EVERYONE
The output of the function should be: 3
28. Consider the following tables WORKERS and DESIG. Give outputs for SQL
queries (i) to (iv) :

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.

(b) Write the command to view all the database.

29. Write definition of a method ODDSum(NUMBERS) to add those values in 3


the list of NUMBERS, which are odd.
Sample Input Data of the List
NUMBERS=[20,40,10,5,12,11]
OUTPUT is 16
30. Write a function in Python PUSH(Num), where Num is a list of integer
numbers.
From this list push all positive even numbers into a stack implemented
by using a list. Display the stack if it has at least one element, otherwise 3
display appropriate error message.
OR
Write a function in Python POP(cities), where cities is a stack
implemented by a list of city names for eg. cities=[‘Delhi’, ’Jaipur’,
‘Mumbai’, ‘Nagpur’]. The function returns the value deleted from the
stack.
SECTION – D
31. Biyani Design and Training Institute is setting up its center in Jaipur with
four
specialized units for Design, Media, HR and Training in separate buildings.
The
physical distances between these units and the number of computers to
be installed in these units are given as follows. You as a network expert,
have to answer the queries as raised by the administrator as given in (i)
to (v).
Shortest distances between various locations in meters :

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

a) Find and write the output of the following python code:


def fun(s):
k=len(s)
m=" "
for i in range(0,k):
if(s[i].isupper()):
m=m+s[i].lower()
elif s[i].isalpha():
m=m+s[i].upper()
else: m=m+'bb'
print(m)
fun('school2@com')

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

34. Consider the following table named ‘‘SOFTDRINK’’.

1+1
+2

Based on the data given above answer the following questions:


(i)Identify the most appropriate column, which can be considered as
Primary key.
(ii) If two columns are added and 2 rows are added from the table result,
what will
be the new degree and cardinality of the above table?
(iii) Write the statements to:
a. Insert the following record into the table DRINKCODE –107, DNAME-
Khatta
Aam, PRICE-15.00, CALORIES-100.
b. Increase the PRICE of the SOFTDRINK’’by 3% whose name begins with
‘A’.
OR
(iii) Write the statements to:
a. Delete the record of SOFTDRINK containing calories 120.
b. Add a column FAT in the table with datatype as decimal(5,2).
35. Amritya Seth is a programmer, who has recently been given a task to
write a python
code to perform the following binary file operations with the help of two
user defined functions/modules: 1+1
a. AddStudents() to create a binary file called STUDENT.DAT containing +2
student
information – roll number, name and marks (out of 100) of each student.
b. GetStudents() to display the name and percentage of those students
who have a
percentage greater than 75. In case there is no student having
percentage > 75 the
function displays an appropriate message. The function should also
display the average percent. He has succeeded in writing partial code and
has missed out certain statements, so he has left certain queries in
comment lines. You as an expert of Python have to provide the missing
statements and other related queries based on the following code for
Amritya. Answer the below mentioned questions.

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)

You might also like