CS Self Test 1
CS Self Test 1
Class: 12
Marks : 70
EXAM NO. Time : 3 Hours
General Instructions:
(i) This question paper contains five sections, Section A to E.
(ii) All questions are compulsory.
(iii) Section A have 21 questions carrying 01 mark each.
(iv) Section B has 07 Very Short Answer type questions carrying 02 marks each.
(v) Section C has 03 Short Answer type questions carrying 03 marks each.
(vi) Section D has 04 Long Answer type questions carrying 04 marks each.
(vii) Section E has 02 questions carrying 05 marks each.
(viii) All programming questions are to be answered using Python Language only.
11 . Identify the correct possible output for the following Python code: 1
import random
for N in range(2,5,2):
print(random.randrange(1,N,end=’@’)
(a) 1@3@5@ (b) 2@3@
(c ) 1@4@ (d)1@3@
SECTION-B (7X2=14)
22. A) List out all the mutable and immutable data types in python.
B) Identify the types of following tokens. (2)
i) _Var_ ii) in
25. Identify the correct output(s) of the following code. Also write the
minimum and the maximum possible values of the variable t.
import random
W=[‘Pen’, ‘Pencil’, ‘Eraser’, ‘Bag’, ‘Book’]
for i in range(2,3):
(2)
f=random.randint(i,3)
t=random.randint(i-1,3)
print(W[f], W[t], sep= “:”)
I)
27.
A)Differentiate WHERE and HAVING clause in SQL with an
example
OR (2)
B)Write any two differences between DELETE and DROP
commands.
II)
A) Satheesh has created a database “school” and table
“student”. Now he wants to view all the databases present in
his laptop. Help him to write SQL command for that, also to
view the structure of the table he created.
OR
B) Write an SQL command to add the new column
PURCHASE_DATE of an already existing table named
PRODUCT.
28. Observe the following code carefully and rewrite it after removing all
syntax and logical errors. Underline all the corrections made.
def sepo_n(NUM):
SUM=0 (2)
PROD=1
for j in range(10:NUM)
if j%2=0:
SUM=SUM+j
else:
PROD=*j
print(SUM,PROD)
N=input(“Enter a number”)
seop_n(N)
SECTION-C (3X3=9)
29 A) Write a function AICOUNT() in Python, which should read each 3
character of a text file “DETAILS.TXT” and then count and display the
count of occurrence of alphabets A and I individually (including small
cases a and i too).
Example:
OR
Example:
text = "pythoncode"
count = {}
c=0
lst = []
for w in text:
if w not in lst:
lst.append(w)
count[w] = 0
c= c + 1
count[w] = count[w] + 1
print(count)
print(lst)
OR
def fun(N1,N2=10):
return N1 > N2
NUM= [10,21,14,56,32]
for I in NUM:
for J in range(1,I%5):
if J > len(NUM)//2:
else:
print(fun(30),'%',end=' ')
SECTION-D (4X4=4)
32. Consider the table EMPLOYEES as given below: 4
Emp_ID Name Department Salary Joining_Date
101 Amit IT 50000 2020-05-15
102 Nisha HR 60000 2019-07-10
103 Rohit IT 45000 2021-02-25
104 Riya Finance 55000 2018-11-23
105 Arjun Marketing 40000 2021-03-05
A) Write the following queries:
i) To display the total salary for each department, excluding
departments with a total salary greater than 100,000.
ii) To display the EMPLOYEES table sorted by salary in
ascending order.
iii) To display the distinct department names from the
EMPLOYEES table
iv) Display the total salary of employees whose joining date is
before 2020-01-01
OR
B) Write the output for the following queries:
i) SELECT name, salary from employees where salary
>50000;
ii) SELECT department, Count(*) as total_employees
FROM employees GROUP BY department;
iii) SELECT * FROM EMPLOYEES where
department=’IT’;
SELECT min(salary) from employees;
33 Write a program in Python that defines and calls the following user 4
defined functions:
i) add()-To add the data of a student to a CSV file ‘school.csv’.
Each record consists of a list with field elements as stuid,
sname and marks to store student id, student name and student
marks respectively.
ii) Search()- To display the records of the student whose marks is
more than 80.
34 Write SQL queries for (i) to (iv) on the basis of table ITEMS and 4
Traders
Table: ITEMS
CODE INAME QTY PRICE COMPANY TCODE
1001 Digital 120 11000 XENITA T01
pad
1006 Led 70 38000 SANTORA T02
screen
1004 Car 50 21500 GEOKNOW T01
Gps
system
1003 Digital 160 8000 DIGICLICK T02
Camera
1005 Pen 600 1200 STOREHOME T03
drive
TABLE: TRADERS
TCODE INAME CITY
T01 ELECTRONIC MUMBAI
SALES
T03 BUSY STORE CORP DELHI
T02 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 10,000 and 22,000(both values included)
iii) To display the number of items traded by each trader, joining
the items and traders tables.
iv) A) To increase the price of items by 10% whose quantity is
above 100.
OR
B) Write a query to display the Cartesian product of
ITEMS and TRADERS
SECTION-E (2X5=10)
36 A binary file “Book.dat” has structure [Bookno, Book_name, 5
Author,Price].
(i) Write a user defined function createfile(). To input data for a record
and add to Book.dat
ADMIN TRAINING
UNIT
UNIT
FINANCE RESOURCE
UNIT UNIT
UNIT NO.OF.COMPUTERS
ADMIN 140
FINANACE 25
TRAINNG 80
RESOURCE 65
OR
B) Mumbai firm is planning to connect to its Finance
department in Gujarat which is approximately 500 km away.
Which type of network out of LAN,WAN or MAN will be
formed ?Justify your answer