Xii Computer Assignment (2023-24)
Xii Computer Assignment (2023-24)
Xii Computer Assignment (2023-24)
Class XII
COMPUTER SCIENCE
ASSIGNMENT
GENERAL INSTRUCTIONS:
• Holidays Homework must be done in a very neat and presentable
manner.
• Submission of Holidays Homework post vacation is compulsory
for all the students.
Revision of Python Topic
1) T=1,2,3
(a) Tuple (b) List (c) variable (d) None of these
2) Evaluate the following expression
Not 20>21 and 6>5 or 7>9
(a) True (b) False (c) 3 (d) None of these
3) What will the following expression be evaluated to in Python?
print(15.0 / 4 + (8 + 3.0))
(a) 14.75 (b)14.0 (c) 15 (d) 15.5
4) Which is valid keyword?
(a) Int (b) WHILE (c) While (d) if
5) Which of the following is not a valid identifier name in Python?
(a) 5Total (b) _Radius (c) pie (d) While
6) Consider the following expression:
51+4-3**3//19-3
Which of the following will be the correct output if the expression is evaluated?
7) What will the following expression be evaluated to in Python?
10*1*2**4-4//4
8) What is the output of the expression 3*1**3?
9) What is the output of the expression 3**1**3?
10) Find and write the output of the following:
x="abcdef"
i="a"
while (i in x):
print( i, end=” “)
11) How many times will the following for loop execute and what’s the output?
(i) for i in range(-1,7,-2):
for j in range(3):
print(1,j)
12) What are data types? What are Python’s built in core data types?
13) What are immutable and mutable types? List immutable and mutable types of Python.
14) What is the difference between implicit and explicit type conversion?
15) What is entry controlled loop? Which loop is entry controlled loop in Python?
16) What are the two ways to add something to a list? How are they different?
17) What are the two ways of removing something from a list? How are they different?
18) What is the difference between (30) and (30,)?
19) How is del(D) and del (D[<key>]) different from one another if D is a dictionary?
20) Name the function/method required to:
a) Check if a string contains only lowercase letters
b) Check if a string contains only digits
c) Check if a string contains only spaces
21) Rewrite the following code in python after removing all syntax error(s). Underline each
correction done in the code.
25=Val 30=To STRING ="WELCOME"
for i in the range(0,Val) for K in range(0,To) NOTE=""
if i %2=0: IF k%5==0: for st in range[0,8]:
Print(i +1) print (K*4) print(STRING(S))
Else: Else: print(S STRING)
print (i -1) print (K+3)
(a) (b) (C)
22) What will be the output of the following Python code snippet?
X=11
If X<=10:
X+=10
if X<=20 :
X+=10
If X<=30:
X+=30
(a) Year . 0. at All the best (b) Year 0. at All the best
(c) Year . 022. at All the best (d) Year . 0. at all the best
Find the suggested output (i) to (iv). Also find the least and highest value that can be
generated:
(i) 20 22 24 25 (ii) 22 23 24 25 (iii) 23 24 23 24 (iv) 21 21 21 21
10) Rewrite the following Python code after removing all syntax error(s). underline the
corrections done.
def main() :
r = input ( ‘ enter any radius: ‘)
A – pi * maths.pow (r,2)
Print (“Area = “ +a)
Main()
11) Give output:
def max_of_two( x, y ):
if x > y:
return x
else
return y
def max_of_three( x, y, z ):
return max_of_two( x, max_of_two( y, z ) )
print(max_of_three(3, 6, -5))
14) Study the following program and select the possible output(s) and write maximum
and minimum value assigned to the variable y
import random
x=random.random( )
y=random.ranint(0,4)
print((int(x),":",y+int(x)))
17) Find and write the output of the following python code:
def Call(P=40,Q=20):
P=P+Q
Q=P–Q
print(P,'@',Q)
return P
R=200
S=100
R=Call(R,S)
print (R,'@',S)
S=Call(S)
print(R,'@',S)
18) Write the output of following python code:
def result(s):
n = len(s)
m=''
for i in range(0, n):
if (s[i] >= 'a' and s[i] <= 'm'):
m = m + s[i].upper()
elif (s[i] >= 'n' and s[i] <= 'z'):
m = m + s[i-1]
elif (s[i].isupper()):
m = m + s[i].lower()
else:
m = m + '#'
print(m)
result('Cricket')
19) Write a method/function COUNTLINES_ET() in python to read a string and COUNT the
number of ‘E’ or ‘e’ and
Number of 'T' and 't' display the Total count separately.
20) Write a method/ function SHOW_TODO() in python to read a string and COUNT the
number of words "TO" and "DO" and display the total count separately.
21) Python funtion oddeve(L) to print positive numbers in a list L.
Example: Input: [4, -1, 5, 9, -6, 2, -9, 8]
Output: [4, 5, 9, 2, 8]
20) Write definition of a Method COUNTROW(REGIONS) to find and display names of
those REGIONS, in which there are less than or equal to 5 characters.
For example :
If the list REGIONS contains ["GOA","NEW DELHI", "DAMAN", "CHENNAI", "BANGALORE"]
The following should get displayed
GOA
DAMAN