0% found this document useful (0 votes)
2K views

Computer Science Class 11 - Sultan Chand - SamplePaper2 (Key)

The document provides solutions to a sample paper on computer science (Python) for class 11. It contains 6 questions with subparts on topics like flowcharts, pseudocode, Python code and output, logical expressions, lists, strings and basic functions. For each question, detailed solutions and code snippets with explanations are given.

Uploaded by

VijayaBabu
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)
2K views

Computer Science Class 11 - Sultan Chand - SamplePaper2 (Key)

The document provides solutions to a sample paper on computer science (Python) for class 11. It contains 6 questions with subparts on topics like flowcharts, pseudocode, Python code and output, logical expressions, lists, strings and basic functions. For each question, detailed solutions and code snippets with explanations are given.

Uploaded by

VijayaBabu
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/ 12

SAMPLE PAPER- II

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" )

c) Which of the following are invalid identifiers.


a) 99flag b) As$swer c) For d) While
d) a=3
b=6
b+=a
print (b)

Ans a) 40
25
b) WELCOME
TO
PYTHON
c) a,b
d) 9

d) Write logical expression for the following: 2


1) Name is riya and age is between 10 and 15
2) CITY is either ‘Delhi’ or ‘Mumbai’ but not ‘Kolkata’

Ans
1) Name==”riya” and age>=10 and age<=15
2) (CITY==‘Delhi’ or CITY==‘Mumbai’) and CITY != ‘Kolkata’

e) Write the output of the following program on execution if x = 90, 2


Ans Ok
Good

Q2 a) Write the output of the following: 2

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)

Ans [16, 15, 14, 1]

b) Suppose L=[“Good”,5,[“students”, “words”],’few’] 1


Consider the above list and answer the following:

1) L[2:]
2) L[2][1]
Ans 1. L[3:]
[[‘students’,’words’],‘few’]
2. L[2][1]
[“students”]

c) Write the output of the following: 1


L=['a','z','p','c','m']
L.remove('c')
print (L)
print (L.pop())
Ans ['a', 'z', 'p', 'm']
m

d) What will be the output of the following programming code? 1


str=”My Python Programming”
print (str([-5:-1])
print (str[1:5])

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’)

Ans The code will produce the following output:


A
B
F
over
Q3 a) What are docstrings? How are they useful? 2
Ans A docstring is just a regular python triple-quoted string that is the first thing in a
function body / a module / a class. When executing a function body (or
module/class), the docstring doesn’t do anything like comments, but python stores
it as part of the function documentation. This documentation can later be
displayed using help() function.

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)

c) Write a program to generate the following series. 2


1 2 3
1 2
1
Ans for i in range(3,0,-1):
for j in range(1,i+1):
print (j,end=’ ‘)
print ()
d) Write a program to input numbers according to the user’s choice and store it in a 2
tuple and find maximum and minimum values in the tuple.
Ans n = input("no of elements")
i=1
t1=tuple()
while i<=n:
a=input("number")
t1=t1+(a,)
i=i+1
print (max(t1))
print (min(t1))

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")

Q4 a) Write at least two points of differences between compiler and interpreter. 2


Ans The difference between a compiler and an interpreter is described as follows:
Interpreter: Translates a program written in a high-level language into the
machine language by converting and executing it line by line. The Interpreter is very
useful for error-debugging as it displays errors while translating a program into the
machine language. It cannot execute a program until all the errors are resolved
Compiler: Works the same way as the interpreter. However, the main
difference between the interpreter and the compiler is that the compiler converts
the entire program into the machine language in one go and also reports all the
errors in the program along with the line numbers. When all the errors are rectified,
the program is recompiled and after that compiler is no longer needed in the
memory.
b) Fill the appropriate answer: 1
a) 1024 ZB=
b) 1024 KB

Ans a) 1024 TB =1 PETA BYTE


b) 1024 KB =1 MEGA BYTE

c) Write short note on ASCII. 1


Ans ASCII

American Standard Code for Information Interchange (ASCII) is a character encoding


based on the English alphabet. ASCII codes represent text in computers,
communications equipment, and other devices that work with text. Most modern
character encodings which support many more characters than did the original have
a historical basis in ASCII. Work on ASCII began in 1960. The first edition of the
standard was published in 1963 a major revision in 1967, and in 1986. It currently
defines codes for 128 characters where 33 are non-printing, and 94 are printable
characters (excluding the space).

d) 1. Convert decimal number (0.375) to its equivalent binary number. 2


2. Add 10001 to 11101

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

Ans F(P,Q,R) =(P+Q)(Q'+R)

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.

b) What are the merits of social networking? 2


Ans • Lowest cost form of marketing
• Huge potential audience and the possibility of messages going viral
• Offers a closer connection with your clients
• Source of instant feedback

c) What is Cyber Trolling? Write down Medium/Ways of Trolling. 2


Ans The internet troll is a modern version of the mythological version. They hide behind
their computer screens, and actively go out of their way to cause trouble on the
Internet.
YouTube video comments, Blog Comments, Forums, Email, Fb, Twitter, Instagram,
Social Networking sites and Anonymous ways of networking.
d) Name three data security concepts. 1

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

CCode Cname Ccode


1001 HemantSahu 501
1002 Raj Lal 509
1002 Feroza Shah 503
1004 Ketan Dhal 502

(A) Write SQL commands for the following statements:


(i) To display the names of all the silver colored Cars.
(ii) To display name of car, make and capacity of cars in descending order of their
sitting capacity.
(iii) To display the highest charges at which a vehicle can be hired from CARDEN.
(iv) To display the customer name and the corresponding name of the cars hired
by them.

(B) Give the output of the following SQL queries:


(i) SELECT COUNT(DISTINCT Make) FROM CARDEN;
(ii) SELECT MAX(Charges),MIN(Charges) FROM CARDEN;
(iii) SELECT COUNT(*),Make FROM CARDEN;
(iv) SELECT CarName FROM CARDEN WHERE Capacity=4;

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.

d) What is relation? What is the difference between a tuple and an attribute? 1

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.

e) What is Data integrity? 1

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).

g) What is the difference between DDL and DML command? 2

DDL Commands DML Commands


1) DDL stands for Data Definition 1. DML stands for Data Manipulation
Language. Language.
2) These commands allow us to perform 2) These commands are used to
tasks related to data definition, i.e., manipulate data, i.e., records or rows in
related to the structure of the database a table or relation.
objects (relations/databases).
3) The examples of DDL commands are, 3) The examples of DML commands are,
Create, Alter, Drop, Grant, Revoke etc. Insert into, Update, Delete, Select etc.
4) DDL is not further classified. 4) DML are further classified into two
types:
a) Procedural DMLs
b) Non-Procedural DMLs
h) What is relation? What is the difference between a tuple and an attribute? 1
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.

You might also like