CBSE Sample Paper for Class 11 Computer Science - Set E
Short Description
For All CBSE Sample Papers for Class 11 English visit: http://schools.aglasem.com/?p=38388 For All CBSE Sample Papers...
Description
AglaSem Schools
Sample Question Paper–E 1. (a) Proprietary software or closed source software is computer software licensed under exclusive legal right of the copyright holder with the intent that the licensed is given the right to use the software only under certain conditions (1) (b) Fourth Generation. (1) (c) A management information system (MIS) provides information that organizations require to manage themselves efficiently and effectively (1) (d) Differences between Interpreter and Compiler: Interpreted Language
Compiled Language
1. The program is checked line by line.
Check the whole program at once.
2. Generally Slower than compiled language.
Faster than interpreted language.
m o
.c
m e s
(1 mark for each difference) 2. (a) Cache Memory is a memory located intermediate to CPU and Main memory and saves the data accessed frequently so that access is faster. (1) (b)
a l g
SIMD
a . s
1. There is only one instruction to fetch data
l o o
2. Lower level of parallelism achieved.
h c s
MIMD
Multiple Instructions to fetch data. Higher level of Parallelism achieved. (2)
(c) math.fabs(x) Return the absolute value of decimal x. Example: math.fabs(-44.9) gives output as 45. (1) math.abs() does not work with decimals (1) Example: math.fabs(-44.9) gives ERROR (d) Decimal Binary to Decimal with a Table 1. Create a table whose leftmost column is the greatest power of 2 less than the number you want to convert. If the number is between 64 and 127, the leftmost column will be 64. If the number is between 128 and 255, the leftmost column will be 128. Each column in the table is a power of 2. The rightmost column is 20 (= 1), the next one to the left is 21 (= 2), the next is 22 (= 4), etc. Instead of thinking about powers of 2, you can just think about doubling each number to get the value for the next column to the left. This will typically look like.
.
w
w
w
2.
3.
4.
64 32 16 8 4 2 1 Start by comparing the number you want to convert to the value leftmost column. If you’ve set up the table correctly, it should be less than the column value, so put a 1 in the column. Add up the values of all the columns you’ve put 1’s in so far. This is your running total. Take the running total and add the value of the next column, If the result is less than the number you want to convert, put a 1 in this column. If the resilt is greater thsn thr number you want to convert, put a 0 in this column. Repeat the previoud step until all columns are filled.
64 1
32
16
8
4
2
AglaSem Schools
1 (64 < 87 ? yes) (64 + 32 < 87 ? no) (64 + 16 < 87 ? yes)
0 1 0 1
(64 (64 (64 (64
1 1
+ + + +
16 16 16 16
+ + + +
8 4 4 4
< < + +
87 ? no) 87 ? yes) 2 < 87 ? yes) 2 + 1 < 87 ? yes, done)
Binary number : 1010111 (4) 3. (a) range() generates a list which is to be updated manually by the programmer while xrange ( ) generates an automatically updated list (iterator). (1) (b) Functional Programming: Functional programming decomposes a problem into a set of functions. Ideally, functions only take inputs and produce outputs, and don’t have any internal state that affects the output produced for a given input. Well-known functional languages include the ML family (Standard ML, OCaml, and other variants), Haskell and Python. (2) (c) Lists are a simple list of values. Each one of them is numbered, starting from zero - the first one is numbered zero, the second 1, the third 2, etc. You can remove values from the list, and add new values to the end. Example: Your many cats’ names. Tuples are just like lists, but you can’t change their values. The values that you give it first up, are the values that you are stuck with for the rest of the program. Again, each value is numbered starting from zero, for easy reference. Example: the names of the months of the year. (2) (d) “Decorators allow you to inject or modify code in functions or classes”. In other words decorators allow you to wrap a function or class method call and execute some code before or after the execution of the original code. And also you can nest them e.g. to use more than one decorator for a specific function. Usage examples include – logging the calls to specific method, checking for permission(s), checking and/or modifying the arguments passed to the method etc. (2) (e) Loop Structures are used to repeat a set of statements. A loop is a way of repeating a statement a number of times until some way of ending the loop occurs. It might be run for a preset number of times, typically in a for loop, repeated as long as an expression is true (a while loop) or repeated until an expression becomes false in a do while loop.
m o
.c
m e s
a l g
a . s
l o o
h c s
.
w
One Loop Structure found in Python is range( ). To do iterate transforms or collections of some data sets. for each in xrange(0,10): ...# loop (4) 4. (a) A String is a collection of characters. Example: “OSWAAL” is a string that consists of characters: O,S,W,A,A,L.
w
w
String are created in Python by enclosing some characters or numbers in single (‘) or double (”) quotes. Example of creating a String >>> a = “hello” # using double quote >>> b = ‘world’ # using single quote >>> c = “How’re you doing?” # mixing single and double quotes l A long string that spans a few lines can be enclosed in triple quotes(“””) (2) (b) To obtain a user input in Python input([Prompt])
Schools Where [ Prompt ] is the string you would want to prompt the user AglaSem with, obviously. So, from what Example: foo=input(‘Please enter a value:’) To Enter a String, we use raw_input. Example: var = raw_input(“Enter something: “) (c) (i) ASCII—Americam Standard Code for Information Interchange (ii) MICR—Magnetic Ink Character Reader (iii) EBCDIC—Extended Binary Coded Decimal Interchange Code (iv) UNICODE—Uniform Character encoding (v) BCD—Binary Coded Decimal (vi) ALU—Arithmetic and Logical Unit (d) n=raw—input (“Enter the string”) def Palindrome (n); index=0 check=true while index len (n); if n [index]==n[-1-index]; index+=1 return True. return false if Palindrome (n)=True
(1/2 mark for each correct answer)
m o
.c
m e s
Print (“It is a Palindrone”) Else Print (“It is not a Palindrone”) 5. (a) x = 1 while x :
a l g
a . s
l o o
h c s
#Statements following while (b) def Temperature () : F = input (‘Enter temperature in Fareniet’) C = ((5.0/9.0) * (F - 32)) print C (c) print (‘! * Python Multiplication Table from 2 to 10\n’)
.
w
(2)
w
w
def Multiplication Table1 () : for i in range (2, 11) : for j in range (1, 11) : mul = i * j print mul, print (d) #!/usr/bin/env python from math import sqrt def area(a, b, c): p = 0.5 * (a + b + c) print ‘area found’ return sqrt(p * (p - a) * (p - b) * (p - c))
(3)
(1)
(2)
(2)
(3)
AglaSem Schools
(e) def main ( ): Print “This Program finds the real solutions to a quadratic” Print a, b, c= input (“please Enter the coefficients (a, b, c) :”) disc Root=math.sart (b*b-4*a*c)
root 1 = (–b + disc Root)/(2*a) root 2 = (–b – disc Root)/(2*a) Print “The solutions are:”, root 1, root 2 (4) 6. (a) object oriented programming is a programming methodology in which the program is terms of classes and the related objects. (1) (b) A dictionary has the following capabilities : 1. Ability to iterate over keys or values or key-value pairs. 2. Ability to add key-value pairs dynamically. (2) (c) Three forms of the import statement : l Import a module. Refer to an attribute in that module : Import test print test . X l Import a specific attribute from a module : from test import x
l
from othertest import y, z print x, y, z Import all the attributes in a module : from test import * print x print y
.c
m e s
a l g
a . s
l o o
m o
(3)
(d) assert statement is used to place error checking statements in the code. Examples : def test fargl, arg2) : arg1 = float (arg1) arg2 = float (arg2)
.
h c s
assert arg2 ! = 0, ©Bad dividend — argl : %f arg 2 : %f© % (arg1, arg2) ratio = arg1 / arg2 print ©ratio:©, ratio When arg2 is zero running this code will produce something like the following : Traceback (most recent call last) : File ‘‘tmp.py’’, line 22, in ? main ( ) File ‘‘tmp.py’’, line 18, in main test (args[0], args[1]) File ‘‘tmp.py’’, line 8, in test assert arg2 ! = 0, ©Bad dividend — arg1 : %f© % (arg1, arg2) AssertionError : Bad dividend — arg1 : 2.000000 arg2 : 0.000000 A few comments : l Notice that the trace-back identifies the file and line where the test is made and shows the test itself. l If you run python with the optimize options (-O and -OO), the assertion test is nor performed, l The second argument to assert () is optional. (4)
w
w
w
AglaSem Schools 7. (a) >>> try: ... x=y ... except : ... print ©y not defined© ... y not defined (1) (b) Algorithm : step 1 : START step 2 : Input marks step 3 : Check if ((marks/500)*100) ≥ 0·33*marks step 4 : If yes, then Print “Passed” GOTO STEP 6 step 5 : If no, Print “Failed” step 6 : END (2) (c) Packages—A package is a way to organize a number of modules together as a unit. Python packages can also contain other packages. For example : # modulel.py class class1: def ___ init ___(self) : self.description = ©class #1© def show (self) : print self. description (2) (d) Extending vs. embedding — They are different but related: l Extending Python means to implement an extension module or an extension type. An extension module creates a new Python module which is implenebted in C/C++. From Python code, an extension module appears to be just like a module implemented in Python code. An extension type creates a new Python (built-in) type which is implemented in C/C++. From Python code, an extension type appears to be just like a built-in-type. l Embedding Python, by contrast, is to put the Python interpreter within an application (i.e. link it in) so that the application can run Python scripts. The scripts can be executed or triggered in a variety of ways, e.g. they can be bound to keys on the keyboard or to menu items, they can be triggered by external events, etc. Usually, in order to make the embedding Python interpreter useful. Python is also extended with functions from the embedding application, so that the scripts can call functions that are implemented by the embedding C/C++ application. (3)
m o
.c
m e s
a l g
a . s
l o o
h c s
.
w
w
w
qq
View more...
Comments