Professional Documents
Culture Documents
BVM CS 2324 3papers
BVM CS 2324 3papers
If the file “main” contains ’Good’ before execution of the program, what will be the
contents of the file after execution?
6 1
Observe the diagram given above and identify the correct option to open the file
named “one.txt” using absolute path ?
a. F = open (‘one.txt’)
b. F = open( ‘C:\\tom\\data\\one.txt’)
c. F = open( ‘..\\data\one.txt’)
d. F = None of the above
8 Which of the following symbols are used for passing parameterized query for 1
execution using the cursor?
a. % b. { } c. $ d. Both a & b
9 Which argument of open() is used to suppress the EOL character in an CSV file ? 1
a. delimiter b. with c. newline d. writer ( )
10 Consider the following table Customer and choose the correct output for the query 1
given below
13 When a file is opened using ‘a’ file mode, the file pointer is at the ______________ 1
of the file.
14 If a binary file is opened using the file object fin, which of the following is a valid 1
statement ?
a. fin.load( L ) b. pickle.load(fin, L )
c. L = pickle.load ( fin ) d. L = fin.load ( )
What is the degree and cardinality of the resultant table obtained by the following
query ?
select * from emp natural join dept;
17 Assertion (A) - If the arguments in the function call statement match the number and order 1
of arguments as defined in the function definition, such arguments are called positional
arguments.
Reasoning (R) - During a function call, the argument list first contains default argument(s)
followed by the positional argument(s).
Reasoning (R) - An element can be deleted only from the Top of the Stack.
20 a. A list contains the following record of students ([studname , mark]). Write the 3
following user defined functions to perform given operations on stack named
‘stud’.
i) push_stud() - To push students names to stack whose mark is more
than 250
ii) pop_stud() - To pop the names of students from stack and display them.
Also display “Underflow” when there are no students in the stack.
Example:
If the list contains:
[[‘Rahul’,450],[‘Deepa’,200],[‘Uma’,400],[‘Sidharth’,230]]
The stack should contain
Rahul
Uma
The output should be:
Uma
Rahul
Underflow
OR
Write a function in Python Push(student), where student is a dictionary containing
details of students {student_name:stream}. The function should push the names of
students who belong to Science stream to the stack ( Consider the case )
Example:
If the dictionary contains the following data :
student={‘Amal’:’Science’,’Julian’:’Commerce’,’Veena:’SCIENCE’,’Thara’:’Humaniti
es’}
The stack should contain
Amal
Veena
22 Assume that a file is opened using the file object “File”, Write commands to do the 2
following :
a. Place the file handle at the end of the file.
b. Print the current position of the file handle.
23 Write a program in Python to increase the salary of all employees by 1000 in the 4
table Emp which contains the following table structure.
Eno - integer , Ename - string ,Salary - integer
Note the following to establish connectivity between Python and MySQL:
host is "localhost" , User name is "root" , Password is "root", Table name is Emp
database name is "Employee"
24 Write a program in python that defines and calls the following user defined 4
functions:
a. Add_Cust() : Takes details of a customer and adds them to a csv file
‘Cust.csv’. Details of customer - cust_no, cust_name, pending_amount
b. Search_Cust() : Takes customer number as input and displays
corresponding pending_amount to be paid
OR
Write a program in python that defines and calls the following user defined
functions:
c. Add_Match ( ) : Takes details of a football match ( Date, Teams, Stadium )
and adds them to a csv file Football.csv’.
d. Display_Stadium ( ) : The function takes the stadium as an argument and
displays the dates on which the matches are played at the corresponding
stadium.
28 Write a function in Python named Shift() which will shift all elements in a list 3
towards the left. First element in the list will be placed as the last element.
Example:
Consider the list - [10,4,2,7,8,1]
Final list should be - [4,2,7,8,1,10]
SECTION - C
29 Sumitha, a database administrator, is working on a project. She wrote a query for 1
her project and found that it is not giving the expected result. Help her to correct
her query. The query is as follows:
Select * from items where comp_name =null;
30 Consider the table Teacher and write the queries for the following questions: 9
a. Display name and age of teachers whose salary is between 30000 and 40000
(both inclusive)
b. Display number of departments
c. Display details of teachers whose name ends with ‘a’
d. Display the total salary of all departments along with department name
e. Display names and salary of teachers in descending order of their age
f. Give an increment of 5000/- in their salary for all Computer teachers
g. Remove all teachers from the table whose age is below 30
Consider the above table and write the output for the following queries:
h. Select Tname from Teacher where Dept in(‘Maths’,’Computer’);
i. Select Tname,salary+5000 from Teacher Where age > 40 and
Dept=’English’;
32 Consider the tables ‘emp’ and ‘dept’ and answer the question given below:
General Instructions:
Please check this question paper contains 35 questions.
The paper is divided into 4 Sections- A, B, C, D and E.
Section A, consists of 18 questions (1 to 18). Each question carries 1 Mark.
Section B, consists of 7 questions (19 to 25). Each question carries 2 Marks.
Section C, consists of 5 questions (26 to 30). Each question carries 3 Marks.
Section D, consists of 2 questions (31 to 32). Each question carries 4 Marks.
Section E, consists of 3 questions (33 to 35). Each question carries 5 Marks.
All programming questions are to be answered using Python Language only.
SECTION A
4.Which keyword can be used to return only different values in a particular column or a
whole
table?
(a) WHERE (b) DISTINCT (c) ALL (d) BETWEEN
7. Which of the following statement(s) would give an error during execution of the
following code?
tup = (20,30,40,50,80,79)
print(tup) #Statement 1
print(tup[3]+50) #Statement 2
print(max(tup)) #Statement 3
tup[4]=80 #Statement 4
8. To delete all the records from a table “Product” the command will be
(a) DEL FROM Product; (b) DELETE FROM Product;
(c) REMOVE ALL FROM Product; (d) DELETE ALL;
10. Study the following program and select the possible output(s) and write maximum and
minimum value assigned to the variable y
import random
x=random.random( )
y=random.randint(0,4)
print(int(x),”:”,y+int(x))
(a) 0:0 (b) 1: 6 (c) 2:4 (d) 0:3
12. The values being passed through a function call statements are called
(a) Actual parameter (b) Formal parameter (c) default parameter (d) None of
these
13. Write a statement to send the file pointer position 10 bytes forward from current location
of file, consider fp as file object.
a) fp.seek(10) b) fp.seek(10,1) c) fp.tell(10) d) fp.seek(1,10)
14. In order to open a connection with MySQL database from within Python using
mysql.connector
package, __________ function is used.
(a) open (b) connect (c) database() (d) connectdb()
15. What is the csv method that is used to read the csv file.
(a) readcsv() (b) read_csv( ) (c) reader( ) (d) read( )
18. Assertion(A) : Stack is a linear data structure which works on FIFO principle.
Reasoning (R) : Stack is implemented using lists in Python with some restrictions.
(a) Both (A) and (R) are correct (b) Both (A) and (R) are incorrect
(c) (A) is correct but (R) is incorrect (d) (A) is incoorect but (R) is correct
SECTION B
20. A resultset is extracted from the database using the cursor object (that has been already
created) by giving the following statement.
Mydata=cursor.fetchone()
(a)How many records will be returned by fetchone() method?
(b)What will be the datatype of Mydata object after the given command is executed?
21. Differentiate between local variable and global variable with a suitable example for
each.
24. Differentiate between equi –join and natural join in SQL with appropriate example.
OR
Categorize the following commands as DDL or DML:
INSERT, UPDATE, ALTER, DROP
25. Write a function, lenWords(Str), that takes a string as an argument and returns a tuple
containing length of each word of a string. For example, if the string is "Come let us have
some fun", the tuple will have (4, 3, 2, 4, 4, 3)
SECTION C
28. Write a function countINDIA() which read a text file ‘myfile.txt’ and print the frequency
of the words ‘India’ in it (ignoring case of the word).
Example: If the file content is as follows:
INDIA is my country. I live in India. India has many states.
The countIndia() function should display the output as:
Frequency of India is 3
OR
Write a function countVowel() in Python, which should read each character of a text file
“myfile.txt” and then count and display the count of occurrence of vowels (including small
cases and upper case).
Example:
If the file content is as follows:
INDIA is my country. I live in India. India has many states.
The countVowel() function should display the output as:
Total number of vowels are : 20
29. Consider the following tables BOOKS and ISSUED in a database named “LIBRARY”.
Write SQL commands for the statements
(i) Display book name and author name and price of computer type books.
(ii) To increase the price of all history books by Rs 50.
(iii) Show the details of all books in ascending order of their prices.
OR
(iii) To display book id, book name and quantity issued for all books which have been
issued.
31. Write the SQL statements for the queries given below based on the following tables.
(i) Display the Trainer Name, City & Salary in descending order of their Hiredate.
(ii) To display the TNAME and CITY of Trainer who joined the Institute in the month of
December 2001.
(iii) To display TNAME, HIREDATE, CNAME, STARTDATE from tables TRAINER and
COURSE of all those courses whose FEES is less than or equal to 10000.
(iv) To display number of Trainers from each city.
32.Write a Program in Python that defines and calls the following user defined functions:
(i) ADDR() – To accept and add data of a student to a CSV file‘ record.csv’ . Each record
consists of a list with field elements as rollno, name and mobile to store roll number name
and mobile no of student respectively.
(ii)COUNTR() – To count the number of records present in the CSV file named ‘
record.csv’
SECTION E
Q no Question Mark
SECTION A
1 State True or False: 1
“The else part of a loop gets executed only when a break statement terminates it.”
2 Relation R1 has 10 tuples and 5 attributes. Relation R2 has 2 tuples and 7 attributes. 1
When a CROSS JOIN (Cartesian Product) is achieved between R1 and R2, how many
tuples would the resultant set have?
a) (‘G20’,’summit’,’20) b) (‘G20’,’summit’,’20)
c) ['G20', ' ', 'summit 2023'] d) ('G20', ' ', 'summit 2023')
5 In SQL, name the clause and keyword that is used to display the tuples in descending 1
order of an attribute.
a)Order By,Desc b)Group By ,Desc
c)Order BY,Asc d)Sort By,Desc
1
6 Two schools in the same city wanted to transfer e-learning information. Which type of 1
network will be used to implement the same?
9 Which of the following statement(s) would give an error during execution of the 1
following code?
p1=["pass","fail"] #statement 1
p2=tuple(p1) #statement 2
p2[0]='redo'+'2' #statement 3
print(p2) #statement 4
2
13 State whether the following statement is True or False: 1
Which of the following statements is true?
a) The standard exceptions are automatically imported into Python programs
b) All raised standard exceptions must be handled in Python
c) When there is a deviation from the rules of a programming language, a semantic error
is thrown
d) If any exception is thrown in try block, else block is executed
14 A _____________ makes sure that the values present in the foreign key column must 1
exist in the primary key column of the parent table.
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
SECTION B
19 i)Expand the following:- 1+1=2
a)WIMAX b)TCP/IP
ii)Give 2 differences between IP address and MAC address.
OR
i)Define the term baud.
ii)Explain URL and domain name with an example.
20 Find errors, underline them and rewrite the same after correcting the following code: 2
d1=dict[]
i=1
n=input("Enter number of entries:")
3
while i<=n:
a=input("Enter name:")
b=input("Enter age:")
d1(a)=b
i+=1
l=d1.key()
for i in l:
print(i,'\t',d1[i])
21 Write a python function to count the number of characters(character frequency) in a 2
string and store it in a dictionary. The function accepts string as an argument and return
the dictionary.
Consider the following string
S=”google.com”
Expected output is
{'g': 2, 'o': 3, 'l': 1, 'e': 1, '.': 1, 'c': 1, 'm': 1}
OR
Write a python function which takes list of strings as argument and display the
palindromic words from the list of strings separated by #.
Consider the following list
l=['mom','dad','hello','hai','malayalam']
Expected output is
mom#dad#malayalam#
s="Hello"
l=[11,12,14,13,20]
d=fun(s,l)
for i in d.values():
print(i,sep='*',end='!')
23 Write the Python statement for each of the following tasks using BUILT-IN 1+1=2
functions/methods only:
i) To Join all items in a tuple( t) into a string( x ), using a hash character as
separator:
ii) To sort a list (L1) in descending order and returns a new sorted list (L2)
without changing the original list.
4
OR
i) A list named studentAge stores age of students of a class. Write the Python
command to import the required module and (using built-in function) to
display the most common age value from the given list.
24 Riya is working on RDBMS. Help her to perform the following task: 1+1=2
i) To delete a column named Dept from the table Emp.
ii) To add a primary key to the Empno column of the table Emp.
OR
i) Rayan is working in a database named SPORT, in which he has created a table
named “Sports” containing columns SportId, SportName, no_of_players, and
category. After creating the table, he realized that the attribute, category has
to be deleted from the table and a new attribute TypeSport of data type string
has to be added. This attribute TypeSport cannot be left blank. Help Rayan
write the commands to complete both the tasks.
25 Predict the output of the following code: 2
p=5
def calc(q,r=2):
global p
p+=q+r
print(p, end= '#')
a=30
b=10
calc(a,b)
print(p,end='@')
calc(r=5,q=1)
SECTION C
26 Predict the output of the following code: 3
s="First Model 2023"
r=' '
for i in range(len(s)):
if s[i].isupper():
r=r+s[i].lower()
elif s[i].islower():
r=r+s[i].upper()
elif i%2==0:
r=r+s[i-1]
else:
r=r+'&'
print(r)
27 Consider the table MED_REPORT given below and write the output of the SQL 1x3=3
queries that follow.
STU_ID STU_NAME BLOOD_GROUP HEIGHT WEIGHT AGE
S101 Amrita O+ 151 55 16
S102 Bindhu A+ 162 65 17
S103 Radhika AB+ 170 45 16
5
S104 Rani O+ 155 50 15
S105 Sandra A+ 175 40 17
OR
Write a function(method) in python to read the text file “MYNOTES.TXT”, to find and
display the lines not starting with vowel.
29 Consider the table given below: 1x3=3
Table:Result
For example
If the list Player contains
6
Player=[['aaa','India',30],['bbb','India',20],['ccc','Srilanka',28]]
SECTION D
31 Consider the following tables CABHUB and CUSTOMER. Write SQL commands for 1x4=4
the questions (i) to (iv)
Table: CABHUB
Table: CUSTOMER
32 Shyam is a Python programmer working in a school. For the Model Exam, he has created 4
a csv file named Result.csv, to store the marks of computer science of n students.
7
Shyam wants to write the following user defined functions:
Accept() – to accept the details of n students and add it to the file Result.csv. The column
headings should also be added on top of the csv file.
Display() – to display the details of students who have scored ‘A’ Grade.
As a Python expert, help him to complete the task.
SECTION E
33 Delhi Public School is setting up its branch office in Hyderabad with four departments 1+1+
for Computer, Mathematics and FA along with an administrative office in separate 1+2=5
buildings. The physical distances between these department buildings and the number
of computers to be installed in these departments and administrative office are given
as follows. You as a network expert have to answer the queries as raised by them in
(i) to (iv).
Administrative Computer
office dept.
FA dept. Mathematics
dept.
Computer Dept 40
Administrative Office 140
Mathematics Dept 50
FA Dept 80
i) Suggest the most suitable location to house the server of this institution.
Justify the answer.
ii) Suggest the best cable layout for effective network connectivity of the
departments.
iii) Suggest the devices to be installed in each of these buildings for connecting
computers installed within the departments out of the following:
• Gateway
• Modem
• Switch
8
iv) Suggest the topology of the network and network cable for efficiently
connecting each computer installed in each of the departments out of the
following:
Topologies: Bus Topology, Star Topology
Network Cable: Ethernet Cable, Single Pair Telephone Cable, Coaxial Cable
34 i) Differentiate between seek() and tell() methods? 2+3=5
ii) Consider a Binary File Emp.dat, containing records of the following
structure:[Empno,Empname,Salary]
Write a function EmpUpdate(), to update the salary of an employee whose
employee number is accepted from the user.If the employee number is not
found, an appropriate message should be displayed.
OR
i) How are text files different from binary files?
ii) A Binary file, employee.dat containing Empno,Ename,Salary as
dictionary.
Write a user defined function, Search(), that displays the records from the
binary file employee.dat whose salary is greater than 30000.
35 i) Define the terms attribute and tuple with respect to RDBMS. Explain with 1+4=5
an example.
ii) Mr. xyz wants to write a program in Python to insert the following record
in the table named Student in MYSQL database, SCHOOL:
• rno(Roll number )- integer
• name(Name) – string
• DOB (Date of birth) – Date
• Fee – float
Note the following to establish connectivity between Python and MySQL:
• Username – root • Password - tiger • Host – localhost
The values of fields rno, name, DOB and fee has to be accepted from the
user. Help him to write the program in Python.
OR
i) Differentiate update command and alter command in RDBMS.
ii) Mr. ABC wants to write a program in Python to insert the following record
in the table named Student in MYSQL database, SCHOOL:
• rno(Roll number )- integer
• name(Name) – string
• DOB (Date of birth) – Date
• Fee – float
Note the following to establish connectivity between Python and MySQL:
• Username – root • Password - tiger • Host – localhost
Mr. ABC wants to display the records of students whose fee is more than
5000. Help him to write the program in Python
*******************************