CS QUARTERLY 2023 28 08 2023 Answers 1694082584
CS QUARTERLY 2023 28 08 2023 Answers 1694082584
CS QUARTERLY 2023 28 08 2023 Answers 1694082584
SCHOOL
SREE NANDEESWARAR CAMPUS,
ADAMBAKKAM, CHENNAI-600088
Quaterly Examination-2023
Maximum Marks:70 Time Allowed: 3 hours
General Instructions:
pride="#G20 Presidency"
print(pride[-12:0:-1][::-1])
ans: G20
ii) What will the output?
>>> import math
>>> x=25
>>> y=5
>>>x/y+math.floor(6*2/3)
ans: 9.0
command is used to remove all the rows from the table student
inSQL.
ans:3
print(abs(int(str(L[-1:-2:-1]).strip('[ ]'))))
ans: 51
ii)
count={}
count[(1,2,4)] = 5
count[(4,2,1)] = 7
count[(1,2)] = 6
count[(4,2,1)] = 2
tot = 0
for i in count:
tot=tot+count[i]
print(len(count)+tot)
13 i) Which of the following outputs are not possible when we run the below 1
code?
import random
for a in range(3):
3
for b in range(3):
res=random.random()*4+12
res1=round(res,4)
print(res1,' ',end=' ')
print()
ii) Which point can be considered as difference between tuple and list?
a. Length b. Indexing c. Mutability d. Slicing
ii) In string slicing, the start and stop can be given beyond limits. If it is then
a. raise exception IndexError
b. raise exception ValueError
c. return empty string
d. return the entire string
15 i) Ms. Hemanth is working on a string program with s=”computer”. He wants 1
to display last four characters of a string object named s. Which of the
following statement is true?
a. s[4:] b. s[:4] c. s[-4:] d. s[:-4]
ii)
>>> s='o o p s'
>>> ls=s.split()
>>> '-'.join(ls[0].upper()+ls[1].capitalize()+ls[2].swapcase()+ls[3].lower())
4
d) Error because join takes one argument
ii) Assertion- The open a file one should use the open() function,
open() is a built in function
Reason - The open () functions returns a file object, it is used to
read or modify the file accordingly.
Ans:a,b
SECTION B
19 Evaluate the following expressions: 2
a) 7*3+4**2//5-8
16
b) 7>5 and 8>20 or not 12>4
False
c) 2*(2*(len("01\n")))
12
d) 1 or None and 'a' or 'b'
1
5
ans: ('Centre', 10, 3, 4, 6)
Given below the file hierarchy:
LIBCOMSCI
__init__.py
Details.py
COMSCI
__init__.py
CSXI.py
CSXII.PY
INFOPRAC
__init__.py
IPXI.py
IPXII.py fun1()
22 Write the queries for the following questions using the table Product with 2
the following fields. (P_ Code, P_Name, Qty, Price)
(i) Display the price of product having code as P06.
Select price from product where P_code=’p06’;
(ii) Display the name of all products with quantity greater than 50 and price
less than 500
Select P_name from product where Qty>50 and price<500;
iii) Include the ‘discount’ column to the table with float values as data
Alter table product add discount float;
iv) Make P_Code as the primary key of the table.
Alter table product modify P_Code varchar(30)primary key;
(Or)
Alter table add Primary key(P_Code)
23 Given below the folder contents in the C:\ drive 2
C:\
6
FIRST
One.txt
SECOND
Two.txt
Three.txt
THIRD
Four.txt
Five.txt
i)c:\second\third\five.txt
ii)..\three.txt
iii).\third\four.txt
iv)c:\one.txt
7
25 i) Rewrite the following code in Python after removing all syntax error(s).
Underline each correction done in the code.
def func(a=100,b):
if a<b:
print(a)
elif:
print(b)
return a+b
func()
answer
def func(b,a=100):
if a<b:
print(a)
elif:
print(b)
return a+b
func(20)
return str1
s=encrypt("WeLcOmE")
print(s)
w*El*Co*Me
Section-C
26 i) Write a method Firstlast( ) in python to print the lines starting with ‘T’ 3
or ‘t’ or ending with ‘e’ or ‘g’ in a text file “ARTICLE.txt”
Example :
Of a student
Output:
This is a sample text file
is created for the purpose of testing,
File Handling with text file.
Thank you.
ii) Write a method RevText() to read a text file “input.txt” and print the
text in reverse order.
Example:
If the file content is as follows: I LOVE MY NATION
Output will be: NOITAN YM EVOL I
Output:
Vivek 460
9
Vidya Suresh 470
27 a) Write the outputs of the SQL queries (i) to (iv) based on the 3
relations Teacher and Placement given below:
10
Write the SQL queries for the following statements:
iv) Write the command to remove all the tuples of teacher table
Delete from Teacher;
vi) Write the command to make T_ID as the primary key and P_ID as foreign
key of the respective tables
Alter table teacher modify T_ID int primary key;
Or
28 i) Write a function countvow() to count the total number of lines starting with 3
vowel(Consider the merge.txt file)
29 3
a. Write the outputs of the SQL queries (i) to (iii) based on the relations
Club and Coach given below:
Table : Club
Coach-id CoachName Age Sports DateOfApp Pay Sex
1 KUKREJA 35 KARATE 27/03/1996 1000 M
2 RAVINA 34 KARATE 20/01/1998 1200 F
3 KARAN 34 SQUASH 19/02/1999 2000 M
4 TARUN 33 BASKETBALL 01/01/1999 1500 M
5 ZUBIN 36 SWIMMING 12/01/1998 750 M
6 KETAKI 36 SWIMMING 24/02/1997 800 F
7 ANKITA 39 SQUASH 20/02/1998 2200 F
8 ZAREEN 37 KARATE 22/02/1997 1100 F
9 KUSH 41 SWIMMING 13/01/1997 900 M
10 SHAILYA 37 BASKETBALL 19/02/1998 1700 M
11
Table: Coach
Sports_Person Sex Coach-id
AJAY M 1
SEEMA F 2
VINOD M 1
TANEJA F 3
VINOTHINI F 8
12
a) Write a query to change the fare to 6000 of the flight whose FNO is
F104.
Update flight set fare=6000 where fno=’F104’;
b) Write a query to display the total number of MALE and FEMALE
PASSENGERS.
Select count(*),gender from passenger group by gender;
f) Write a query to display the info about the flight which has maximum
fare which starts from Mumbai
Select * from flight where fare=(select max(fare) from flight where
start=”Mumbai”) and start=”Mumbai”;
Section-D
31 a. Predict the output of the code given below 1+1 ½
+1 ½
def Display(str):
m=" "
for i in range(0,len(str)):
if(str[i].isupper()):
m=m+str[i].lower()
elif str[i].islower():
m=m+str[i].upper()
13
else:
if i%2==0:
m=m+str[i-1]
else:
m=m+"#"
print(m)
Display('CBSE@Mrch23')
c
cb
cbs
cbse
cbseE
cbseEm
cbseEmR
cbseEmRC
cbseEmRCH
cbseEmRCH#
cbseEmRCH#2
ii) Change the Bprice as rs.500/- for the book “Wings of Fire”
10 # 25 $ 150 @
18 # 50 $ 250 @
18 # 25 $ 350 @
50 # 25 $ 400 @
10 # 13 $ 400 @
b) Write a void function that receives a 4-digit no. and calculates the
sum of the squares of each digit in the number.
Example :
Enter a 4-digit no.1234
Sum of squares of digits=30
SECTION-E
33 a) Find output of the following code : 2+1
import sys ½ +1
s="""Wish ½
you
all
"""
f=open("abc.txt",'w+')
print(f.write(s))
f.flush()
f.seek(0)
15
print(f.read(3))
print(f.readline(4))
f.seek(4)
print(f.readlines(9))
13
Wis
h
Example-2:
21=22+12=4+1=5
Thus 21 is not a ‘HAPPY NUMBER”
16
Write the following SQL queries:
He wants to add one more record to this table and has written the following
code and unable to insert that record.
INSERT INTO DEPARTMENT VALUES(43,”HRD”);
Write a commands to :
g) show the names of department starting with “R”.
select Dname from department wher Dname like ‘R%’;
h) Change LOC as “New York” for DEPTNO 30.
Update department set LOC=’New York” where deptno=30;
i) delete the records of location(LOC) “Boston”
Delete from department where Loc=”Boston”;
Table : STUDENT
19