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

Set 1

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
62 views

Set 1

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

Sample Question Paper - 1

Class: XIlI Session: 2023-24


Computer Science (083)

Time Allowed: 3 hours Maximum Marks: 70


General Instructions:
® Please check this question paper contains 35 questions.
e The paper is divided into 4 Sections- A, B, C, D and E.
e Section A, consists of 18 questions (1 to 18). Each question carries 1 Mark.
e Section B, consists of 7 questions (19 to 25). Each question carries 2 Marks.
e Section C, consists of 5 questions (26 to 30). Each question carries 3 Marks.
e Section D, consists of 2 questions (31 to 32). Each question carries 4 Marks.
e Section E, consists of 3 questions (33 to 35). Each question carries 5 Marks.
e All programming questions are to be answered using Python Language only.
Section A
1. State true or false: [1]
Do both the following represent the same list.
[a) ', 'c']
[c, a, 'b']

2. Which operator performs pattern matching? [1]

a) LIKE operator b) BETWEEN operator

c) None of these d) EXISTS operator

3. Which of the following is correct to retrieve any character at index 'i' in string 's'? [1]

a) s.__getitem__(i) b) s.getitem(i-1)

c)s.__getitem__(i-1) d) s.getitem(i)

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

value =50
def display(N):
global value
value = 25
if N%7==0:
value = value + N
else:
value =value - N
print(value, end="#")
display(20)
print(value)

a) 5#50# b) 50#50

c) 50#5 d) 50#30

Signals generated by an operating system to send it over phone line must be further [1]
converted into a/an

a) analog signal b) microwave

c) AC signal d) digital signal

To read the next line of the file from a file object infi, we use (1
a) infi.read() b) infi.readlines()

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

What is default value of host? (1]


a) localhost b) global host

c) Host d) None of these

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

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

c) DML (Data Manipulation d) Query


Language)

Which function is used to read all the characters? [1


a) readcharacters( ) b) read( )

c) readchar( ) d) readall( )

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


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

a) None b) Null

c) 50 d)o

11. Consider the following operation performed on a stack of size 5. (1


Push(1); Pop(); Push(2); Push(3); Pop(); Push(4); Pop(); Pop(); Push(5);
After the completion of all operation, the number of elements present in stack are:

a)4 b)3

o)1 d)2

12. Which of the following is the use of function in python? [1]


a) Functions don't provide better b) Functions are reusable pieces of
modularity for your application programs

c) you can't also create your own d) All of these


functions

13. State true or false: [1]


PING checks if a computer is connected to a network or not.

14. The process of converting a data type into another data type is known as [1]
a) expression b) type conversion

c) operator d) comparison

15. Fill in the blanks: [1]


operator is used to match a value similar to specific pattern in a column
using % and _.

16. CDMA stands for? [1]


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

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


17. Assertion (A): The intersection_update() method is different from the intersection() [1]
method.
Reason (R): intersection_update() method modifies the original set by removing the
unwanted items.

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

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

18. Assertion (A): CSV stands for comma-separated values, which is defined as a simple [1]
file format that uses specific structuring to arrange tabular data.
Reason (R): The csv module is used to handle the CSV files to read/write and get
data from specified columns.

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

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

Section B
19. Answer: [2]
(i) i. Whatis modulation? [1]
ii. Write one characteristic each for 2G and 3G mobile technologies. [1]

(i) OR
i. What are the basic methods of checking errors in the data being [2]
transmitted over networks?

20. Write Python code to create a table location with the following fields [2]

id id of the location
bidycode code of the building
room type of rooms
capacity capacity of the room

21. Rewrite the following code in python after removing all syntax error(s). [2]
Underline each correction done in the code.
30=To
for K in range(0,To)
IF k%4==0:
print (K * 4)
Else:
print (K + 3)

OR
What is the output of the following?
True = False
while True:
print(True)
break

22. Answer: [2]

(i) Which command is used to import mysql.connector package with an identifier? [1]

(i) What will the following query do? [1]


import mysgl.connector
db = mysgl.connector.connect..)
cursor = db.cursor()
person_id = input ("Enter required person id")
lastname = input ("Enter required lastname")
db.execute("INSERT INTO staff (person_id, lastname) VALUES ({}, '{}') "
format(person__id, lastname))
db.commit( )
b.close()

23. Differentiate between a logical error and syntax error. Also, give suitable examples of [2]
each in Python.

OR
As immutable types cannot be changed in place then the following code should raise an
error which modifies an int (an immutable type) variable. But it produces no error. Why?
A=22
A+=2

24. Consider a binary file Employee.dat containing details such as empno:ename:salary [2]
(separator ":'). Write a Python function to display details of those employees who
are earning between 20000 and 40000. (Both values inclusive)

OR
A text file(say an.txt) contains alphanumeric text. Write a program that reads this text
file and prints only the numbers or digits from the file.

25. Write a function that takes a positive integer and returns the one's position digit of [2]
the integer.
Section C

26. Answer: [3]


(i) Write a program which will find all such numbers which are divisible by 7 but [1.5]
are not a multiple of 5, between 200 and 300 (both included).

(ii) Predict the output. [1.5]

dic={a':1,'b':2,'c':3,'d" : 4}
print(dic)
if 'a' in dic:
del dic['a']
print(dic)

27. Write a method in Python to find and display the prime number between 2 to n. [3]
Pass n as an argument to the method.

28. Create a table named Programmers with the following structure: 3]


P_Name VARCHAR(20)
DOJ Date
SAL NUMBER
i. Display the name of the programmer, which has the highest salary.
ii. Update the salary of all programmer by 2000, whose name start with letter R.

OR
What are Tuples in a SQL Table? Write a suitable example with a SQL Table to illustrate
your answer.

29. A text file "Quotes.Txt" has the following data written in it : [3]
Living a life you can be proud of Doing you
Spending your time with people and activities that are important to you
Standing up for things that are right even when it's hard
Becoming the best version of you
Write a user defined function to display the total number of words present in the
file.

30. Write a function that takes a sorted list and a number as an argument. Search for 3]
the number in the sorted list using binary search.
Section D
31. Ayurveda Training Educational Institute is setting up its Centre in Hyderabad with [5]
three specialized departments for Orthopaedics, Neurology and Paediatrics along
with an administrative office in separate buildings. The physical distances between
these department buildings and the member of computers to be installed in these
departments and administrative offices are given as follows. You, as a network
expert have the shortest distances between various locations in meters:
Administrative office to Orthopaedics unit 55
Neurology unit to Administrative office 30

Orthopedics unit to Neurology unit 70

Paediatrics unit to Neurology unit 50

Pediatrics unit to Administrative office 40


Paediatrics unit to Orthopaedics unit 110
The number of Computers installed at the various location is as follows:

Paediatrics unit 40
Administrative office 140
Neurology unit 50
Orthopedics unit 80

‘ Orthopaedics unit Poediatrics unit


Neurology unit

i. Suggest the most suitable location for the main server of this institution to get
efficient connectivity.
ii. Suggest the cable layout for effective network connectivity of the building having
a server with all the other buildings.
iii. Suggest a device to be installed in each of these building for connecting
computers installed within the building out of the following:
* Gateway
e Modem
® Switch
iv. Suggest the topology of the network and network cable for efficiently connecting
in each of the building one of the following: Topologies: Bus Topology, Star
Topology, Network Cable: Single Pair Telephone Cable, Coaxial Cable, Ethernet
Cable.

32. Write SQL queries for (i) to (vii) on the basis of table ITEMS and TRADERS:
Table: ITEMS
ICODE |INAME QTY |PRICE |[COMPANY TCODE

1001 DIGITAL PAD 12i 120 |11000 |XENITA TO1l

1006 LED SCREEN 40 70 38000 |[SANTORA TO2

1004 CAR GPS SYSTEM 50 [21500 |GEOKNOW T01


1003 DIGITAL CAMERA 12X 160 |[8000 DIGICLICK TO2

1005 PEN DRIVE 32 GB 600 |1200 STOREHOME TO3

Table: TRADERS

TCode TName City


101 ELECTRONIC SALES MUMBAI
103 BUSY STORE CORP DELHI

102 DISP HOUSE INC CHENNAI

i. To display the details of all the items in ascending order of item names (i.e.,
INAME).
ii. To display item name and price of all those items, whose price is in the range of
10000 and 22000 (both values inclusive).
iii. To display the number of items, which are traded by each trader. The expected
output of this query should be:
TO012T7022T031
iv. To display the price, item name and quantity (i.e., qty) of those items which have
quantity more than 150.
v. To display the names of those traders, who are either from DELHI or from
MUMBAI.
vi. To display the names of the companies and the names of the items in descending
order of company names.
vii. Obtain the outputs of the following SQL queries based on the data given in tables
ITEMS and TRADERS above.
a. SELECT MAX (PRICE), MIN (PRICE) FROM ITEMS;
b. SELECT PRICE*QTY FROM ITEMS WHERE CODE=1004;
c. SELECT DISTINCT TCODE FROM ITEMS;
d. SELECT INAME, TNAME FROM ITEMS I, TRADERS T WHERE | TCODE=T.TCODE
AND QTY<100;

OR
Consider the following tables WORKER and PAYLEVEL and answer (a) and (b) parts of this
question:
Table: WORKER
ECODE |NAME DESIGN PLEVEL |DOJ DOB

11 Radhe Shyam Supervisor |P001 13-5ep-2004 |23-Aug-1981


12 Chander Nath Operator P003 22-Feb-2010 12-Jul-1987

13 Fizza Operator P003 14-Jun-2009 14-Oct-1983


15 Ameen Ahmed Mechanic P002 21-Aug-2006 13-Mar-1984

18 Sanya Clerk P002 19-Dec-2005 09-Jun-1983

Table: PAYLEVEL

PLEVEL PAY ALLOWANCE

POO1 26000 12000


P002 22000 10000
P003 12000 6000

a. Write SQL commands for the following statements:


i. To display the name of all Workers in descending order of DOB.
ii. To display NAME and DESIGN of those Workers, whose PLEVEL is either POO1 or
P002.
iii. To display the content of all the workers table, whose DOB is in between '19- JAN-
1984' and '18-JAN-1987'.
iv. To add a new row with the following: 19, 'DayaKishore', 'Operator’, 'P003', '19- Sep-
2008', 17-Jul-1984'
b. Give the output of the following SQL queries:
i. SELECT COUNT (PLEVEL), PLEVEL FROM WORKER GROUP BY PLEVEL;
ii. SELECT MAX(DOB), MIN(DOJ) FROM WORKER;
iii. SELECT Name, PAY FROM WORKER W, PAYLEVEL P WHERE W.PLEVEL = P.PLEVEL
AND W.ECODE < 13;
iv. SELECT PLEVEL, PAY+ ALLOWANCE FROM PAYLEVEL WHERE PLEVEL= "P003 ";
33. Answer: [5]

(i) i. Whatis the use of WHERE clause in SQL? [1]


ii. Answer the questions (i) to (v) on the basis of the following tables SHOPPE [4]
and ACCESSORIES.
TABLE: SHOPPE
Id SName Area
S001 ABC Computeronics CcpP

S002 All Infotech Media GKII


S003 Tech Shoppe cP
S004 Geeks Tecno Soft Nehru Place
S005 Hitech Tech Store Nehru Place

TABLE: ACCESSORIES
No Name Price Id
AO1 Mother Board 12000 So1
A02 Hard Disk 5000 S01
A03 Keyboard 500 S02
A04 Mouse 300 S01

AO5 Mother Board 13000 S02


AO6 Keyboard 400 S03
A07 LCD 6000 S04
TO8 LCD 5500 S05

TO9 Mouse 350 S05

T10 Hard Disk 4500 S03


i. To display Name and Price of all the Accessories in ascending order of
their Price.
ii. To display Id and SName of all Shoppe located in Nehru Place.
iii. To display Minimum and Maximum Price of each Name of Accessories.
iv. To display Name, Price of all Accessories and their respective SName,
where they are available.
v. To display name of accessories whose price is greater than 1000.

(ii) OR
i. Give the syntax of DROP statement. [1]

ii. Consider the following table STORE. Write SQL commands for the following [4]
statements.

Table: STORE
ItemNo Item Scode Qty Rate LastBuy

2005 Sharpener 23 60 8 31-Jun-09


Classic
2003 Ball Pen 0.25 22 50 25 01-Feb-10

2002 Gel Pen


Premium
21 150 12 | 24-Feb-10

2006 Gel Pen


Classic
21 250 20 | 11-Mar-09
2001 Eraser Small 22 220 6 19-Jan-09
2004 Eraser Big 22 110 8 02-Dec-09
2009 Ball Pen 0.5 21 180 18 03-Nov-09
i. To display details of all the items in the Store table in ascending order of
LastBuy.

Page 11
ii. To display ItemNo and Item name of those items from Store table whose
Rate is more than 15 Rupees.
iii. To display the details of those items whose Suppliers code (Scode) is 22
or Quantity in Store (Qty) is more than 110 from the table Store.
iv. To display the Minimum Rate of items for each Supplier individually as
per Scode from the table store.

Section E
34. Write a program to perform binary search on a list of strings arranged in descending [4]
order.

35. Write SQL commands for (i) to (v) on the basis of table EMPLOYEE [4]
TABLE: EMPLOYEE

SNO NAME BASIC DEPARTMENT DATO FAPP | AGE | SEX


1 KARAN 8000 PERSONNEL 27/03/97 35 M

2 DIVAKAR 9500 COMPUTER 20/01/98 34 M

3 DIVYA 7300 ACCOUNTS 19/02/97 34 F

4 ARUN 8350 PERSONNEL 01/01/95 33 M


5 SABINA 9500 ACCOUNTS 12/01/96 36 F

6 JOHN 7400 FINANCE 24/02/97 36 M

7 ROBERT 8250 PERSONNEL 20/02/97 39 M

8 RUBINA 9450 MAINTENANCE 22/02/98 37 F


9 VIKAS 7500 COMPUTER 13/01/94 41 M

10 MOHAN 9300 MAINTENANCE 19/02/98 37 M

i. Which command will be used to list the names of the employees, who are more
than 34 years old sorted by NAME.
a. SELECT NAME FROM EMPLOYEE WHERE AGE>34 ORDER BY NAME;
b. SELECT * FROM EMPLOYEE WHERE AGE>34 ORDER BY NAME;
c. SELECT NAME FROM EMPLOYEE WHERE AGE>34;
d. SELECT NAME FROM EMPLOYEE AGE>34 ORDER BY NAME;

Page 12
ii. Write a query to display a report, listing NAME, BASIC, DEPARTMENT and annual
salary. Annual salary equals to BASIC * 12.
iii. Insert the following data in the EMPLOYEE table
11, 'VIJAY', 9300, 'FINANCE', '13/7/98', 35, "M"
iv. Write a query to count the number of employees, who are either working in
PERSONNEL or COMPUTER department.
v. Write the degree and cardinality of the table EMPLOYEE.


Solutions


——
Section A



(b) False

——
Explanation: False

——
The lists are ordered.

——
2. (a) LIKE operator

.
Explanation: LIKE operator is used in the WHERE clause allows us a search based

S
operation on a pattern.

.
3. (a) s.__getitem__(i)

e
Explanation: It is the correct syntax to call character at index i of string s

e
(c) 5045

e
Explanation: 50#5

e
5. (a) analog signal

e
Explanation: An analog signal is any continuous signal for which the time-varying

e
feature of the signal is a representation of some other time-varying quantity, i.e.,

e
analogous to another time-varying signal. Analog signals produce too much

e
noise. Examples:- Human voice, Thermometer, Analog phones, etc.

e
e
(c) infi.readline()

e
Explanation: readline() function reads a line from the file pointer position.

e
7. (a) localhost
Explanation: localhost

e
e
(b) DDL (Data Definition Language)

e
Explanation: DDL (Data Definition Language) is the language which performs all the

e
operation in defining structure of relation.

.
e
(b) read()
.
Explanation: read( ) function reads the whole file and returns the text as a string.
.

10. (a) None


e

Explanation: None
e

11.
e

(c)1
e

Explanation: 1
12.
e

(b) Functions are reusable pieces of programs


e

Explanation: Functions are reusable pieces of programs. They allow you to give a name
e
b
to a block of statements, allowing you to run that block using the specified name
anywhere in your program and any number of times.
13. (a) True
Explanation: True
14.
(b) type conversion
Explanation: type conversion
15. 1. LIKE
16.
(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.
17. (a) Both A and R are true and R is the correct explanation of A.
Explanation: The intersection_update() method is different from the intersection()
method since it modifies the original set by removing the unwanted items, on the other
hand, the intersection() method returns a new set removing the unwanted items.
18.
(b) Both A and R are true but R is not the correct explanation of A.
Explanation: CSV stands for "comma-separated values", which is defined as a simple
file format that uses specific structuring to arrange tabular data. It stores tabular data
such as spreadsheets or databases in plain text and has a common format for data
interchange. In python, the csv module is used to handle the CSV files to read/write and
get data from specified columns.
Section B
19 . Answer:
(i) i. The process of altering the characteristics (amplitude or frequency etc.) of a high-
frequency wave called the carrier wave so that it can carry low-frequency
information along with it while being transmitted, is called modulation.
ii. 2G networks primarily involve the transmission of voice information while 3G
technology provides the additional advantage of data transfer.
(ii) OR
i. There are many methods of checking or detecting errors in the data transmitted.
The four simplest ones are:
i. Single dimensional parity checking
ii. Two-dimensional parity checking
iii. Checksum
iv. Cyclic Redundancy Check (CRC)

20 . import MySQLdb
db = MySQLdb.connect("localhost", "Admin", "Ad123", "HMD")
cursor= db.cursor()
cursor.execute("DROP TABLE IF EXISTS Location")
sql="""Create Table location (id Numeric(5) PRIMARY KEY, bidycode varchar(10) Not
Null,
room varchar(6) Not Null , Capacity Numeric(5) Not Null)" " "
cursor.execute(sql)
db.close()
. To = 30 # variable name should be on LHS
for K in range(0, To):# : was missing
if k%4 == 0: # IF should be in lowercase; i.e; if
print (K * 4)
else: # else should be in lower case
print (K + 3)
OR
The above code will give Error because keyword True has been used as variable (in first
line of code True = False). We cannot use keywords as variables or any other identifiers.
22 . Answer:
(i) import mysql.connector as identifier_name
e.g.
import mysgl.connector as mydb
(i) It will add a new record in the database after obtaining values of person-id, and
lastname from user.

23 . Differences between logical error and syntax error are as follows:


Logical Error Syntax Error
It occurs when statements are wrongly
It occurs because of wrong implementation
written violating rules of the
of logic.
programming language.
With logical errors, the code is syntactically | With syntax errors, the code is not
correct and compiler will not show any syntactically correct and compiler will
error message. show the error messages.
It produces the output, but undesired. It does not produce any output.
e.g. in place of (c = a*b); if by mistake (c = a|e.g. in place of (a == b); if by mistake (a ==
+b); is written, it will be a logical error. b); is written, it will be a syntax error.
OR
In the given code, A is an int type variable, which is an immutable type, which means its
value cannot change in place (i.e., in the same memory location). So, when the second
statement gets executed, the variable no longer points to the same memory as it was in
statement 1. So internally it is made to point to a new location which stores its value
24. So, in a way a new A is created after statement 2.
Thus, when we make changes in an immutable type variable, internally Python creates
a new variable having the new value and hence no error is reported. Change of the
value does not take place in the same memory location for an immutable type.

24. def Readfile():


i=open("Employee.dat", "rb+")
x=i.readline()
while(x):
I=x.split(":")
if (20000>=float(1[2])<=40000):
print(x)
x=i.readline()

OR
fileObject = open ("an.txt", "r")
for line in fileObject:
words = line.split()
for word in words:
for char in word:
if (char.isdigit()):
print(char)
25. def get_ones_digit(num): # return the ones digit of the integer num
ones_Digit = num % 10
return ones_Digit
get_ones_digit function returns the digit at one's position of number num.
Section C
26. Answer:

@ 1=0
for i in range(200, 300):
if(i%7==0) and (i%5!=0)
l.append (str(i))
print(",'.join(l))

(ii) Output
{d':4,'a":1,'c":3,'b": 2}
{d':4,'c":3,'0': 2}

27. def prime(n) :


for numin range (2, n) :
is_prime=1
foriin range (2, num):
if num % i==0:
is_prime =0
if is_prime == 1:
print (num)
28. i. SELECT P_Name MAX (SAL)
FROM Programmers;
ii. UPDATE Programmers SET SAL = SAL + 2000 WHERE P_Name LIKE 'R%';
OR
In DBMS, this row or record is known as a tuple. Hence In DBMS, a tuple is just a row
representing some associated data for a certain entity, such as a user, student, or
employee. You can see from the figure above that a tuple is a row of information about
a single item, such as its name, age, marks, etc.
29. User define function to display total number of words in a file:
def countwords():
s=open ("Quotes.txt", 'r')
f=s, read()
z =f. split()
count=0
foriinz:
count=count +1
print("Total number of words", count)
30. def binary_search(sorted_list, number):
low =0
high = len(sorted_list)
found = False
while (low < high) and found = False:
mid = int(low+high/2)
if sorted_list[mid] == number:
print ("Number found at",mid)
found = True
break
elif sorted_list[mid] == number:
low = mid + 1
else:
high = mid -1
if low >= high:
print ("Number not found")
max_range = input("Enter Count of numbers:")
numlist = []
for i in range(0, max_range):
numlist_append(input("Enter number : "))
numlist.sort()
print ("Our list : ", numlist)
number = input("Enter the number")
binary_search(numlist, number)

Section D
31. i. Administrative Office is the most suitable location for the main server of this
institution to get efficient connectivity.

| Administrative office |

[Orthopaedics unit [Neurology unit [Paediatrics unif

iii. Switch to be installed in each of these building for connecting computers installed
within the building
iv. Topology: Star Topology
Network Cable Ethernet Cable/Coaxial Cable
32. i. SELECT * FROM ITEMS ORDER BY INAME ASC;
ii. SELECT INAME, PRICE FROM ITEMS WHERE PRICE = > 10000 AND PRICE = < 22000;
iii. SELECT TCODE, COUNT (CODE) FROM ITEMS GROUP BY TCODE;
iv. SELECT PRICE, INAME, QTY FROM ITEMS WHERE QTY > 150;
v. SELECT TNAME FROM TRADERS WHERE (CITY = "DELHI") OR (CITY = "MUMBAI")
vi. SELECT COMPANY, INAME FROM ITEMS ORDER BY COMPANY DESC;
vii. a. 38000
1200
b. 1075000
. TO3
o

d. LED SCREEN 40 DISP HOUSE INC CAR GPS SYSTEM ELECTRONICS sales
OR
i. SELECT NAME FROM WORKER ORDER BY DOB DESC;
o

ii. SELECT NAME, DESIGN FROM WORKER WHERE PLEVEL="P001" OR PLEVEL=


"P002"; OR
SELECT NAME, DESIGN FROM WORKER WHERE PLEVEL IN ('P001', 'P002');
jii. SELECT * FROM WORKER WHERE DOB BETWEEN '19-JAN-1984' AND '18- JAN-
1987';
iv. INSERT INTO WORKER VALUES (19, "DayaKishore", "Operator", "P003", '19-Sep-
2008', 17-Jul-1984');
b. i.|count (PLEVEL) PLEVEL
1 P0O01

2 P002

2 P0O03
ii. |Max (DOB) Min (DOJ)
12-Jul-1987 13-Sep-2004

iii. [Name Pay

Radhe Shyam 26000


Chander Nath 12000

iv. | Plevel Pay


P003 18000

33. Answer:
(i) i. The WHERE clause is used to extract only those records that fulfil a specified
criteria.

ii. i. SELECT Name, Price


FROM ACCESSORIES
ORDER BY Price;

ii. SELECT Id, SName


FROM SHOPPE
WHERE Area='Nehru Place';

iii. SELECT MIN (Price) "Minimum Price", MAX(Price) "Maximum Price", Name
FROM ACCESSORIES
GROUP BY Name;
iv. SELECT Name, Price, SName
FROM ACCESSORIES A, SHOPPE S
WHERE A.ld = S.1d;

but this query enable to show the result because A.Id and S.Id are not identical.

V. SELECT Name From ACCESSORIES


WHERE Price>1000;

(ii) OR
i. DROP TABLE table_name;
ii. i.SELECT *
FROM STORE
ORDER By LastBuy ;
ii. SELECT ItemNo, Item
FROM STORE
WHERE Rate >15 ;
jii. SELECT *
FROM STORE
WHERE Scode =22 OR Qty > 110 ;
iv. SELECT Scode, Min(Rate)
FROM STORE
GROUP By Scode;

Section E
34. def bsearch(strarr, str):
beg=0
last=len(strarr)-1
while(beg<=last):
mid=(beg+last)/2
if strarr[mid]==str:
return mid
elif strarr[mid]>=str:
beg=mid+1
else:
last=mid-1
else:
return False
---Main---
N=int(raw_input(“Enter no. of elements of the array”.)
Print (“\n Enter strings in descending order:”)
Ar=[" “*N
Foriin range (N):
Ar [i] raw_input (“String”+i+": "
Item = raw_input(“Enter string to be searched:”)
foundat=bsearch(Ar, Item)
if foundat:
print “\n Element found at”, foundat
else:
print "\n String Net Fount"

35. i. (a) SELECT NAME FROM EMPLOYEE WHERE AGE>34 ORDER BY NAME;
ii. SELECT NAME, BASIC, DEPARTMENT, BASIC*12 "Annual Salary" FROM EMPLOYEE;
jii. INSERT INTO EMPLOYEE VALUES(11, 'VIJAY’, 9300, 'FINANCE', ‘13/7/98', 35, 'M");
iv. SELECT COUNT(*) FROM EMPLOYEE
WHERE DEPARTMENT='PERSONNEL" OR DEPARTMENT='COMPUTER";
v. Degree of the given table is 7 and cardinality is 10.

You might also like