XII
XII
21. Assertion (A): The python abs() function is used to return the absolute value of a
pg. 2
number.
Reason (R): The python all() function doesn't accept an iterable object. [1]
a) Both A and R are true and R is the correct explanation of A.
b)Both A and R are true but R is not the correct explanation of A.
c) A is true but R is false. d) A is false but R is true.
Section B
22. How is Coaxial cable different from Optical Fibre? [2]
23. Consider the table Student whose fields are [2]
SCODE Name strode Points Grade
101 Amit NULL
102 Arjun NULL
103 Zaheer NULL
104 Gagan NULL
105 Kumar NULL
Write the Python code to update grade to A for all these students who are getting more than
8 as points.
24. What are data types? What are Python's built-in core data types? [2]
OR
Find the errors in the following code and write the correct code. s =
[11, 13, 15]
for n in len(s) :
tot = tot + s[n]
print(tot)
i. Underline the corrections.
ii. Write the reason! error next to it in the comment form.
25. Which record will get inserted in the table by the following code?
import mysql. connector as sqltor
mycon = sqltor .connect(host = "localhost”, user = "learner”, passwd = "fast”,
database=”test")
cursor = mycon.cursor()
query = "INSERT INTO books (title, isbn) VALUES(%s, %s)".%
(fUshakaalJ, '12678987036')
cursor.execute(query)
mycon.commitO [2]
26. Write a method in python to display the elements of list thrice if it is a number and
display the element terminated with if it is not a number.
pg. 3
For example, if the content of list is as follows:
List =['41', 'DROND', 'GIRIRAJ', ’13', 'ZARA']
The output should be 414141
DROND# GIRIRAD# 131313 ZARA# [2]
OR
Write a program that reads an integer N from the keyboard computers and displays
the sum of the numbers from N to (2 * N) if N is nonnegative. If N is a negative
number, then it's the sum of the numbers from (2 * N) to N. The starting and ending
points are included in the sum.
27. Write a function in Python to count the number of lowercase and uppercase
characters in a text file "Book.txt". [2]
28. What is raw input? [2]
Section C
29. Write a function which takes two string arguments and returns the string comparison
result of the two passed strings. [3]
30. Write separate user defined functions for the following:
i. PUSH(N) - This function accepts a list of names, N as parameter. It then pushes only
those names in the stack named OnlyA which contain the letter 'A'.
ii. POPA(OnlyA) - This function pops each name from the stack OnlyA and
displays it. When the stack is empty, the message "EMPTY" is displayed. For
example:
If the names in the list N are
['ANKITA', 'NITISH', 'ANWAR', 'DIMPLE', 'HARKIRAT']
Then the stack OnlyA should store
['ANKITA', 'ANWAR', 'HARKIRAT']
And the output should be displayed as
HARKIRAT ANWAR ANKITA EMPTY
31. What do you understand by the local and global scope of variables? How can you access
a global variable inside the function, if the function has a variable with the same name?
[3]
OR
Write the definition of a function Sum3(L) in Python, which accepts a list L of integers
and displays the sum of all such integers from the list L which end with the digit 3.
For example, if the list L is passed [123, 10, 13, 15, 23]
then the function should display the sum of 123, 13, 23, i.e. 159 as follows:
Sum of integers ending with digit 3 = 159
pg. 4
Section D
32. Write a program to implement a stack for these book details (book no., book name).
That is, now each item node of the stack contains two types of information - a book
no. and its name. Just implement Push and display operations. [4]
33. Consider the file p2.txt created above. Now predict the output of following code that
works with p2.txt. Explain the reason behind this output.
fp1 = open("p2.txt", "r") print(fp1.readline(20)) s1 = fp1.readline(30) print(s1)
print(fpl.readline(25)) [4]
34. Consider the following tables CABHUB and CUSTOMER and answer the
following parts of this question: [4]
Table: CABHUB
Vcode VehicleName Make Color Capacity Charges
100 Innova Toyota WHITE 7 15
102 SX4 Suzuki BLUE 4 14
104 C Class Mercedes RED 4 35
105 A-Star Suzuki WHITE 3 14
108 Indigo Tata SILVER 3 12
Table: CUSTOMER
CCode CName Vcode
1 Hemant Sahu 101
2 Raj Lai 108
3 Feroza Shah 105
4 Ketan Dhal 104
Give the output of the following SQL queries :
i. SELECT COUNT (DISTINCT Make) FROM CABHUB ;
ii. SELECT MAX(Charges), MIN(Charges) FROM CABHUB ;
iii. SELECT COUNT(*), Make FROM CABHUB ;
iv. SELECT VehicleName FROM CABHUB WHERE Capacity = 4;
pg. 5
35. Create following table using Python code.
Table Name = Customer
Database - xyzcorp.
Userid - Adminxyz
Password - Axydm12
[4]
CUSTNUMB CUST ADDRESS BALANCE CREDLIM SLSR
NAME NUMB
TINA 481Tilak
124 ADAMS lane, CP, 41800.75 50,000 3
Delhi
215
256 R VENKAT Mylapore, 100000.75 80,000 6
Chennai
BHUVNA 808, Bala Nagar,
567 BALAJI Hyderabad 57,000.75 50000 6
149, Plot
PRATHAM 182, sec-9
622 JAIN Dwarka, Delhi 57500.75 80,000 12
pg. 6
Section E
36. Learn Together is an educational NGO. It is setting up its new campus at Jabalpur
for its web-based activities. The campus has 4 compounds as shown in the diagram
below: [5]
Main Compound 5
Resource Compound 15
Training Compound 150
Accounts Compound 20
i. Suggest the most suitable place (i.e., compound) to house the server for
this
NGO. Also, provide a suitable reason for your suggestion.
ii. Suggest the placement of the following devices with justification:
a. Repeater
b. Hub/Switch
iii. The NGO is planning to connect its international office situated in Mumbai,
which out of the following wired communication link, you will suggest for
very high-speed connectivity?
a. Telephone Analog Line
b. Optical Fiber
c. Ethernet Cable
pg. 7
37. Write SQL queries for (i) to (iv) and find outputs for SQL queries (v) to
(viii),which
are based on the tables. [5]
TRAINER
TID TNAME CITY HIREDATE SALARY
101 SUNAINA MUMBAI 1998-10-15 90000
102 ANAMIKA DELHI 1994-12-24 80000
103 DEEPTI CHANDIGARH 2001-12-21 82000
104 MEENAKSHI DELHI 2002-12-25 78000
105 RICHA MUMBAI 1996-01-12 95000
106 MANIPRABHA CHENNAI 2001-12-12 69000
COURSE
CID CNAME FEES STARTDATE TID
C201 AGDCA 12000 2018-07-02 101
C202 ADCA 15000 2018-07-15 103
C203 DCA 10000 2018-10-01 102
C204 DDTP 9000 2018-09-15 104
C205 DHN 20000 2018-08-01 101
C206 0 LEVEL 18000 2018-07-25 105
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 displayTNAME, 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 Ans. city.
iv. SELECT TID. TNAME, FROM TRAINER WHERE CITY NOT IN
('DELHT', 'MUMBAI');
v. SELECT DISTINCT TID EROM COURSE;
vi. SELECT TID, COUNT(*), MIN (FEES) FROM COURSE. CROUP
BY TID HAVING COUNT(*)>1;
vii. SELECT COUNTS), SUM(FEES) FROM COURSE WHERE
pg. 8
STARTDATE< '2018-09- 15';
OR
Write SQL queries for (i) to (iv) and find outputs for SQL queries (v) to (viii),
Which are based on the table.
Table: CUSTOMER
CNO CNAME ADDRESS
101 Richa Jain Delhi
102 Surbhi Sinha Chennai
103 Lisa Thomas Bangalore
104 Imran Ali Delhi
105 Roshan Singh Chennai
Table: TRANSACTION
TRNO CNO AMOUNT TYPE DOT
T001 101 1500 Credit 2017-11-23
T002 103 2000 Debit 2017-05-12
T003 102 3000 Credit 2017-06-10
T004 103 12000 Credit 2017-09-12
T005 101 1000 Debit 2017-09-05
pg. 9
viii. SELECT DISTINCT CNO FROM TRANSACTION
pg. 10