XII Computer Science -TERM 1: Syllabus & Topics
Revision of Python topics covered in Class XI.
●Introduction to Python, features of Python, execution modes: interactive mode and script mode,
Python character set, Python tokens (keyword, identifier, literal, operator, punctuator), variables,
concept of l-value and r-value, use of comments
● Knowledge of data types: number (integer, floating point, complex), boolean, sequence (string,
list, tuple), none, mapping (dictionary), mutable and immutable data types
● Operators: arithmetic operators, relational operators, logical operators, assignment operator,
augmented assignment operators, identity operators (is, is not), membership operators (in, not in)
● Expressions, statement, type conversion & input/output: precedence of operators, expression,
evaluation of expression, python statement, type conversion (explicit & implicit conversion),
accepting data as input from the console and displaying output
● Errors: syntax errors, logical errors, runtime errors
● Flow of control: introduction, use of indentation, sequential flow, conditional and iterative flow
control
● Conditional statements: if, if-else, if-elif-else, flowcharts, simple programs: e.g.: absolute value,
sort 3 numbers and divisibility of a number
● Iterative statements: for loop, range function, while loop, break and continue
statements, nested loops
( ● Strings: introduction, indexing, string operations (concatenation, repetition, membership &
slicing), traversing a string using loops, built-in functions: len(), capitalize(), title(), lower(), upper(),
count(), find(), index(), endswith(), startswith(), isalnum(), isalpha(), isdigit(), islower(), isupper(),
isspace(), lstrip(), rstrip(), strip(), replace(), join(), partition(), split()
● Lists: introduction, indexing, list operations (concatenation, repetition, membership & slicing),
traversing a list using loops, built-in functions: len(), list(), append(), extend(), insert(), count(),
index(), remove(), pop(), reverse(), sort(), sorted(), min(), max(), sum(); nested lists, suggested
programs: finding the maximum, minimum, mean of numeric values stored in a list; linear search
on list of numbers and counting the frequency of elements in a list
● Tuples: introduction, indexing, tuple operations (concatenation, repetition, membership &
slicing),built-in functions: len(), tuple(), count(), index(), sorted(), min(), max(), sum(); tuple
assignment,nested tuple, suggested programs: finding the minimum, maximum, mean of values
stored in atuple; linear search on a tuple of numbers, counting the frequency of elements in a tuple
● Dictionary: introduction, accessing items in a dictionary using keys, mutability of dictionary
(addinga new item, modifying an existing item), traversing a dictionary, built-in functions: len(),
dict(),keys(), values(), items(), get(), update(), del(), clear(), fromkeys(), copy(), pop(), popitem(),
setdefault(), max(), min(), count(), sorted(), copy(); suggested programs : count the number of
times a character appears in a given string using a dictionary, create a dictionary with names of
employees, their salary and access them
● Introduction to Python modules: , Importing math module (pi, e, sqrt, ceil, floor, pow, fabs, sin,
cos, tan); random module (random, randint, randrange), statistics module (mean, median, mode)
Functions: types of function (built-in functions, functions defined in module, user
definedfunctions), creating user defined function, arguments and parameters, default
parameters,positional parameters, function returning value(s), flow of execution,
scope of a variable (globalscope, local scope)
Introduction to files, types of files (Text file, Binary file, CSV file), relative and
absolute paths
Text file: opening a text file, text file open modes (r, r+, w, w+, a, a+), closing a text
file, opening afile using with clause, writing/appending data to a text file using write()
and writelines(), readingfrom a text file using read(), readline() and readlines(), seek
and tell methods, manipulation of data in a text file
Binary file: basic operations on a binary file: open using file open modes (rb, rb+,
wb, wb+, ab, ab+),
close a binary file, import pickle module, dump() and load() method, read,
write/create, search, append and update operations in a binary file
CSV file: import csv module, open / close csv file, write into a csv file using
[Link]() and read from a csv file using [Link]( )
XI – Python Recap
1. Which of the following are invalid identifier?
(a) While (b)XthClass (c) _Flash10 (iv) True
2 .What is the output of this code?
print( int(“3”+”4”))
(a)“7” (b) 7 (c) 34 (d) 24
3. _________ function is used to find the position of an item in the list
(a) find() (b)index() (c) pos() (d) position()
4. And, Or and Not are ___________ operators.
(a) Relational (b)Logical (c) Arithmetic (d) Comparison
5. The following statement will return _________
Lst=(1,2,3,4,5,6,7)
print(Lst[2:6])
(a)Tuple (b)Dictionary (c)List (d) None of the above
6. Select the command will insert 7 in third position of List L.
(a) [Link](3,7) (b) [Link](7,3) (c) [Link](2,7) (d) [Link](7,2)
7. Select the result of the following:
L1 = [1, 2, 3]
L2 = [1, 2, 3, 4, 5, 6]
print(L1 in L2)
(a)True (b)False (c) Error (d) None of the above
8. Which of the following statement will return error?
print(int("a")) #Statement1
print(str(123)) #Statement2
(a)Satement1 (b)Statement2 (c)Both Statement (d)None of the above
9. Dictionary keys are of _______________ types.
(a)Mutable (b)List (c) Immutable (d)None
10. Which one of the following is the correct input statement?
(i) Marks=float(input(‘Enter the marks’)
(ii) Marks=float(“Enter the marks”)
(iii) Marks =float(input(‘Enter the marks’))
(iv) Marks =input (float(“Enter the marks”))
11. The ________ method remove all items from the dictionary.
(a) pop () (b) del() (c) clear() (d)All of the above
To which python module does fabs() function belongs to.
(i)random (ii)math (iii)system (iv)statistics
Evaluate the following expression and identify the correct answer.
import math
a=[Link](3,3)+round(48.7)-[Link]((4.89)
(i) 79.0 (ii) 80.0 (iii)72.0 (iv) 81.0
1. ___________ is a file containing python definitions and statements intended for use in other python
programs.
(i) library (ii) module (iii) function (iv) import
2. Choose the correct possible output for the following code fragment:
print(3+[Link](3,5 )*2)
(i) 12 (ii) 13 (ii)14 (iv) 15
5. What will be the output produced by the following code?
print(round(583.4579,2))
(i) 583.467 (ii) 583.45 (iii) 583.46 (iv) 583.50
3 . The return type of the input() function is
a. string b. integer c. list d. tuple
4. Which of the following components are part of a function header in Python?
a. Function Name b. Return Statement c. Parameter List d. Both a and c
5. A function in python begins with a keyword
(i) return (ii) void (iii) int (iv)def
6. This function defines a series of numbers
(i) random() (ii) len() (iii) range() (iv) type()
3. The function which is written by the programmer as per his/her requirement is known as
(i) module (ii) built-in (iii) user-defined (iv) keyword
8. What will be the output produced by the following code?
print(round(8962.79,-2))
(i) 9000.0 (ii) 8900.0 (iii) 8970.0 (iv) 8000.0
2. This function converts its argument in to string .
(i) chr() (ii) str() (iii) eval() (iv)type()
7. Identify the correct function declaration statement/function header.
(i) def Diplay(X=5, Y=45, Z) :
(ii) def Display(A, B= “A+”, C=A%3):
(iii) def Display(M, N=20, K= 20>10):
(iv) def Display( Qty=0, Price, Type=’A’):
8. Which values used by the functions to communicate information back to the caller.
(i) local (ii) global (iii) return (iv) random
Identify the incorrect statement regarding local and global variables
(i) Local variables cannot be accessed outside the function
(ii) Global variable can be accessed in a function using the keyword global
(iii) If a local variable exists with the same name of global variable then global variable is shadowed
(iv) The lifetime of local variable is the entire program run.
(iv) What possible outputs(s) are expected to be displayed on screen at the time of execution of the
program from the following code? Also specify the maximum values that can be assigned to each
of the variables FROM and TO.
import random
AR=[20,30,40,50,60,70];
FROM=[Link](1,3)
TO=[Link](2,4)
for K in range(FROM,TO+1):
print (AR[K],end=”#“)
output options:(i) 10#40#70# (ii) 30#40#50# (iii) 50#60#70# (iv) 40#50#70#
What will be the output of the following
i) print(round(1244.892,-2))
ii) print(ord(‘B’))
Find the correct possible output(s) from the options.
import random
TEXT = "PROGRAMMING"
COUNT = [Link](0,3)
C=10
while TEXT[C] != 'M':
print(TEXT[C]+TEXT[COUNT]+' * ',end="")
COUNT= COUNT + 1
C = C-1
output options:
(i) GG * NR * IA* (ii) GP * NR * IO * (iii) OG * NG * IR * (iv) GR * NO * IG*
4. Name the function that returns the length of items in an object
5. Name the variable which is created or defined within a function body
[Link] the function that defines a series of numbers
7. The arguments present in the function call are --------- arguments
8. The function which is written by the programmer as per his/her requirement is known as ---------------
[Link] variable declared outside the function are called -----------
10. The -------- of a variable is the area of the program where it may be referenced.
11. What will be the output produced by the following code?
print(round(2949.2358,-3))
(i) 2900.0 (ii) 2000.0 (iii) 3000.0 (iv)2949.236
7. The arguments present in the function header are called ---------.
(i) Local argument (ii) global argument (iii) formal argument (iv) actual argument
8. Which of the following keywords marks the beginning of the function block
(i) define (ii) fun (iii)return (iv)def
9. The values being passed through the function call statement are called _________
(i) real arguments (ii) actual arguments (iii) global arguments (iv) formal arguments
10. Choose the correct output for the following program
def Change(S):
S*=2
S+='2'
print(S)
Change('15')
(i)32 (ii)152152 (iii) 302 (iv)15152
11. How many values a python function can return ?
(i) one value (ii) zero value (iii) multiple values (ii) two values
12. Choose the correct output for the following program
def Change(L):
return(L[2]+5//2)
Values=[5,20,100,110,50]
print(Change(Values))
(i) 100 (ii) 102 (iii)52 (iv) 50
13. Which of the following function calls can be used to invoke the below function definition?
def Execute(A,B,C=10,D=0):
print(A+B)
(i) Execute(10, B=40, C=20,A=50)
(ii)Execute(A=5, B=100, B=C=50)
(iii)Execute(A=20, 30)
(iv)Execute(2, B=30)
14. Choose the correct output for the following program
def interest(P=4000,R=2,T=0.10):
return(P*R*T)
print(interest(5000,3))
(i)1200.0 (ii)1500.0 (iii)800.0 (iv) 1000.0
15. Find the output of the following
def fun(x,y=15):
if x%y ==0:
return x+y
else:
return y-1
p,q=60,10
q=fun(p,q)
p=fun(q)
print(p,q)
(i) 70 15 (ii) 9 70 (iii)14 70 (iv) 70 14
16. Find the output of the following
X=10
def Global(Y):
global X
X=15
X+=Y
return (X+Y)
K=Global(X)
print(X+K)
(i) 50 (ii) 60 (iii)45 (iv)35
17. Find the correct possible output(s) from the options.
import random
Lst=[50,70,80,90]
option=[Link](0,2)+3;
for K in range(1,4):
chance=[Link](4-K)
print(Lst[chance]+option,end='#')
Output options: i) 85#54#53# (ii) 54#74#54# iii) 75#75#75# iv) 55#74#73#
1. Which method is used to represent today’s date and time?
(i) now() (ii)datetime() (iii)today() (iv)date()
2. This function converts its argument in to string .
(i) chr() (ii) str() (iii) eval() (iv)type()
3. The arguments present in the function header are called ---------.
(i) Local argument (ii) global argument (iii) formal argument (iv) actual argument
4. What will be the output produced by the following code?
print(round(759285.49,-2))
(i) 759000.0 (ii) 7592900.0 (iii) 759300.0 (iv) 759200.0
5. What will be the maximum value of X?
X= 3*([Link](5,8)+5)//3
(i) 13 (ii)14 (iii)12 (iv)10
6. Consider the following python program
import random
STR="MEDIA@CYBER"
NUM=[Link](0,3)
K=10
while STR[K]!='C':
print(STR[K]+STR[NUM]+'*',end='')
NUM=NUM+1
K=K-1
Which of the following option(s) is possible to display as output for the above program
output options: (i) RD*EI*BA*YC* (ii) RM*EE*BD*YI*
(iii) RE*ER*BI*YA* (iv) RI*EA*BA*YC*