Download Sample Question Paper–6

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Sample Question Papers | 1
Sample Question Paper–6
1. (a) PROM-Programmable Read Only Memory.
(b) William Bradford Shockley introduced the concept of Transistors.
(c) Relational Database Management System
(d)
Low Level Language
1.
The programming is done in binary.
2.
Programs are machine specific
(1)
(1)
(1)
High Level Language
The programming is done in human
understandable language
Programs are machine independent
(1 mark for each difference)
(e) (i) Real-time : A real-time operating system is a multitasking operating system that aims
at executing real-time applications. Real-time operating systems often use specialized
scheduling algorithms so that they can achieve a deterministic nature of behavior. The
main objective of real-time operating systems is their quick and predictable response to
events. They have an event-driven or timesharing design and often aspects of both. An
event-driven system switches between tasks based on their priorities or external events
while time-sharing operating systems switch tasks based on clock interrupts.
(ii) Multi-user : A multi-user operating system allows multiple users to access a computer
system at the same time. Time-sharing systems and Internet servers can be classified as
multi-user systems as they enable multiple-user access to a computer through the sharing
of time. Single-user operating systems have only one user but may allow multiple programs
to run at the same time.
(iii) Distributed : A distributed operating system manages a group of independent
computers and makes them appear to be a single computer. The development of networked
computers that could be linked and communicate with each other gave rise to distributed
computing. Distributed computations are carried out on more than one machine. When
computers in a group work in cooperation, they make a distributed system.
(iv) Embedded : Embedded operating systems are designed to be used in embedded
computer systems. They are designed to operate on small machines like PDAs with less
autonomy. They are able to operate with a limited number of resources. They are very
compact and extremely efficient by design. Windows CE and Minix 3 are some examples of
embedded operating systems.
(4)
2. (a) Level 1 Cache : Level 1 cache, often called primary cache, is a static memory integrated
with processor core that is used to store information recently accessed by a processor. Level
1 cache is often abbreviated as L1 cache. The purpose of level 1 cache is to improve data
access speed in cases when the CPU accesses the same data multiple times. For this reason
access time of level 1 cache is always faster than access time of system memory. The
processor may have additional level 2 and level 3 caches, albeit those caches are always
slower then the L1 cache.
In modern microprocessors primary cache is split into two caches of equal size - one is
used to store program data, and another is used to store microprocessor instructions. Some
old microprocessors utilized “unified” primary cache, which was used to store both data
and instructions in the same cache.
(2)
(b) MIMD-Multiple Instruction and Multiple Data : MIMD computer system has a number of
independent processors operate upon separate data concurrently.
(2)
(c) math.cos(x) returns the cosine value of the entered number.
Example: math.cos(60) returns 0.5
(2)
2 | Oswaal CBSE (Sample Question Papers) Computer Science, Class–XI
(d) (i)
(ii)
(iii)
(iv)
(1)
(1)
(1)
(1)
109
100101110111
747402
1111101
3. (a) Static Binding
At translation
— Determined by programmer — bind type to variable name, value to constant.
— Determined by translator — bind global variable to location (at load time), bind
source program to object program representation.
(2)
(b) Assume variable a holds 10 and variable b holds 20 then:
l
Operator
Description
Example
==
Checke if the value of two operands are
equal or not, if yes then condition
becomes true.
Checks if the value of two operands are
equal or not, if values are not equal then
condition becomes true.
(a == b) is not true.
!=
(a != b) is true.
(2)
(c) ABC+A′B′C′+A′BC+ABC′+A′B′C′
=BC(A+A′)+A′B′(C+C′)+AB(C+C′)
=BC+A′B′+AB
=A′B′+B(A+C)
(d) Four functions performed by compression tools are:
(3)
(i) Reduce the file size
(ii) Provides faster access
(iii) Makes file transfer easy over web (due to small file size)
(iv) Prevents any data loss in files.
(4)
4. (a) List is a data structure to store homogeneous data. Like string indices, list indices start at
0, and lists can be sliced, concatenated and so on:
>>> a[0]
‘spam’
>>> a[3]
1234
>>> a[-2]
100
>>> a[1:-1]
[‘eggs’, 100]
>>> a[:2] + [‘bacon’, 2*2]
[‘spam’, ‘eggs’, ‘bacon’, 4]
>>> 3*a[:3] + [‘Boe!’]
[‘spam’, ‘eggs’, 100, ‘spam’, ‘eggs’, 100, ‘spam’, ‘eggs’, 100, ‘Boe!’]
(2)
(b) input() is used to get string input while raw_input() is used to get integer input.
Example:
>> name=input(‘Enter a Name’)
>>age=raw_input (‘Enter Age’)
(2)
(c) Python basically has three datatypes: dict, list and set
Sample Question Papers | 3
list([iterable]) : Return a list whose items are the same and in the same order as iterable’s
items. iterable may be either a sequence, a container that supports iteration, or an iterator
object.
class dict(iterable, **kwarg)
Return a new dictionary initialized from an optional positional argument and a possibly
empty set of keyword arguments.
class set([iterable])
Return a new set or set object whose elements are taken from iterable. The elements of a
set must be hashable. To represent sets of sets, the inner sets must be frozenset objects.
If iterable is not specified, a new empty set is returned.
(3)
(d) (i) math.ceil(x)
Return the ceiling of x as a float, the smallest integer value greater than or equal to x.
(ii) math.fabs(x)
Return the absolute value of x.
(iii) math.floor(x)
Return the floor of x as a float, the largest integer value less than or equal to x.
(iv) math.factorial(x)
Return x factorial. Raises ValueError if x is not integral or is negative.
(4)
5. (a) for and while loops are supported in python
(b) a=10, b=30
(1)
(1)
(c) Defining a Function
You can define functions to provide the required functionality. Here are simple
rules to define a function in Python:
l
Function blocks begin with the keyword def followed by the function name and
parentheses ( ( ) ).
l
Any input parameters or arguments should be placed within these parentheses. You
can also define parameters inside these parentheses.
l
The first statement of a function can be an optional statement - the documentation
string of the function or docstring.
l
The code block within every function starts with a colon (:) and is indented.
l
The statement return [expression] exits a function, optionally passing back an expression
to the caller. A return statement with no arguments is the same as return None.
Syntax :
def functionname( parameters ):
“function_docstring”
function_suite
return [expression]
(d) x = 0
while True:
try:
x = int(raw_input(‘input a decimal number \t’))
if x in xrange(1,1000000001):
y = bin(x)
rev = y[2:]
print(“the reverse binary soln for the above is %d”) %(int(‘0b’+rev[::-1],2))
break
except ValueError:
print(“Please input an integer, that’s not an integer”)
continue
(3)
4 | Oswaal CBSE (Sample Question Papers) Computer Science, Class–XI
(e)
Name
Symbol
Use in flowchart
Oval
Denotes the beginning or end a program.
Flow line
Denotes the direction of logic flow ina
program.
Parallelogram
Denotes either an input operation (e.g.,
INPUT) or an output operation (e.g., Print)
Rectangle
Denotes a process to be carried out (e.g., an
addition)
Diamond
Denotes a decision (or branch) to be made.
The program should continue along one of
two routes (e.g., IF/THEN/ELSE)
(4)
6. (a) isdigit() checks if entered character is a digit. Returns false otherwise.
isalpha() checks if entered character is a alphabet. Returns false otherwise.
(1)
(b) Keywords are reserved words that are used for special purpose in a program provided by
the programming language.
Some of the keywords in Python are:
and
assert
break
class
continue
def
(2)
(c) When you want to extract part of a string, or some part of a list, you use a slice. Other
languages use the termsubstring for a string slice, and may have no mechanism for extract
a list slice. Python’s slice syntax is easy and elegant:
slicedString = aString[beginIndex:endIndex]
slicedList = aList[beginIndex:endIndex]
Slices Examples
Line
Code
Meaning
1
alphabet = “abcdefghij’’
Making an alphabet variable.
2
slice1 = alphabet[1:3]
3. slice2 = alphabet[3]
Slicing from subscript 1 thru subscript 2.
slice1 = ‘bc’
Slicing from subscript 0 (empty beginlndex) through subscript
slice2 = ‘abc’
(3)
(d) (i) Large uniform register set
(ii) minimal number of addressing modes
(iii) no/minimal support for misaligned accesses
(iv) Fixed length instructions
(4)
7. (a) System software is a type of computer program that is designed to run a computer’s
hardware and application programs.
(1)
Sample Question Papers | 5
(b)
Main Memory
CPU
Buses
Input
Devices
Auxiliary
Storage
Output
Devices
Input-Output System
(2)
(c) #program to find factorial of a number
n=int(raw_input(‘Enter the number ‘))
fact = 1
while n :
fact = fact * n
n=n-1
print “Factorial of number is “,fact
(d) line 1 : def sin(x,n) :
line 2 : for (i in range[n]):
line 3: sign=(-1)*i*i
(2)
(3)
qq
6 | Oswaal CBSE (Sample Question Papers) Computer Science, Class–XI
Sample Question Paper–7
1. (a) Software is a collection of programs and related documentation.
(b) ASCII supports 128 characters.
(c) Dynamic Random Access Memory
(d) def multiplication Table () :
for i in range (5, 10) :
for j in range (1, 11) :
mul = i*j
(1)
(1)
(1)
Print mul,
Print.
(2)
2. (a) (i) Physical Level
(ii) Logical Level
(iii) View Level
(1)
(b) Network DataBase Management System is a type of file management system in which the
files are arranged in form of a network with linkages present between them .
(1)
(c) (i) It is open source
(ii) It has a powerful security feature.
(2)
(d) A software interrupt is caused either by an exceptional condition in the processor itself,
or a special instruction in the instruction set which causes an interrupt when it is executed.
The former is often called a trap or exception and is used for errors or events occurring
during program execution that are exceptional enough that they cannot be handled within
the program itself. For example, if the processor’s arithmetic logic unit is commanded to
divide a number by zero, this impossible demand will cause a divide-by-zero exception. (2)
3. (a) c[:] displays all the elements of the list while c[:-1] displays after reducing one element
(i.e. slices the list).
(1)
(b) Object-oriented programming (OOP) is a programming paradigm that represents
concepts as “objects” that have data fields(attributes that describe the object) and associated
procedures known as methods. Objects, which are usually instances of classes, are used to
interact with one another to design applications and computer programs.Objective-C,
Smalltalk, Java and Phython are examples of object-oriented programming languages. (2)
(c) A Python decorator is a specific change to the Python syntax that allows us to more
conveniently alter functions and methods (and possibly classes in a future version). This
supports more readable applications of the DecoratorPattern but also other uses as well..
(2)
(d) A list can store a sequence of objects in a certain order such that you can index into the
list, or iterate over the list. List is a mutable type meaning that lists can be modified after
they have been created.
Example:
>> stack = [3, 4, 5]
A tuple is similar to a list except it is immutable. There is also a semantic difference between
a list and a tuple.
Example:
>>t = 12345, 54321, ‘hello!’
A dictionary is a key-value store. It is not ordered and it requires that the keys are hashable.
It is fast for lookups by key.
Sample Question Papers | 7
Example:
>>dict([(‘sape’, 4139), (‘guido’, 4127), (‘jack’, 4098)])
(3)
(e) Decision Statements or selection statements are the statements which produce a certain
output based upon a condition.
Some decision statements commonly supported by all languages are:
(i) If…Else
This enables the programmer to provide different paths for the program flow depending on
certain conditions. For example: consider a program for dividing two numbers. Division by
zero will lead to an error. To avoid this from happening, after obtaining the two numbers
from the user the programmer will want to ensure that the denominator is not zero. Hence
there needs to be two different program flow options. If the denominator is zero a message
saying, “Division not possible” should be displayed. Otherwise the program should carry
out the division and display the results. In simpler terms this can be stated as:
If the denominator is zero, then display a message and do not divide
else perform division and display the output.
Syntax:
if (condition)
{
//statements to be executed;
}
else
{
//statements to be executed;
}
(ii) Nested If
You can have an ‘if’ statement within another ‘if’ statement. This is known as nested ‘if’.
The program flow will enter into the inner ‘if’ condition only if the outer ‘if’ condition is
satisfied. In general form nested ‘if’ will be of the form:
if (condition1)
{
//code to be executed if condition1 is true
if (condition2)
{
//code to be executed if condition2 is true
}
}
(iii) Switch
A switch statement is a type of selection control mechanism used to allow the value of a
variable or expression to change the control flow of program execution via a multiway branch.
Syntax:
In most languages, a switch statement is defined across many individual lines using one or
two keywords. A typical syntax is:
l The first line contains the basic keyword, usually switch, case or select, followed by an
expression which is often referred to as the control expression or control variable of
the switch statement.
l Subsequent lines define the actual cases (the values) with corresponding sequences of
statements that should be executed when a match occurs.
Python supports if…else and nested if.
(3)
4. (a) A global variable is a variable that is accessible in every scope. Interaction mechanisms
with global variables are called global environment mechanisms. The global environment
8 | Oswaal CBSE (Sample Question Papers) Computer Science, Class–XI
paradigm is contrasted with the local environment paradigm, where all variables are local
with no shared memory (and therefore all interactions can be reconducted to message
passing).
The scope of global variables is the whole program.
(2)
(b) HELLOOSWAL
(2)
(c) An interpreter is a computer program that executes, i.e. performs, instructions written in
a programming language. An interpreter generally uses one of the following strategies for
program execution:
1.
execute the source code directly
2.
translate source code into some efficient intermediate representation and immediately
execute this
3.
explicitly execute stored precompiled code made by a compiler which is part of the
interpreter system
(1)
Interpreter
Source code
Output
Data
(2)
(d) (i)
(ii)
(iii)
(iv)
1
25
False
True
(4)
(d) #program to enter a number and print its octal
x=0
while True:
(e) try:
x = int(raw_input(‘input a decimal number\t’))
if x in xrange(1,1000000001):
y = oct(x)
print y
z=hex(x)
print z
print( zero(x-1)-1)
func xall
xrange()
except ValueError:
print(“Please input an integer, that’s not an integer”)
continue
(f) Step1: Start
Step2: Input date, month and year from user.
Step 3: Check if date<=31 and month<=12 and year<=9999
(4)
Sample Question Papers | 9
Step4: Print the date in dd/mm/yyyy format and print Yes.
Step5: Else print No
Step6: Stop
5. (a) 64
(4)
(1)
(b) aaabbbcccddd
(1)
(c) best stored in a list of dictionaries..
dictionary format: {‘number:12453’}
(2)
(d) The Corrected Code is:
n=[1, 2, 5, 10, 3, 100, 9, 24]
for e in n :
if e<5 :
n.remove(e)
println n
(3)
(e) Even if a statement or expression is syntactically correct, it may cause an error when an
attempt is made to execute it. Errors detected during execution are calledexceptions and
are not unconditionally fatal.
It is possible to write programs that handle selected exceptions. Look at the following
example, which asks the user for input until a valid integer has been entered, but allows
the user to interrupt the program (using Control-C or whatever the operating system
supports); note that a user-generated interruption is signalled by raising the
KeyboardInterrupt exception.
>>> while True:
...
try:
...
x = int(raw_input(“Please enter a number: “))
...
break
...
except ValueError:
...
print “Oops! That was no valid number. Try again...”
The try statement works as follows.
l
First, the try clause (the statement(s) between the try and except keywords) is
executed.
l
If no exception occurs, the except clause is skipped and execution of the trystatement
is finished.
l
If an exception occurs during execution of the try clause, the rest of the clause is skipped.
Then if its type matches the exception named after the exceptkeyword, the except
clause is executed, and then execution continues after the try statement.
l
If an exception occurs which does not match the exception named in the except clause,
it is passed on to outer try statements; if no handler is found, it is an unhandled
exception and execution stops with a message as shown above.
(4)
6. (a) ceil( ) is used to round off a number to next higher integer. floor( ) rounds off to nearest
optimal integer(i.e. if decimal is <5 lower integer else higher)
(1)
(b) First
Fourth
Fifth
(2)
(c) print ‘You typed’ +line
line=line+ ’h’
print ‘You typed the number’+num
(3)
10 | Oswaal CBSE (Sample Question Papers) Computer Science, Class–XI
(d)
Start
Read A, B, C
YES
Is B>C ?
NO
Is A>B ?
YES
Is A>C ?
YES
NO
NO
Print B
Print C
Print A
End
(4)
7. (a) One function performed by School Management System is that it maintains students’
attendance records.
(1)
(b) Booting (also known as booting up) is the initial set of operations that a computer system
performs when electrical power to the CPU is switched on or when the computer is reset.
(1)
(c)
Bluetooth
1.
Not affected by physical inference
2.
3.
Range more than infrared
Bluetooth does not need a direct line
of connection
Infrared
Communication stops in presence of
interference
Range less than Bluetooth
Infrared needs a direct line of connection
(3)
(d) Third Generation Computers (1964-1971)
In this era, there were several innovations in various fields of computer technology. These
include Integrated Circuits (ICs), Semiconductor Memories, Microprogramming, various
patterns of parallel processing and introduction of Operating Systems and time-sharing.
In the Integrated Circuit, division there was gradual progress. Firstly, there were smallscale integration (SSI) circuits (having 10 devices per chip), which evolved to medium scale
integrated (MSI) circuits (having 100 devices per chip). There were also developments of
multi-layered printed circuits.
Parallelism became the trend of the time and there were abundant use of multiple functional
units, overlapping CPU and I/O operations and internal parallelism in both the instruction
and the data streams. Functional parallelism was first embodied in CDC6600, which
contained 10 simultaneously operating functional units and 32 independent memory banks.
This device of Seymour Cray had a computation of 1 million flopping point per second (1 M
Flops). After 5 years CDC7600, the first vector processor was developed by Cray and it
boasted of a speed of 10 M Flops. IBM360/91 was a contemporary device and was twice as
first as CDC6600, whereas IBM360-195 was comparable to CDC7600. In case of language,
this era witnessed the development of CPL i.e. combined programming language (1963).
CPL had many difficult features and so in order to simplify it Martin Richards developed
BCPL - Basic Computer Programming Language (1967). In 1970 Ken Thompson developed
yet another simplification of CPL and called it B.
(4)
qq
Sample Question Papers | 11
Sample Question Paper–8
1. (a) Mozilla Firefox.
(b) 1 Tera Byte= 0.000976562 PetaByte
(c) Lesser number of instructions in a program
(d)
PROM
1.
2.
(1)
(1)
(1)
EPROM
Once written, data cannot be erased
Data can be erased by electrical or
from it.
magnetic means.
Data is not disrupted by any electrical Data is disrupted by electrical interference.
interference
(2)
2. (a) 1 GHz= 1000 MHz
(1)
(b) Unique Universal and Uniform character Encoding .
(1)
(c) (i) Management of System Hardware
(ii) Management of System memory
(2)
(d) (i) Top Down Program Development
(ii) No use of modules in the program
(2)
3. (a) Scope can be defined as the part of program where the lifetime of variable exists.
(1)
(b) len()
>>> len(a) # get number of characters in the string
5
capitalize()
The method capitalize() returns a copy of the string with only its first character capitalized.
For 8-bit strings, this method is locale-dependent.
Syntax
str.capitalize()
Example
str = “this is string example....wow!!!”;
print “str.capitalize() : “, str.capitalize()
result:
str.capitalize() : This is string example....wow!!!
(c) def rot(x):
x=5
print randint(x,8) may return numbers between 5 and 8
(2)
(2)
(d) ALGORITHM:
STEP 1 : START
STEP 2 : Input sides of triangle
STEP 3 : Find largest of three sides
STEP 4 : If (Largest Side)= (Side1)+(Side 2)GOTO STEP 5 ELSE STEP 6
STEP 5 : Print “Right Angled Triangle” GOTO STEP 7
STEP 6 : Print “Not a Right Angled Triangle.” GOTO STEP 7
STEP 7 : END
(2)
12 | Oswaal CBSE (Sample Question Papers) Computer Science, Class–XI
(e) String Operators
(i) + Operator
For strings, + means “concatenate”
Example:
>>> a = “hello”
>>> b = ‘world’
>>> a + b
‘helloworld’
# using double quote
# using single quote
# concatenates string
(ii) * Operator
This Operator creates new strings, concatenating multiple copies of the same string .
Example
>>>a=hello
>>>a*2
HelloHello
(iii) in
Evaluates to true if it finds a variable in the specified sequence and false otherwise
x in y, here in results in a 1 if x is a member of sequence y.
(iv) not in
Evaluates to true if it does not finds a variable in the specified sequence and false otherwise.
x not in y, here not in results in a 1 if x is not a member of sequence y.
(v) [m:n] Slice Operator
Gives the character from the given index
Like 119 people like this. Be the f irst of your f riends.
Example
>>> a = “hello”
>>> a[0] # get first character (same as list, zero indexed)
‘h’
>>> a[-1] # get last character
‘o’
>>> a[0:2] # get first two characters
(4)
4. (a) DBMS is a collection of programs that enables you to store, modify, and extract information
from a database. There are many different types of DBMSs, ranging from small systems
that run on personal computers to huge systems that run on mainframes.
(1)
(b) len() finds the length of the list.
reverse() reverses the list.
Example:
l=[1,2,3,4]
l.len() returns 4
l.reverese returns 4,3,2,1
(2)
(c) The Python interpreter can be used in two modes: interactive and scripted. In interactive
mode, Python responds to each statement while we type. In script mode, we give Python a
file of statements and turn it loose to interpret all of the statements in that script. Both
modes produce identical results. When we’re producing a finished application program, we
set it up to run as a script.
Interactive Mode:
It is a command line shell which gives immediate output for each statement.
>>> is the representation of each new line in Interactive mode. It is a better mode than
script mode since the output is faster.
Sample Question Papers | 13
Example:
>>> def abc(x):
>>> x=input()
>>>print x
Script Mode:
In script mode, we have to write a program in an editor. It is not a console based system.The
difference here is that we have to write and save the whole program at one and then call it
from the python shell. It is slower as compared to interactive mode but it is better when
writing big programs.
(3)
(d) The map() function applies a function to every member of a list. Here a list of numbers 32
to 255 is changed to a list of the corresponding ASCII characters. Then map() is used in a
more complex application to combine thet two lists to form a dictionary containing
number:character pairs.
Syntax:
map(f, iterable)
Example:
map(operator.setitem, [charD]*len(keyList), keyList,
valueList)
(3)
(e) A flowchart is a type of diagram that represents an algorithm or process, showing the
steps as boxes of various kinds, and their order by connecting them with arrows. This
diagrammatic representation illustrates a solution to a given problem. Process operations
are represented in these boxes, and arrows; rather, they are implied by the sequencing of
operations. Flowcharts are used in analyzing, designing, daocumenting or managing a
process or program in various fields.
Lamp doesn’t work
Lamp
plugged in?
No
Plug in lamp
Yes
Buib
burned out?
Yes
Replace lamp
No
Repair lamp
(3)
(f) (i) 30,10,18
(ii) No Output, size of a is less than the index.
(iii) 5,10,18
(iv) 30,20,18
(4)
5. (a) A compiler is a computer program (or set of programs) that transforms source code written
in a programming language (the source language) into another computer language (the target
language
(1)
(b) Basically there are two types of microprocessor architectures:
(i) RISC : RISC (reduced instruction set computer) is a microprocessor that is designed to
perform a smaller number of types of computer instructions so that it can operate at a
14 | Oswaal CBSE (Sample Question Papers) Computer Science, Class–XI
higher speed (perform more millions of instructions per second, or MIPS). Since each
instruction type that a computer must perform requires additional transistors and circuitry,
a larger list or set of computer instructions tends to make the microprocessor more
complicated and slower in operation.
(ii) CISC : The term “CISC” (complex instruction set computer or computing) refers to
computers designed with a full set of computer instructions that were intended to provide
needed capabilities in the most efficient way.
(3)
(c) happyhappy
happyhappyhappy
happyhappyhappyhappy
(3)
(d) def log(x):
sum = 0.0
n = 0.0
term = 1.0
while (term > .0000000001):
#loops until the iterations grow so large that ‘term’ becomes negligibly small
term = ((x ** (2 * n - 1.0))) / (factorial( n + 1.0))
if n % 2 == 0:
sum += term
else:
sum -= term
n += 1
return sum
(4)
6. (a) a function call is a statement in which a function is invoked from another function
(1)
(b) from math import pi
r = 123
area = pi * r**2
print “Area of circle with radius 123 = “ + str(area)
(2)
(c) 0
1
2
(3)
(d) The string module contains a number of useful constants and classes, as well as some
deprecated legacy functions that are also available as methods on strings. In addition,
Python’s built-in string classes support the sequence type methods described in the Sequence
Types — str, unicode, list, tuple, bytearray, buffer, xrange .
String constants
The constants defined in this module are:
string.ascii_letters
The concatenation of the ascii_lowercase and ascii_uppercase constants described
below. This value is not locale-dependent.
string.ascii_lowercase
The lowercase letters ‘abcdefghijklmnopqrstuvwxyz’. This value is not locale-dependent
and will not change.
string.ascii_uppercase
The uppercase letters ‘ABCDEFGHIJKLMNOPQRSTUVWXYZ’. This value is not localedependent and will not change.
string.digits
The string ‘0123456789’.
String Formatting
class string.Formatter
Sample Question Papers | 15
The Formatter class has the following public methods:
format(format_string, *args, **kwargs)¶
format() is the primary API method. It takes a format string and an arbitrary set of
positional and keyword arguments. format() is just a wrapper that calls vformat()
(4)
7. (a) Python is an interpreted language.
(1)
(b) Soft Real Time Systems are the systems where there is not a guarantee that the output
will be produced in a stipulated time.
(1)
(c) def possible_anagrams(word):
‘’’given a word, return a list of possible anagrams for that word’’’
if len(word) == 1:
yield word
for i, letter in enumerate(word):
# recursively call with a word whose characters have been rotated
for s in possible_anagrams(word[i+1:] + word[:i]):
yield ‘%s%s’ % (letter, s)
def anagrams(word):
‘’’given a word, return a list of anagrams in an english dictionary’’’
words = [w.rstrip() for w in open(‘WORD.LST’)]
return [a for a in possible_anagrams(word) if a in words]
if __name__ == “__main__”:
print anagrams(‘python’)
(4)
(d) Fourth Generation of Computers (1972-1984)
In this generation, there were developments of large-scale integration or LSI (1000 devices
per chip) and very large-scale integration or VLSI (10000 devices per chip). These
developments enabled the entire processor to fit into a single chip and in fact, for simple
systems, the entire computer with processor; main memory and I/O controllers could fit on
a single chip.
Core memories now were replaced by semiconductor memories and high-speed vectors
dominated the scenario. Names of few such vectors were Cray1, Cray X-MP and Cyber205.
A variety of parallel architectures developed too, but they were mostly in the experimental
stage.
As far as programming languages are concerned, there were development of high-level
languages like FP or functional programming and PROLOG (programming in logic).
Declarative programming style was the basis of these languages where a programmer could
leave many details to the compiler or runtime system. Alternatively languages like PASCAL,
C used imperative style. Two other conspicuous developments of this era were the C
programming language and UNIX operating system. Ritchie, the writer of C and Thompson
together used C to write a particular type of UNIX for DEC PDP 11. This C based UNIX
was then widely used in many computers.
(4)
qq
16 | Oswaal CBSE (Sample Question Papers) Computer Science, Class–XI
Sample Question Paper–9
1. (a) An advantage of using Propreitary Software over Open Source Software is that it is much
reliable than open source.
(1)
(b) Booting is the process of starting a computer, specifically in regards to starting its software.
The process involves a chain of stages, in which at each stage a smaller simpler program
loads and then executes the larger more complicated program of the next stage.
(1)
(c) (i) Power Management
(ii) Memory Management
(2)
(d) (i) Large Number of Instructions
(ii) Large Address Space
(2)
2. (a) BOSS- Bharat Operating System Solutions.
(1)
(b) Comments are used to convey a message to programmer that what a particular line of
code does in a program. No, It is not necessary to comment every line of code.
(2)
(c) A logic error is a bug in a program that causes it to operate incorrectly, but not to terminate
abnormally (or crash). A logic error produces unintended or undesired output or other
behavior, although it may not immediately be recognized as such.
Logic errors occur in both compiled and interpreted languages. Unlike a program with a
syntax error, a program with a logic error is a valid program in the language, though it
does not behave as intended. The only clue to the existence of logic errors is the production
of wrong solutions.
(2)
(d) (i) 5A
(ii) 467
(iii) 10 11
(3)
3. (a) Keyword is a reserved word that is used for a special purpose in a program.
(1)
(b) rint() function is used to round off the entered value.
Example: rint(5.6) gives answer as 6
abs() is used to return absolute value of entered number.
Example: abs(-2) gives 2
(2)
(c) lower( ) is used to convert entered string to lowercase
islower ( ) is used to check if entered string is lowercase or not.
Example:
lower(A) will return a
islower(A) will return False
(2)
(d) Algorithm:
STEP 1: START
STEP 2: Input income.
STEP 3: Check if income>100000
STEP 4: If yes, then print “You are eligible for income tax” GOTO STEP 6
STEP 5: If no, print “Not eligible for paying tax”
STEP 6: END
(2)
(e) Creating Lists
To create a list, put a number of expressions in square brackets:
L=[]
L = [expression, ...]
This construct is known as a “list display”. Python also supports computed lists, called “list
comprehensions”. In its simplest form, a list comprehension has the following
Sample Question Papers | 17
4. (a)
(b)
(c)
(d)
syntax:
L = [expression for variable in sequence]
where the expression is evaluated once, for every item in the sequence.
The expressions can be anything; you can put all kinds of objects in lists, including other
lists, and multiple references to a single object.
You can also use the built-in list type object to create lists:
L = list() # empty list
L = list(sequence)
L = list(expression for variable in sequence)
The sequence can be any kind of sequence object or iterable, including tuples and generators.
If you pass in another list, the list function makes a copy.
Note that Python creates a single new list every time you execute the [ ] expression. No
more, no less. And Python never creates a new list if you assign a list to a variable.
A = B = [ ] # both names will point to the same list
A=[]
B = A # both names will point to the same list
A = [ ]; B = [ ] # independent lists
For information on how to add items to a list once you’ve created it, see Modifying
Lists below.
Accessing Lists
Lists implement the standard sequence interface; len(L) returns the number of items in
the list, L[i] returns the item at index i (the first item has index 0), and L[i:j] returns a
new list, containing the objects between iand j.
n = len(L)
item = L[index]
seq = L[start:stop]
If you pass in a negative index, Python adds the length of the list to the index. L[-1] can be
used to access the last item in a list.
For normal indexing, if the resulting index is outside the list, Python raises an IndexError
exception. Slices are treated as boundaries instead, and the result will simply contain all
items between the boundaries.
Lists also support slice steps:
seq = L[start:stop:step]
seq = L[::2] # get every other item, starting with the first
seq = L[1::2] # get every other item, starting with the second
(4)
Inventory management software is a computer-based system for tracking inventory
levels, orders, sales and deliveries.
(2)
Unix (officially trademarked as UNIX, sometimes also written as UNIX in small caps) is
a multitasking, multi-user computer operating system originally developed in 1969 by a
group of AT&T employees at Bell Labs, including Ken Thompson,Dennis Ritchie, Brian
Kernighan, Douglas McIlroy, Michael Lesk and Joe Ossanna.
First developed in assembly language, by 1973 it had been almost entirely recoded in C,
greatly facilitating its further development and porting to other hardware.
(2)
Script Mode:
In script mode, we have to write a program in an editor. It is not a console based system.The
difference here is that we have to write and save the whole program at one and then call it
from the python shell. It is slower as compared to interactive mode but it is better when
writing big programs.
(3)
Some of the guidelines for effective problem solving are:
(i) Understand the problem well
(ii) Identify the conditions
(iii) List the possible solutions (options).
(iv) Evaluate the options.
18 | Oswaal CBSE (Sample Question Papers) Computer Science, Class–XI
(v) Select an option
(vi) Agree on contingencies
(vii) Monitor the progress.
(3)
(e)
Start
Input
N
M=1
N=1
F = F*M
M=M+1
No
Does
M = N?
Yes
F = 1*2*3 .... *N
Output
F
End
(f) (i)
(ii)
(iii)
(iv)
2
4
5,7,9
5,7,9
(3)
(1)
(1)
(1)
(1)
5. (a) def change_temp () :
C = input (“Enter °C”)
F = ((9*C + 160)/5)
Print C
(2)
(b) Latency is a measure of time delay experienced in a system, the precise definition of which
depends on the system and the time being measured. For an ideal system, seek time must
be the minimum.
(2)
(c) hellooswal
hellohellooswal
hellohellohellooswal
(3)
(d) def cosine(x):
term = float(x)
result = term # avoid ‘sum’ which is the name of a builtin function
u = term * term # this is minus (x squared)
n = 0 # use an integer for integer data
while abs(term) > 1.0e-10:
n += 2
term *= u / (n * (n+1))
Sample Question Papers | 19
6. (a)
(b)
(c)
(d)
7. (a)
(b)
(c)
result += term
return result
(4)
A function is a part of program that does a specific task.
(1)
>> b = ‘like to say’+ ‘hi’
>>c= b
>>println b+c
(1 mark for each correction)
0
0
3
(1 mark for each line)
The decision constructs in python are as follows:
(i) if statements
if statement checks for an expression and performs the decision based on the true or false
value of the expression.
n = raw_input(“Integer? “)#Pick an integer. And remember, if raw_input is not supported
by your OS, use input()
n = int(n)#Defines n as the integer you chose. (Alternatively, you can define n yourself)
if n < 0:
print (“The absolute value of”,n,”is”,-n)
(ii) eliif statements
if statement handles only cases where the value of expression is true while elif statement
can handles the cases when the value of expression is false.
a=0
while a < 10:
a=a+1
if a > 5:
print (a,”>”,5)
elif a <= 7:
print (a,”<=”,7)
else:
print (“Neither test was true”)
(4)
From math import pi
r = 56
P = 2*pi*r
Print “Perimeter =”+str(P).
(2)
Hard real time systems are the systems which guarantee to solve a certain problem in a
fixed time-period. One application of Hard Real Time Systems is in the Aircraft systems.
(2)
def User():
i,j = 0,0
s = raw_input(‘MOHAN’)
print “+”,
while(i < len(s)):
print “-”,
i = i +1
print “+”
print “| “,
print s, “ |”
print “+”,
while(j < len(s)):
print “-”,
j=j+1
print “+”
4
qq
20 | Oswaal CBSE (Sample Question Papers) Computer Science, Class–XI
Sample Question Paper–10
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.
(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)
SIMD
MIMD
1. There is only one instruction to fetch
data
Multiple Instructions to fetch data.
2. Lower level of parallelism achieved.
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.
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.
Sample Question Papers | 21
64
1
32
16
8
4
2
1
(64 < 87 ? yes)
(64 + 32 < 87 ? no)
(64 + 16 < 87 ? yes)
0
1
0
1
1
1
(64
(64
(64
(64
+
+
+
+
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.
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.
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])
22 | Oswaal CBSE (Sample Question Papers) Computer Science, Class–XI
Where [ Prompt ] is the string you would want to prompt the user 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
(2)
(1/2 mark for each correct answer)
while index len (n);
if n [index]==n[-1-index];
index+=1
return True.
return false
if Palindrome (n)=True
Print (“It is a Palindrone”)
Else
Print (“It is not a Palindrone”)
5. (a) x = 1
while x :
#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’)
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)
Sample Question Papers | 23
(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
(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)
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)
24 | Oswaal CBSE (Sample Question Papers) Computer Science, Class–XI
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)
qq