CS
CS
QUARTERLY EXAM
SECTION-A
18X1=18
print (6+5/4**2//5+8)
S = "text#next"
print(S.strip("t"))
8. fetchall () method returns all rows in a result set and returns a___________
A) Tuples of list B) List of tuples C) List of strings
D) Tuple of strings
9. Consider the statements given below and then choose the correct output from the
given options:
10. Which of the following output will never be obtained when the given code is
executed?
import random
Shuffle = random.randrange(10)+1
Draw = 10*random.randrange(5)
a=10
def convert(b=20):
a=30
c=a+b
print(a,c)
convert(30)
print(a)
N = (25)
13. Mr. Ravi is creating a field that contains alphanumeric values and fixed lengths.
Which MySQL data type should he choose for the same ?
A) VARCHAR B) CHAR C) LONG D) NUMBER
Questions No.17 and 18 are Assertion and Reason type questions. Each question consists
of two statements, namely, Assertion (A) and Reason (R). Mark the correct choice as
B) Both A and R are true and R is not the correct explanation for A.
17. Assertion (A): Global variables are accessible in the whole program.
Reason (R): Local variables are accessible only within a function or block in which it
is declared.
18. Assertion (A): If numeric data are to be written to a text file, the data needs to be
converted into a string before writing to the file.
Reason (R): write () method takes a string as an argument and writes it to the text
file.
SECTION-B
7X2=14
19. (i) Expand the following terms:
URL, XML
(ii) Give one difference between HTTP and FTP.
20. Observe the following code carefully and rewrite it after removing all syntactical
errors. Underline all the corrections made.
def 1func():
a=input("Enter a number"))
if a>=33
print("Promoted to next class")
ELSE:
print("Repeat")
21. Write the definition of a method/function SearchOut(Teachers, TName) to search for
TName from a list Teachers, and display the position of its presence.
For example :
If the Teachers contain ["Ankit", "Siddharth", "Rahul", "Sangeeta", "rahul"] and
TName contains "Rahul"
The function should display
Rahul at 2
rahul at 4
22. (i) Define the term IP address with respect to network.
23. Write the Python statement for each of the following tasks using BUILT-IN
functions/methods only :
User_id – int
User_name – varchar(20)
Password – varchar(10)
Help him by writing SQL queries for both tasks
Sum=0
for C in range(1,Num+1):
if C%2!=0:
continue
Sum+=C
return Sum
print(Total(4),end="$")
print(Total(),sep="@")
SECTION-C
5x3=15
m = m+'@'
print(m)
27. Consider the table Stationery given below and write the output of the SQL queries
that follow.
Table: Stationery
TEMNO ITEM DISTRIBUTOR QTY PRICE
401 Ball Pen 0.5 Reliable Stationers 100 16
402 Gel Pen Classic Plastics 150 20
Premium
403 Eraser Big Clear Deals 210 10
404 Eraser Small Clear Deals 200 5
405 Sharpener Classic Plastics 150 8
Classic
406 Gel Pen Classic Classic Plastics 100 15
ii) SELECT ITEMNO, ITEM FROM STATIONERY WHERE DISTRIBUTOR = "Classic Plastics"
AND PRICE > 10;
iii) SELCET ITEM, QTY * PRICE AS "AMOUNT" FROM STATIONERY WHERE ITEMNO = 402;
28. Write a method/function COUNTWORDS () in Python to read contents from a text file
DECODE.TXT, to count and return the occurrence of those words, which are having 5
or more characters.
Table: Rent_cab
Vcode VName Make Color Charges
101 Big car Carus White 15
102 Small car Polestar Silver 10
103 Family Windspeed Black 20
car
104 Classic Studio White 30
105 Luxury Trona Red 9
Based on the given table, write SQL queries for the following:
{state:city}
(i) push_city(d_city): It takes the dictionary as an argument and pushes all the cities
in the stack CITY whose states are of more than 4 characters.
(ii) pop_city(): This function pops the cities and displays "Stack empty" when there are
no more cities in the stack.
SECTION-D
2x4=8
Table: GAMES
GCode GameName Type Number PrizeMoney
101 Carrom Board Indoor 2 5000
102 Badminton Outdoor 2 12000
103 Table Tennis Indoor 4 NULL
104 Chess Indoor 2 9000
105 Lawn Tennis Outdoor 4 25000
Table: PLAYERS
PCode Name GCode
1 Nabi Ahmad 101
2 Ravi Sahai 108
3 Jatin 101
4 Nazneen 103
(i)Display the game type and average number of games played in each type.
(ii) Display prize money, name of the game, and name of the players from the tables
Games and Players.
(iii) Display the types of games without repetition.
(iv) Display the name of the game and prize money of those games whose prize money
is known.
32. Write the output of the queries (i) to (iv) based on the table.
TABLE: EMPLOYEE
EMPNO NAME DATE OF JOINING SALARY CITY
5001 SUMIT SINGH 5/24/2012 55000 JAIPUR
5002 ASHOK SHARMA 10/25/2015 65000 DELHI
5003 VIJAY SINGH 9/9/2009 85000 JAIPUR
5004 RAKESH VERMA 12/21/2020 60000 AGRA
5006 RAMESH KUMAR 1/22/2011 72000 DELHI
(ii) Suggest the best wired medium to efficiently connect various blocks within the
Ambala office compound.
(iii) Draw an ideal cable layout (Block to Block) for connecting these block a for wired
connectivity.
(iv) The company wants to schedule an online conference between the managers of
Delhi and Ambala offices. Which protocol will be used for effective voice
communication over the Internet?
(v) Which kind of network will it be between Delhi office and Ambala office?
34. a) Write a method/function COUNTLINES() in Python to read lines from a text file
CONTENT.TXT, and display those lines, which have @ anywhere in the line.
For example:
G20 @ India
G20 @ India
CName – String
Dept – String
Place – String
Salary – integer
Username – root
Password – job
Host – localhost
Help Sangeeta to write the program in Python for the above-mentioned task.