Sei sulla pagina 1di 5

Sri Kumaran Children’s Home CBSE

II Terminal Examination 2018 - 2019


Class: XI Sri Kumaran Children’s
Subject: Computer Science Home - CBSE
Marks: 50
Date: 14.12.2018 Time: 2 Hrs.

General Instructions
i) All the questions are compulsory.
ii) Programming Language: Python.
iii) Database: MySQL
iii) Give appropriate examples wherever necessary.

1. Find the output of :


i. [2 ½]
a=[1,2,3,4,5,6,7,8,9]
print(a[::2])
a[::2]=10,20,30,40,50
print(a)
print(a[3:0:-1])
arr = [[1, 2, 3, 4],
[4, 5, 6, 7],
[8, 9, 10, 11],
[12, 13, 14, 15]]
for i in range(0, 4):
print(arr[i].pop())

ii. [1]
numberGames = {}
numberGames[(1,2,4)] = 8
numberGames[(4,2,1)] = 10
numberGames[(1,2)] = 12
sum = 0
for k in numberGames:
sum += numberGames[k]
print(len(numberGames) + sum)
print(numberGames)

iii. [½]
box = {}
jars = {}
crates = {}
box['biscuit'] = 1
box['cake'] = 3
jars['jam'] = 4
crates['box'] = box
crates['jars'] = jars
print(len(crates['box']))
iv. [½]
a=(1,2,3)
b=('A','B','C')
c= zip(a,b)
c= tuple(c)
print(c)
v. [½]
T = (1, 2, 3, 4, 5, 6, 7, 8)
print(T[T.index(5)], end = " ")
print(T[T[T[6]-3]-6])

vi. [1]
names1 = ['Amir', 'Bear', 'Charlton', 'Daman']
names2 = names1
names3 = names1[:]

names2[0] = "Alice"
names3[1] = "Bob"

sum = 0
for ls in (names1, names2, names3):
if ls[0] == "Alice":
sum += 1
if ls[1] == "Bob":
sum += 10

print(sum)

1. Find the errors in :

a. my_tuple = (1, 2, 3, 4) [1]


my_tuple[0]=2
a,b,c,d,e = my_tuple

b. d1 = {[1,2,3]:40, [5,6,7]:45} [1]


d2 = {1:466, 2:45}
if (d1 > d2):
print(“1”)
d1[4]=50
d1[(6,7)] = 25
d1 = d1 + d2
c. L1 = [1,2,3,5] [1]
L2 = [1,3,5,8]
An = L1.remove(7)
An = L2.remove(8)
print(An+2)

d. s=”This is it!” [1]


s1=s [ : 5]
s2=s [5 :]
s3=s1 * s2
s4=s2 + 3͛͛
s5=s1+3

2. What will be stored in variables a, b,c ,d ,e and f after the following statements: [3]
T= (90, 98, 76, 45, 12, 11)
a = T[2:2]
b = T[2:]
c = T[:2]
d = T[:-2]
e = T[-2:]
f = T[2:-2]

3. Will this code give a runtime error of infinite loop or will it give the output 5, 6, 7, 8, 9?
Explain with the help of a dry run. [2]
x = 5
L = [5,6,7,8,9]
for i in range(0,x):
x= x+1
print(L[i])
4. What are the different ways in which you can add elements to a list? Give examples. [2]
5. What is the meaning of unpacking of tuples? Show example. What is the condition for
unpacking? [2]
6. Consider the following List of Characters. Assume that the bubble sort (in ascending order)
is being applied on the list. Show the different passes and the state of the list in each pass.
[2]
[‘f’,’z’,’e’,’w’,’b’]
7. What is the difference between del and pop in terms of a dictionary? What are the different
ways in which pop can be called for a dictionary? [2]
8. WAP to create a list of unique values of numbers from any given list. [3]
For example:
L= [1,1,3,8,3,0,7,4,5,2,0]
Newlist = [1,3,8,0,7,4,2]
Note: Use nested loops, do not use built in functions of list.
9. Use a list of tuples: [3]
((1,2),(3,4,5),(9,7,6,10))
Create a tuple with the means of the individual nested tuples.
i.e (1.5 , 4 , 8)
Find the mean of the final set of numbers in the tuple. In this case 4.5
(P.S: Mean of numbers is the average of the numbers.)

10. Consider the following Lists: [3]


Names = [“ajay”,”shreyas”,”sanjana”,”sukumar”]
Marks=[[67,78,98,90],[90,78,61,92],[34,56,65,66],[98,100,100,98]]

WAP to use the above lists to create a dictionary of names as key and the total of each
sublist as their corresponding total marks for example the resultant dictionary should be
Report = {“ajay”:333,”shreyas”:321……..}
Further iterate through the dictionary to print the results as:
Name: Total
Ajay 333
Shreyas 321
11. Write an algorithm to sort a list of numbers using insertion sort. [3]
12. What is the difference between Primary Key, Candidate Key and Alternate Key? Explain
with examples. [3]
13. Expand and give two commands examples for DDL and DML: [4]
a. DDL
b. DML
c. DTL
d. DCL

14. Consider the table below, write SQL for a-d and output for f-i. [8]

Table Name: Sports_Club

COACH COACH AGE SPORTS DATEOFJOIN PAY GENDER


ID NAME
1 Aditya N 45 TENNIS 27-03-2009 1100 M
2 Aditya K 34 KARATE 20-01-2008 2200 F
3 Kunal 30 KARATE 19-02-2008 2900 M
4 Krishna 33 BASKETBALL 01-01-2008 2500 F
5 Zeenat 40 SWIMMING 24-02-2007 3000 M
6 Ankita 30 SQUASH 20-02-2009 8000 F
7 Zubin 29 KARATE 12-12-2009 8500 F
8 Raj 38 SWIMMING 22-02-2008 7500 F
9 Janet 23 TENNIS 27-03-2009 10000 F
10 Raveena 24 BASKETBALL 27-03-2009 20000 F
11 Amit 33 SQUASH 26-02-2008 5000 F
a. Write a Create SQL to create the above table where coach id is the primary key, coach
name and age cannot be null. Pay cannot be 0.
b. Write a SQL to display the names of all male coaches where age is greater than 30.
c. Write a SQL to insert a new row with the following data.
12, Hema, 45, TENNIS,25-04-2009,2000,F
d. Display all the records where the name of the coach starts with A and in ascending order
of age.
e. Add a column called Level to the table, which can take characters up to 50, and whose
default value is “STATE”
Or
Create a table called basketballcoach from the base table which has the name , age and
gender of all basketball coaches and also populate the table(1 or 2 SQLs)

f. select * from sports_club where pay >5000;


g. select distinct sports from sports_club;
h. select * from sports_club where dateofjoin between ‘2008-01-01’ and ‘2009-12-12’;
i. select coach_id from sports_club where gender=’F’ or gender =’M’;

*********************************GOOD LUCK!*******************************

Potrebbero piacerti anche