0% found this document useful (0 votes)
59 views

Selfstudys Com File

Uploaded by

visalini18012008
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views

Selfstudys Com File

Uploaded by

visalini18012008
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

SAMPLE QUESTION PAPER - 1

Computer Science (083)


Class XII (2024-25)

Time Allowed: 3 hours Maximum Marks: 70


General Instructions:
​This question paper contains 37 questions.
All questions are compulsory. However, internal choices have been provided in some questions. Attempt
only one of the choices in such questions.
The paper is divided into 5 Sections- A, B, C, D and E.
Section A consists of 21 questions (1 to 21). Each question carries 1 Mark.
Section B consists of 7 questions (22 to 28). Each question carries 2 Marks.
Section C consists of 3 questions (29 to 31). Each question carries 3 Marks.
Section D consists of 4 questions (32 to 35). Each question carries 4 Marks.
Section E consists of 2 questions (36 to 37). Each question carries 5 Marks.
All programming questions are to be answered using Python Language only.
In case of MCQ, text of the correct answer should also be written.
Section A
1. State true or false: [1]
Do both the following represent the same list.
['a', 'b', 'c']
['c', 'a', 'b']

2. Which of the following is not an aggregate function? [1]

a) Min b) With

c) Avg d) Sum

3. What is the best way to represent attributes in a large database? [1]

a) All of these b) Concatenation

c) Dot Representation d) Relational-and

4. What will be the output of the following Python code? [1]


def add (num1, num2):
sum = num1 + num2
sum = add(20, 30)
print(sum)

a) None b) Null

c) 50 d) 0

5. Discuss the utility and significance of Tuples, briefly. [1]

6. CDMA stands for? [1]


a) Call Division Multiple Access b) Channel Division Multiple Access

c) Cell Division Multiple Access d) Code Division Multiple Access

7. To read the entire remaining contents of the file as a string from a file object infi, we use [1]

a) infi.readlines( ) b) infi.read(all)

c) infi.readline( ) d) infi.read( )

8. Which command is used to display the name of existing databases? [1]

a) show databases; b) display databases;

c) result databases; d) output databases;

9. Which operator performs pattern matching? [1]

a) LIKE operator b) BETWEEN operator

c) INTO operator d) EXISTS operator

10. Write a line of code that writes "Hello world!" to a file opened with file object my file. [1]

11. State true or false: [1]


In Python, a variable is a placeholder for data.

12. Process of removing an element from stack is called ________. [1]

a) Evaluation b) Push

c) Create d) Pop

13. Differentiate between commands DROP TABLE and DROP VIEW in SQL. [1]

14. A ________ is a network spread across a small area connecting various related devices such as laptop, [1]
mobile phone, wifi, printers etc.

a) WAN b) MAN

c) PAN d) LAN

15. Which of the following four code fragments will yield following output? [1]
Ziva
Diva
Riva
[Notice blank lines in between]
Select all of the function calls that result in this output.

a) print('Ziva b) print('''ZivaDivaRiva''')
Diva
Riva')

c) print('Ziva\nDiva\nRiva') d) print('''Ziva
\nDiva
\nRiva''')

16. Which of the following sublanguages of SQL is used to define the structure of the relation, deleting [1]
relations and relating schemas?

a) Relational Schema b) DDL (Data Definition Language)

c) DML (Data Manipulation Language) d) Query

17. Find ODD parity bit for 11100011 [1]

a) 1 b) 2

c) 3 d) 0

18. Which command is used for finding the IP address and default gateway of your network? [1]

a) netstat b) ping

c) ipconfig d) ifconfig

19. Assertion (A): While creating series by specifying data as a scalar value, the index must be provided. [1]
Reason (R): The scalar value is repeated to match the length of the index.

a) Both A and R are true and R is the b) Both A and R are true but R is not the
correct explanation of A. correct explanation of A.

c) A is true but R is false. d) A is false but R is true.

20. Assertion (A): By using "a" access mode, it appends the content to the file if the file already exists with [1]
the specified name.
Reason (R): By using "w" access mode, It overwrites the existing file.

a) Both A and R are true and R is the b) Both A and R are true but R is not the
correct explanation of A. correct explanation of A.

c) A is true but R is false. d) A is false but R is true.

21. Assertion (A): A function doesn't accept the parameter. [1]


Reason (R): The function block is started with the colon (:) and block statements must be at the same
indentation.

a) Both A and R are true and R is the b) Both A and R are true but R is not the
correct explanation of A. correct explanation of A.

c) A is true but R is false. d) A is false but R is true.

Section B
22. Define the following terms: [2]
i. Amplitude modulation
ii. Frequency modulation

23. Given below is a table Item in database Inventory. [2]


ItemID ItemName Quantity UnitPrice
101 ABC 5 120
102 XYZ 7 70
103 PQR 8 65
104 XYZ 12 55
Riya created this table but forget to add column ManufacturingDate. Can she add this column after
creation of table? If yes, write the code where user’s name and password are system and test respectively.

24. To find the number is even or odd with compound statement. [2]

OR
Predict the output of the following code fragment.
b = 20
a = 90/b
print("value of a is :", a)

25. Which data will get added in table Company by following code? [2]
import mysql.connector
con = mysql.connector.connect(host = "localhost”,user = "system”,passwd = "hello”,database = "connect”)
cur = con.cursor()
sql = "insert into Company(Name, Dept, Salary) values (%s, %s, %s)"
val = ("ABC", "DBA", 35000)
cur.execute(sql, val)
con.commit()

26. Write a program that repeatedly asks from users some numbers until string 'done' is typed. The program [2]
should print the sum of all numbers entered.

OR
Predict the output of following code fragment:
fruit = { }
f1 = ['Apple', 'Banana', 'apple', 'Banana']
for index in f1:
if index in fruit:
fruit [index] += 1
else:
fruit[index] =1
print(fruit)
print (len(fruit))

27. Write a program that check to see if the file name exists, it will give you an error message, if not, it will [2]
create the file.

OR
Write a program to count the number of uppercase letters in a text file "Article.txt".

28. What are the errors in the following codes? Correct the code and predict output: [2]
i. total = 0;
def sum(arg1, arg2):
total = arg1 + arg2;
print("Total:", total)
return total;
sum(10, 20);
print("Total :", total)
ii. def Tot(Number) #Method to find Total
Sum = 0
for C in Range (1, Number + 1) :
Sum += C
RETURN Sum
print (Tot[3]) #Function Calls
print (Tot[6])

Section C
29. Consider a function with following header: [3]
def info(object, spacing = 10, collapse = 1)
Here are some function calls given below. Find out which of these are correct and which of these are
incorrect stating reasons?
For correct function call statements, specify the argument values too.
i. info(obj1)
ii. info(spacing=20)
iii. info(obj2, 12)
iv. info(obj11, object = obj12)
v. info(obj3, collapse = 0)
vi. info( )
vii. info(collapse = 0, obj3)
viii. info( spacing = 15, object = obj4)

OR
What will be the output of following programs?
i. num = 1
def myfunc():
return num
print(num)
print(myfunc())
print(num)
ii. num = 1
def myfunc():
num = 10
return num
print(num)
print(myfunc())
print(num)
iii. num = 1
def myfunc():
global num
num = 10
return num
print(num)
print(myfunc())
print(num)
iv. def display ():
print ("Hello", end = ' ')
display()
print("there!")

30. What do you understand by Union and Cartesian Product operations performed upon two relations? [3]

OR
a. A SQL table BOOKS contains the following column names:
BOOKNO, BOOKNAME, QUANTITY, PRICE, AUTHOR
Write the SQL statement to add a new column REVIEW to store the reviews of the book.
b. Write the names of any two commands of DDL and any two commands of DML in SQL.

31. From the program code given below, identify the parts mentioned below : [3]
1. def processNumber(x):
2. x = 72
3. return x + 3
4.
5. y = 54
6. res = processNumber(y)
Identify these parts: function header, function call, arguments, parameters, function body, main program.

OR
Answer the questions (i) to (iv) based on the following:
class Book
{
char Bno[20];
protected:
float Price;
public:
void GetB();
void ShowB();
};
class Member
{
char Mno[20];
protected:
char Name[20];
public:
void GetM();
void ShowM();
};
class Library : public Member, private Book
{
char Lname[20];
public:
void GetL();
void ShowL();
};
void main()
{
Library L;
}
i. Which type of Inheritance out of the following is illustrated in the above example?
- Single Level Inheritance, Multilevel Inheritance, Multiple Inheritance
ii. Write the names of all the data members, which are directly accessible by the member function GetL() of
class Library.
iii. Write the names of all the member functions, which are directly accessible by the member function
ShowL() of class Library.
iv. Write the names of all the members, which are directly accessible by the object L of class Library
declared in the main() function.

Section D
32. Write Addnew(Book) and Remove(Book) methods in Python to Add a new Book and Remove a Book [4]
from a List of Books, considering them to act as PUSH and POP operations of the data structure stack.

OR
Write a function to push any student's information to stack.

33. Write a point of difference between append (a) and write (w) modes in a text file. [4]
Write a program in Python that defines and calls the following user defined functions:
i. Add_Teacher() : It accepts the values from the user and inserts the record of a teacher to a csv file
'Teacher.csv'. Each record consists of a list with field elements as T_id, Tname and desig to store
teacher ID, teacher name and designation respectively.
ii. Search_Teacher() : To display the records of all the PGT (designation) teachers.

34. Give output for following SQL queries as per given table(s): [4]
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/1998 2000 M
4. TARUN 33 BASKETBALL 01/01/1998 1500 M
5. ZUBIN 36 SWIMMING 12/01/1998 750 M
6. KETAKI 36 SWIMMING 24/02/1998 800 F
7. ANKITA 39 SQUASH 22/02/1998 2200 F
8. ZAREEN 37 KARATE 22/02/1998 1100 F
9. KUSH 41 SWIMMING 13/01/1998 900 M
10. SHAILYA 37 BASKETBALL 19/02/1998 1700 M
i. SELECT COUNT (DISTINCT SPORTS) FROM CLUB;
ii. SELECT MIN(AGE) FROM CLUB WHERE SEX = "F";
iii. SELECT AVG(PAY) FROM CLUB WHERE SPORTS = "KARATE";
iv. SELECT SUM(PAY) FROM CLUB WHERE DATEOFAPP > {31/01/98};

OR
Write SQL queries for (a) to (d) based on the tables CUSTOMER and TRANSACT given below:
Table : CUSTOMER
CNO NAME GENDER ADDRESS PHONE
1001 Suresh MALE A-123, West Street 9310010010
1002 Anita FEMALE C-24, Court Lane 9121211212
1003 Harjas MALE T-1, Woods Avenue 9820021001
Table : TRANSACT
TNO CNO AMOUNT TTYPE TDATE
T1 1002 2000 DEBIT 2021-09-25
T2 1003 1500 CREDIT 2022-01-28
T3 1002 3500 CREDIT 2021-12-31
T4 1001 1000 DEBIT 2022-01-10
a. Write the SQL statements to delete the records from table TRANSACT whose amount is less than 1000.
b. Write a query to display the total AMOUNT of all DEBITs and all CREDITs.
c. Write a query to display the NAME and corresponding AMOUNT of all CUSTOMERs who made a
transaction type (TTYPE) of CREDIT.
d. Write the SQL statement to change the Phone number of customer whose CNO is 1002 to 9988117700 in
the table CUSTOMER.

35. Consider the table MobileMaster [4]


M_Id M_Company M_Name M_Price M_Mf_Date
MB001 Samsung Galaxy 4500 2014-02-12
MB002 Nokia N1100 2250 2011-04-15
MB003 Sony Experia M 9500 2017-11-20
MB004 Oppo SelfieEx 8500 2010-08-21
Write the Python code for the following
i. To display details of those mobiles whose price is greater than 8000.
ii. To increase the price of mobile Samsung by 2000.

Section E
36. Knowledge Supplement Organisation has set up its new center at Mangalore for its office and web-based [5]
activities. It has 4 blocks of buildings as shown in the diagram below:

Center to center distances between various blocks


Block A to Block B 50 m
Block B to Block C 150 m
Block C to Block D 25 m
Number of Computers
Block A 25
Block B 50
Block C 125
Block D 10
i. What type of network will be formed if all blocks are connected?
ii. Suggest the most suitable place (i.e., block) to house the server of this organisation with a suitable
reason.
iii. Suggest the placement of the following devices with justification
a. Repeater
b. Hub/Switch
iv. The organization is planning to link its front office situated in the city in a hilly region where cable
connection is not feasible, suggest an economic way to connect it with reasonably high speed.

37. Write SQL queries for (i) to (vii) on the basis of tables given below: [5]
Table: PRODUCTS
PID PNAME QTY PRICE COMPANY SUPCODE
101 DIGITAL CAMERA 14X 120 12000 RENBIX SOI
102 DIGITAL PAD l l i 100 22000 DIGI POP S02
104 PEN DRIVE 16 GB 500 1100 STOREKING SOI
106 LED SCREEN 32 70 28000 DISPEXPERTS S02
105 CAR GPS SYSTEM 60 12000 MOVEON S03
Table: SUPPLIERS
SUPCODE SNAME CITY
S01 GET ALL INC KOLKATA
S03 EASY MARKET CORP DELHI
S02 DIGI BUSY GROUP CHENNAI
i. To display the details of all the products in ascending order of product names (i.e., PNAME).
ii. To display product name and price of all those products, whose price is in the range of 10000 and
15000 (both values inclusive).
iii. To display the number of products, which are supplied by each supplier, i.e., the expected output should
be;
S01 2
S02 2
S03 1
iv. To display the price, product name, and quantity (i.e., qty) of those products which have a quantity of
more than 100.
v. To display the names of those suppliers, who are either from DELHI or from CHENNAI.
vi. To display the name of the companies and the name of the products in descending order of company
names.
vii. Obtain the outputs of the following SQL queries based on the data given in tables PRODUCTS and
SUPPLIERS above.
a. SELECT DISTINCT SUPCODE FROM PRODUCTS;
b. SELECT MAX (PRICE), MIN (PRICE) FROM PRODUCTS;
c. SELECT PRICE*QTY FROM PRODUCTS WHERE PID = 104;
d. SELECT PNAME, SNAME FROM PRODUCTS P, SUPPLIERS S WHERE P. SUPCODE = S.
SUPCODE AND QTY >100;

OR
Write SQL queries for (i) to (iv) and find outputs for SQL queries (v) to (viii), which are based on the tables:
TABLE: BOOK
Code BNAME TYPE
F101 The Priest Fiction
L102 German easy Literature
C101 Tarzan in the lost world Comic
F102 Untold story Fiction
C102 War heroes Comic
TABLE: MEMBER
MNO MNAME CODE ISSUEDATE
M101 RAGHAV SINHA LI 02 2016-10-13
M103 S ARTHAKJ OHN FI 02 2017-02-23
M102 ANISHA KHAN C101 2016-06-12
i. To display all details from table MEMBER in descending order of ISSUEDATE.
ii. To display the BNO and BNAME of all Fiction Type books from the table Book.
iii. To display the TYPE and number of books in each TYPE from the table BOOK.
iv. To display all MNAME and ISSUEDATE of those members from table MEMBER who have books issued
(i.e., ISSUEDATE) in the year 2017.
v. SELECT MAX (ISSUEDATE) FROM MEMBER
vi. SELECT DISTINCT TYPE FROM BOOK
vii. SELECT A.CODE, BNAME, MNO. MNAME FROM BOOK A. MEMBER B WHERE A.CODE=
B.CODE
viii. SELECT BNAME FROM BOOK WHERE TYPE NOT IN ("FICTION", "COMIC")
Solution
SAMPLE QUESTION PAPER - 1
Computer Science (083)
Class XII (2024-25)

Section A
1.
(b) False
Explanation:
False
The lists are ordered.
2.
(b) With
Explanation:
With is not an aggregate function. The avg is used to find the average, the sum is used to
sum the number of values and min is used to find the minimum.
3.
(b) Concatenation
Explanation:
Example inst sec and student sec
4. (a) None
Explanation:
None
5. The tuple is similar to lists but the value of the items stored in the list can be changed,
whereas the tuple is immutable, and the value of the items stored in the tuple cannot be
changed.
6.
(d) Code Division Multiple Access
Explanation:
CDMA stands for Code Division Multiple Access. In this, each user is allocated a unique
code sequence, that is used to encode/decode the original data.
7.
(d) infi.read( )
Explanation:
read( ) function reads the whole file and returns the text of the file as a string.
8. (a) show databases;
Explanation:
show databases;
9. (a) LIKE operator
Explanation:
LIKE operator is used in the WHERE clause allows us a search based operation on a
pattern.
10. myfile.write("Hello world!")
File object is myfile, and write() function writes string "Hello World!" into the file.
11.
(b) False
Explanation:
Variables are containers for storing data values whereas a placeholder is a pre-formatted
container into which content can be placed.
12.
(d) Pop
Explanation:
The process of removing an element from the stack is called Pop operation.
13. DROP TABLE statement is used to delete the table and all its data from the database
entirely. The syntax for DROP TABLE is DROP TABLE ;
DROP VIEW Removes an existing view from a database. DROP VIEW statement is used
to remove a view or an object view from the database. The syntax for DROP VIEW is
DROP VIEW ;
14.
(c) PAN
Explanation:
A Personal Area Network is a computer network organized around an individual person.
Personal area networks typically involve a mobile computer, a cell phone and/or a
handheld computing device.
15.
(d) print('''Ziva
\nDiva
\nRiva''')
Explanation:
print('''Ziva
\nDiva
\nRiva''')
16.
(b) DDL (Data Definition Language)
Explanation:
DDL (Data Definition Language) is the language which performs all the operation in
defining structure of relation.
17.
(d) 0
Explanation:
Parity refers to the number of bits set to 1 in the data item
Even parity - an even number of bits are 1
Odd parity - an odd number of bits are 1
A parity bit is an extra bit transmitted with a data item, chose to give the resulting bits
even or odd parity
Odd parity - data: 11100011, parity bit 0
18.
(c) ipconfig
Explanation:
ipconfig command displays all network interfaces and their configurations, including IP
addresses, subnet masks and default gateway.
19.
(c) A is true but R is false.
Explanation:
In order to create a Pandas series from an array with an index, we have to provide index
with the same number of elements as it is in array.
In order to create a Pandas series from scalar value, an index must be provided. The scalar
value will be repeated to match the length of index.
20.
(b) Both A and R are true but R is not the correct explanation of A.
Explanation:
In append mode, python creates a new file with the specified name if no such file exists. It
appends the content to the file if the file already exists with the specified name. In write
mode, python creates a new file with the specified name if no such file exists. It overwrites
the existing file.
21.
(d) A is false but R is true.
Explanation:
A function can accept one or more parameters (arguments), and it can be optional. The
function block starts with a colon (:), and block statements must be at the same
indentation, otherwise, there would be an indentation error in your program.
Section B
22. i. Amplitude modulation: In amplitude modulation, the amplitude of the carrier wave is
varied in proportion to the message signal, and the other factors like phase and
frequency remain constant.
ii. Frequency modulation: In Frequency modulation, a radio wave known as carrier is
modulated in frequency by the signal that is to be transmitted.
23. Yes, she can add new column after creation of table.
mycon = mysql.connector.connect(host = "localhost",user = "system",passwd = "test",datab
cursor = mycon.cursor()
cursor.execute("ALTER TABLE Item ADD ManufacturingDate Date NOT NULL")
mycon.close()

24. n = int(input("Enter a number:"))


print("The number is ",n)
d = n%2
if (d == 0):
print ("Remainder on division by 2 is :", d)
print ("The number is an even number.")
else:
print("Remainder on division by 2 is : ", d)
print("The number is an odd number.")

Output
Enter a number:45
The number is 45
Remainder on division by 2 is: 1
The number is an odd number.
OR
value of a is : 4.5
25. "ABC", "DBA", 35000
26. #Unknown Number of Numbers to Sum
total = 0
s = input ('Enter a number or "done":')
while s ! = 'done' :
num = int(s)
total = total + num
s = input('Enter a number or "done": ')
print ('The sum of entered numbers is', total)
OR
{'Apple' : 1}
{'Apple' : 1, 'Banana' : 1}
{'Apple' : 1, 'Banana' : 1, ’apple’ : 1}
{'Apple' : 1, 'Banana' : 2, 'apple' : 1}
3
27. import os
if os.path.isfile('test.txt’):
print ("You are trying to create a file that already exists!")
else :
f = open("text.txt",'w’)
If the text file test exists, the program will print "You are trying to create a file that already
exists!" else the file is opened in write mode, to create a new file with length 0.
OR
fileObject = open("Article.txt",r)
count = 0
str = fileObject.read()
for char in str:
if char.isupper():
count += 1
fileObject.close()
print ("Number of uppercase characters are ", count)
28. i. Wrong indentation for return statement. The return statement should be indented
inside the function.
Semicolons should be avoided (3 statements have it). In Python, semi-colons are
not needed to end the statement.
ii. Range() is not a valid function; it should be range()
RETURN is not a valid keyword. It should be return.
Function calls use parentheses, i.e., ( ) (not square brackets[ ]) to pass values. Thus
Function calls for Tot() would be as: Tot(3) and Tot(6).
Section C
29. i. Correct - obj1 is for positional parameter object; spacing gets its default value of 10
and collapse gets its default value of 1. The function call would become info(obj, 10,
1).
ii. Incorrect - Required positional argument (object) missing; required arguments cannot
be missed. This function call is incorrect.
iii. Correct - Required parameter object gets its value as obj2; spacing gets value 12 and
for skipped argument collapse, default value 1 is taken. The function call would
become info(obj2, 12, 1), which is correct.
iv. Incorrect - Same parameter object is given multiple values - one through positional
argument and one through keyword(named) argument. The same parameter cannot have
multiple values in a function call. Therefore, this function call is incorrect.
v. Correct - Required parameter object gets its value as obj3; collapse gets value 0 and
for skipped argument spacing, default value 10 is taken. The function call would be
info(obj3, 10,0), which is correct.
vi. Incorrect - Required parameter object's value cannot be skipped. Therefore, this
function call is incorrect.
vii. Incorrect - Positional arguments should be before keyword arguments. obj3 should be
passed before spacing and collapse values.
viii. Correct - Required argument object gets its value through a keyword argument.
OR
These are the outputs to the above code segments:
i. 1
1
1
ii. 1
10
1
iii. 1
10
10
iv. Hello there!
30. Cartesian Product is called the CROSS PRODUCT or CROSS JOIN. It combines the
tuples of one relation with all the tuples of the other relation. The Cartesian product of two
relations A and B is written as A × B. e.g, given two relations Student and Instructor as
shown below:
Student
Stud# Stud-Name Hosteler
S001 Meenakshi Y
S002 Radhika N
S003 Abhinav N
Instructor
Inst# Inst-Name Subject
101 K. Lai English
102 R.L. Arora Maths
The cartesian product of these two relations, Student × Instructor, will yield a relation
as :
Stud# Stud-Name Hosteler Inst# Inst-Name Subject
S001 Meenakshi Y 101 K. Lai English
S001 Meenakshi Y 102 R.L. Arora Maths
S002 Radhika N 101 K. Lai English
S002 Radhika N 102 R.L. Arora Maths
S003 Abhinav N 101 K. Lai English
S003 Abhinav N 102 R.L. Arora Maths
Union. The union operation produces a third relation that contains tuples from both the
operand relations which must be union-compatible. To denote the union of two relations X
and Y, we write as X ∪ Y which will contain all tuples of X and all tuples of Y in it.
OR
a. Adding a New Column "REVIEW": To add a new column named "REVIEW" to the
existing "BOOKS" table, we can use the following SQL statement:
ALTER TABLE BOOKS ADD REVIEW VARCHAR (255);
b. DDL Commands: Two common Data Definition Language (DDL) commands are:
CREATE TABLE: Used to create a new table.
ALTER TABLE`: Used to modify the structure of an existing table.
DML Commands: Two common Data Manipulation Language (DML) commands
are:
INSERT INTO: Used to add new records to a table.
UPDATE: Used to modify existing records in a table.

31. Function header def processNumber(x) : in line 1


Function call processNumber (y) in line 6
Arguments y in line 6
Parameters x in line 1
x = 72
Function body in lines 2 and 3
return x + 3
y = 54
Main program in lines 5 and 6
res = processNumber(y)
OR
i. Multiple Inheritance

ii. Lname of class Library


Name of class Member
Price of class Book

iii. GetL() of class Library


GetM(), ShowM() of class Member
GetB(), ShowB() of class Book

iv. GetL(), ShowL() of class Library


GetM(), ShowM() of class Member
Section D
32. Book = [ ]
def Addnew (Books, Name):
Book.append(Name)
print("Book", "Name", "inserted")
def Remove (Books) :
if Books == [ ] :
print ("stack is empty")
else :
print ("Book ",Books.pop(), "deleted")

OR
def push (stack):
s=[]
print "STACK BEFORE PUSH"
display(stack)
s.append(input("Enter student rollno?"))
s.append(raw_input("Enter student name"))
s.append(raw_input("Enter student grade"))
stack.append(s)
def display (stack):
l=len (stack)
print ("STACK CONTENTS")
for i in range(1-1,-1,-1):
print(stack[i])
stack = [ ]
print ("Creating Stack")
n=input("Enter the number of students")
for i in range (n)
student = [ ]
student.append (input("Enter student rollno?"))
student.append(raw_input("Enter student name"))
student. append(raw_input("Enter student grade"))
stack.append(student)
push(stack)
display(stack)
33. Difference between append (a) and write (w) modes in a text file:
a (append) mode - To open the file to write the content at the bottom(or end) of existing
content. It also creates the file, if it does not exist.
whereas
w (write) mode - To create a new file to write the content in it. It overwrites the file, if it
already exists.
import csv
def Add_Teacher():
fout=open("Teacher.csv","a",newline="\n")
T_id=int(input("Enter Teacher id: "))
Tname=input("Enter Teacher name: ")
desig=input("Enter Designation: ")
rec=[T_id,Tname,desig]
csvw=csv.writer(fout)
csvw.writerow(rec)
fout.close()

def Search_Teacher():
fin=open("Teacher.csv")
csvr=csv.reader(fin)
for record in csvr:
if record[2]=="PGT":
print(record)
fin.close()

Add_Teacher()
Search_Teacher()
34. OUTPUT
i. 4
ii. 34
iii. 1100
iv. 7800
OR
a. Delete records from table TRANSACT where the amount is less than 1000:
DELETE FROM TRANSACT WHERE AMOUNT < 1000;
b. Display the total AMOUNT of all DEBITs and all CREDITs:
SELECT TTYPE, SUM(AMOUNT) AS TotalAmount FROM TRANSACT
GROUP BY TTYPE;
c. Display the NAME and corresponding AMOUNT of all CUSTOMERs who made a
transaction type (TTYPE) of CREDIT:
SELECT C.NAME, T.AMOUNT FROM CUSTOMER C INNER JOIN
TRANSACT T ON C.CNO = T.CNO WHERE T.TTYPE = 'CREDIT';
d. Change the Phone number of customer whose CNO is 1002 to 9988117700 in the table
CUSTOMER:
UPDATE CUSTOMER SET PHONE = '9988117700' WHERE CNO = 1002;
35. i. import mysql.connector as mydb
mycon=mydb.connect(host="localhost",user="root",passwd="system",database="Admin
cursor=mycon.cursor()
sql="SELECT * FROM MobileMaster WHERE M_Price>8000"
try:
cursor.execute(sql)
display=cursor.fetchall()
for i in display:
print (i)
except:
mycon.rollback()
mycon.close()
ii. import mysql.connector as mydb
mycon=mydb.connect(host="localhost",user="root",passwd="system",database="Admin
cursor = mycon.cursor()
sql = "UPDATE MobileMaster SET M_Price=M_Price+2000 WHERE M_Company='S
try:
cursor.execute(sql)
mycon.commit()
except:
mycon.rollback()
mycon.close()

Section E
36. i. LAN
ii. Block C. The most suitable place/block to house the server of this organisation would
be Block C, as this block contains the maximum number of computers, thus decreasing
the cabling cost for most of the computers as well as increasing the efficiency of the
maximum computers in the network.
iii. a.

b.

For Layout 1, since the cabling distance between Blocks A and C, and that between B
and C are quite large, so a repeater each, would ideally be needed along their path to
avoid loss of signals during the course of data flow in these routes.
In the layout 2, a hub/switch each would be needed in all the blocks, to interconnect
the group of cables from the different computers in each block.
iv. The most economic way to connect it with a reasonable high speed would be to use
radio wave transmission, as they are easy to install, can travel long distances, and
penetrate buildings easily, so they are widely used for communication, both indoors and
outdoors. Radio waves also have the advantage of being omni directional, which is they
can travel in all the directions from the source, so that the transmitter and receiver do
not have to be carefully aligned physically.
37. i. SELECT * FROM PRODUCTS ORDER BY PNAME ASC; (* bydefault show all the
values)
ii. SELECT PNAME, PRICE FROM PRODUCTS WHERE ((PRICE = > 10000) AND
(PRICE = < 15000));
iii. SELECT SUPCODE, COUNT (PID) FROM PRODUCTS GROUP BY SUPCODE;
iv. SELECT PRICE, PNAME, QTY FROM PRODUCTS WHERE (QTY > 100);
v. SELECT SNAME FROM SUPPLIERS WHERE ((CITY = "DELHI") OR (CITY =
"CHENNAI"));
vi. SELECT COMPANY, PNAME FROM PRODUCTS ORDER BY COMPANY DESC;
vii. a. S03
b. 28000
1100
c. 550000

d. PNAME SNAME
DIGITAL CAMERA 14X GETALL INC
PENDRIVE 16 GB GETALL INC
OR
i. SELECT * FROM MEMBER ORDER BY ISSUEDATE DESC
ii. SELECT Code, BNAME FROM BOOK WHERE TYPE 'Fiction'
iii. SELECT COUNT(*), TYPE FROM BOOK GROUP BY TYPE
iv. SELECT MNAME, ISSUEDATE FROM MEMBER WHERE ISSUEDATE Like '2017
%'
v. MAX (ISSUE DATE) 2017-02-23
vi. DISTINCT (TYPE)
Fiction
Literature
Comic

vii. CODE BNAME MNO MNAME


L102 German easy M101 RAGHAV SINHA
F102 Untold Story M103 SARTHAK JOHN
C101 Tarzan in the lost world M102 ANISHA KHAN
viii. BNAME
German easy

You might also like