Computer Science Class 11 - Sultan Chand - SamplePaper2 (Key)
Computer Science Class 11 - Sultan Chand - SamplePaper2 (Key)
SOLUTIONS
SUBJECT – COMPUTER SCIENCE (Python)
CLASS- XI
MAXIMUM MARKS: 70 TIME:3 hours
GENERAL INSTRUCTIONS:
1. Number of questions are 6.
3. Answer the questions in sequence.
4. Read the question carefully before attempting it.
Q1 a) Draw a flow chart and write pseudo code to find the greatest of 3 numbers. 2
Ans
Flow chart
b) Write pseudo code to Check if the number is positive or negative or zero and display 2
an appropriate message.
Ans Pseudo code:
Input a number
If number is greater than and equal to zero then check, if number is zero then display
‘zero’ otherwise display ‘positive number’.
Otherwise display ‘negative number’.
c) ) write the output of the following: 4
a) a,b=20,30
a = a+5
b=b+10
a,b= b,a
print (a)
print (b)
b) print ("WELCOME\n","TO\n","PYTHON" )
Ans a) 40
25
b) WELCOME
TO
PYTHON
c) a,b
d) 9
Ans
1) Name==”riya” and age>=10 and age<=15
2) (CITY==‘Delhi’ or CITY==‘Mumbai’) and CITY != ‘Kolkata’
L=[]
L1=[]
L2=[]
for i in range(6,10):
L.append(i)
for i in range(10,4,-2):
L1.append(i)
for i in range(len(L1)):
L2.append(L[i]+L1[i])
L2.append(len(L)-len(L1))
print (L2)
1) L[2:]
2) L[2][1]
Ans 1. L[3:]
[[‘students’,’words’],‘few’]
2. L[2][1]
[“students”]
Ans 1 str[-4:-1]
'min'
2 str[1:5]
'y Py'
e) Consider the string str=”Green Revolution”. 5
Write statements in python to implement the following:
i) To replace all the occurrences of letter ‘a’ in the string with “*”
ii) To display the starting index for the substring ‘vo’.
iii) To remove ‘Gre’ from the left of the sting.
iv) To check whether string contains ‘vol’ or not.
v) To repeat the string 3 times.
Ans i) str.replace('e','*')
'Gr**n R*volution'
ii) str.find('vo')
8
iii) str.lstrip('Gre')
'n Revolution'
iv) 'vol' in str
True
v) str*3
'Green RevolutionGreen RevolutionGreen Revolution'
f) What will be the output of following python code, justify your answer. 2
x=5
y=0
print (‘A’)
try:
print (‘B’)
A = x/y
print (‘C’)
except ZeroDivisionError:
print (‘F’)
except :
print (‘D’)
finally:
print (‘over’)
b) WAP to accept a number, find and display whether it’s a Armstrong number or not. 2
Ans num=int(input("Enterno"))
digit =int( input("enter digit on a no"))
f = num
sum = 0
while(f!=0):
a = f%10
f = f/10
sum = sum+(a**digit)
if (sum==num):
print ("it is a Armstrong no",num)
else:
print ("it is not a Armstrong no",num)
e) Write a program to input ‘n’ student and grade to store it in a dictionary and to 3
input any name and to print the grade of that particular name.
Answer
def main():
student=dict()
n=input("enter total no of students")
i=1
while i<=n:
a=raw_input("enter name")
b=raw_input("enter grade")
student[a]=b
i = i+1
name = input("enter name")
f=0
l = student.keys()
for i in l:
if (cmp(i,name)==0):
print ("Grade=",student[i])
f= 1
if f==0:
print ("given name does not exist")
Ans 1. 0.011
2. 101110
e) 2
Verify the following using truth table:
X+Y.Z=(X+Y).(X+Z)
Ans Ans: X+Y.Z=(X+Y).(X+Z) [Given]
X Y Z Y.Z X+Y.Z (X+Y) (X+Z) (X+Y).(X+Z)
0 0 0 0 0 0 0 0
0 0 1 0 0 0 1 0
0 1 0 0 0 1 0 0
0 1 1 1 1 1 1 1
1 0 0 0 1 1 1 1
1 0 1 0 1 1 1 1
1 1 0 0 1 1 1 1
1 1 1 1 1 1 1 1
The values for highlighted columns are same. Hence, L.H.S. = R.H.S.
f) Write the equivalent Boolean expression for the following logic circuit 2
Q5 a) What is an IP address? 1
Ans IP address allows computer or any other digital device to communicate with another
through Internet. An internet protocol is a set of rules that govern internet activity
and facilitate complete a variety of actions on the World Wide Web.
An IP address consists of four numbers, each of which contains one to three digits,
separated by single dot (.). Each of the four numbers can range 0 to 255.
Examples of an IP address- 78.125.0.209. Every machine that is on the internet has a
unique IP number.
Ans The three concepts are: encryption, user authentication and data backup.
e) What is information technology security? 1
Ans IT Security is a term which is more concerned with the protection of hardware,
software and a network of an organisation, from the perils of disaster and external
attacks (through virus, hacking etc.).
f) What do you mean by hacker? 1
Ans Hacker means an expert computer programmer who enjoys finding out the inner
workings of computer systems or Networks. Some have a reputation for using their
expertise to illegally break into secure programs in computers hooked up to the
internet or other networks.
g) What is the support being provided to web browser? 2
Ans Web browser supports the HTML version that is used to create the website in a very
simple manner without using the complex tools.
- Web browser supports rapid development of the websites and tools that can be
used for the creation of it.
- It provides a way to develop the non-standard dialects of HTML that provides the
interoperability support.
- Web browser provides standard libraries through which the support can be given to
make the standard based HTML pages.
- It provides the support for other languages like JavaScript, HTML or XHTML that can
be rendered by the web browsers.
Q6 a) What are SQL constraints? Define constraints NOT NULL and CHECK. 2
Ans Constraints are the rules enforced on data or columns on table. These are used to
restrict the values that can be inserted in a table. This ensures the accuracy and
reliability of the data in the database.
Following are most commonly used constraints available in SQL:
• NOT NULL Constraint: Ensures that a column cannot have NULL value.
• CHECK Constraint: The CHECK constraint ensures that all values in a column satisfy
certain conditions. For example, to restrict the salary column that it should contain
salary more than 10000.
b) Consider the following tables CARDEN and CUSTOMER and answer (A) and (B) parts 6
of question:
TABLE: CARDEN
Ccode CarName Make Color Capacity Charges
501 A-Star Suzuki RED 3 14
503 Indigo Tata SILVER 3 12
502 Innova Toyota WHITE 7 15
509 SX4 Suzuki SILVER 4 14
510 C Class Mercedes RED 4 35
TABLE:CUSTOMER
Ans (A) (i) SELECT CarName FROM carden WHERE Color LIKE 'Silver';
(ii) SELECT CarName,Make,Capacity FROM carden ORDER BY Capacity;
(iii) SELECT MAX(Charges) FROM carden;
(iv) SELECT Cname,CarName FROM carden,customer
WHEREcarden.Ccode=customer.Ccode;
(B)
(i) COUNT(DISTINCT Make)
4
(ii) MAX(Charges) MIN(Charges)
35 12
(iii) COUNT(*) Make
5 Suzuki
(iv) CarName
SX4
C Class
c) What is meant by the term NoSQL? 1
Ans NoSQL databases are especially useful for working with large sets of distributed data. NoSQL
means not SQL or unlike SQL. NoSQL databases are built to allow the insertion of data
without a predefined schema.
Ans A relation is like a table in which data are arranged in the form of rows and columns.
The rows of a table are called tuples.
The columns of a table are called attributes.
Ans Data integrity refers to maintaining and assuring the accuracy and consistency of data over
its entire life cycle.
f) Define FOREIGN Key. 1
Ans A foreign key is a key which is used to link two tables together. This is also called a
referencing key. Foreign Key is a column or a combination of columns whose values
match a Primary Key in a different table. The relationship between two tables
matches the Primary Key in one of the tables with a Foreign Key in the second table.
If a table has a primary key defined on any field(s), then you cannot have two records
having the same value of that field(s).