0% found this document useful (0 votes)
48 views20 pages

12CS HHW

Uploaded by

Sarah Kayiti
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)
48 views20 pages

12CS HHW

Uploaded by

Sarah Kayiti
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/ 20

CLASS XII ABI

HOLIDAY HOMEWORK 2024-25

PYTHON REVISION TOUR

1 Find the invalid identifier from the following


a) None
b) address
c) Name
d) pass

2 Write the type of tokens from the following:


a) If
b) roll_no

3 Consider a declaration L = (1, 'Python', '3.14').


Which of the following represents the data type of L?
a) List
b) Tuple
c) Dictionary
d) String

4 Identify the valid arithmetic operator in Python from the following.


a) ?
b) <
c) **
d) And

5 Which of the following statements is/are not python keywords?


a) False
b) Math
c) WHILE
d) Break

6 Which of the following is a valid keyword in Python?


a) False
b) return
c) non_local
d) none

7 State True or False.


"Identifiers are names used to identify a variable, function in a program".

8 Identify the invalid identifier out of the options given below.


a) Qwer_12
b) IF
c) Play123
d) Turn.over

9 One of the following statements will raise error. Identify the statement that will
raise the error.
a)
b)
c)
d) None of above will raise error

10 Given the following Tuple


Tup (10, 20, 30, 50)
Which of the following statements will result in an error?
a) print (Tup [0])
b) print (Tup [1:2])
c) Tup.insert (2,3)
d) print(len (Tup))

11 Consider the given expression : 5<10 and 12>7 or not 7>4


Which of the following will be the correct output, if the given expression is
evaluated?
a) True
b) False
c) NULL
d) NONE

12 Which of the following will give output as [5,14,6] if lst=[1,5,9,14,2,6]?


a) print(lst[0::2])
b) print(lst[1::2])
c) print(lst[1:5:2])
d) print(lst[0:6:2])

13 The return type of the input() function is


a) string
b) Integer
c) list
d) tuple

14 Which of the following operator cannot be used with string data type?
a) +
b) In
c) *
d) /

15 Consider a tuple tup1 = (10, 15, 25, and 30). Identify the statement that will result
in an error.
a) print(tup1[2])
b) tup1[2] = 20
c) print(min(tup1))
d) print(len(tup1))

16 Which one of the following is the default extension of a Python file?


a) .exe
b) .p++
c) .py
d) .p

17 Which of the following symbol is used in Python for single line comment?
a) /
b) /*
c) //
d) #

18 Which of these about a dictionary is false?


a) The values of a dictionary can be accessed using keys
b) The keys of a dictionary can be accessed using values
c)
d) Dictionaries are mutable

19 Which is the correct form of declaration of dictionary?


a)
b)
c)
d)

20 What will be the output of the following statement:


print(3-2**2**3+99/11)
a) 244
b) 244.0
c) -244.0
d) Error

21 What is the output of following code:


T=(100) print(T*2)
a) Syntax error
b) (200,)
c) 200
d) (100,100)

22 Identify the output of the following Python statements:


x = [[10.0, 11.0, 12.0],[13.0, 14.0, 15.0]] y = x[1][2] print(y)
a) 12.0
b) 13.0
c) 14.0
d) 15.0

23 Select the correct output of the code :


S= "Amrit Mahotsav @ 75" A=S.partition (" ") print (a)
a) ('Amrit Mahotsav', '@', '75')
b) ['Amrit', 'Mahotsav', '@', '75']
c) ('Amrit', 'Mahotsav @ 75')
d) ('Amrit', '', 'Mahotsav @ 75')
24 Identify the output of the following Python statements.
x=2
while x < 9:
print(x, end='')
x=x+1
a) 12345678
b) 123456789
c) 2345678
d) 23456789

25 Identify the output of the following Python statements.


b=1
for a in range(1, 10, 2):
b += a + 2
print(b)
a) 31
b) 33
c) 36
d) 39

26 A tuple is declared as T = (2,5,6,9,8). What will be the value of sum(T)?

27 Identify the output of the following Python statements.


lst1 = [10, 15, 20, 25, 30]
lst1.insert( 3, 4)
lst1.insert( 2, 3)
print (lst1[-5])
a) 2
b) 3
c) 4
d) 20

28 Evaluate the following expression and identify the correct answer.


16 - (4 + 2) * 5 + 2**3 * 4
a) 54
b) 46
c) 18
d) 32

29 Fill in the blank.


________________function is used to arrange the elements of a list in ascending
order.
a) sort()
b) ascending()
c) arrange()
d) asort()
30 Which of the following will delete key-
D1?
a) delete D1("Red")
b) del D1["Red"]
c) del.D1["Red"]
d) D1.del["Red"]

31
a) dictionary
b) string
c) tuple
d) list

32 Given a Tuple tup1= (10, 20, 30, 40, 50, 60, 70, 80, 90).
What will be the output of print (tup1 [3:7:2])?
a) (40,50,60,70,80)
b) (40,50,60,70)
c) [40,60]
d) (40,60)

33 If the following code is executed, what will be the output of the following code?
name="ComputerSciencewithPython"
print(name[3:10])

34 Which of the following statement(s) would give an error during execution of the
following code?

a) Statement 1
b) Statement 2
c) Statement 3
d) Statement 4

35 Consider the statements given below and then c hoose the correct output from the
given options:
pride="#G20 Presidency"
print(pride[-2:2:-2])
a) ndsr
b) ceieP0
c) ceieP
d) yndsr

36 Given is a Python list declaration :


Listofnames=["Aman", "Ankit", "Ashish", "Rajan", "Rajat"]
Write the output of:
print (Listofnames [-1:-4:-1])

37 What will be the output of the following code:

Cities[0],Cities[1]=Cities[1],Cities[0]
print(Cities)

38 What will be the output of the following code?


tup1 = (1,2,[1,2],3)
tup1[2][1]=3.14
print(tup1)
a) (1,2,[3.14,2],3)
b) (1,2,[1,3.14],3)
c) (1,2,[1,2],3.14)
d) Error Message

39 Select the correct output of the code:

a) PYTHON-IS-Fun
b) PYTHON-is-Fun
c) Python-is-fun
d) PYTHON-Is Fun

40 What will be the result of following python code?

41
a) N=len(s)
b) T=S
c)
d)

42 Which of the following statement(s) would give an error after executing the
following code?
Stud={"Murugan":100,"Mithu":95} # Statement 1
print (Stud [95]) # Statement 2
Stud ["Murugan"]=99 # Statement 3
print (Stud.pop()) # Statement 4
print (Stud) # Statement 5
a) Statement 2
b) Statement 4
c) Statement 3
d) Statements 2 and 4

43 What will be the output of following Python code?

a) False
b) True
c) Error
d) None

44 Write a statement in Python to declare a dictionary whose keys are 1, 2, 3 and


values are Monday, Tuesday and Wednesday respectively.

45 Assertion(A): List is an immutable data type


Reasoning(R): When an attempt is made to update the value of an immutable
variable, the old variable is destroyed and a new variable is created by the same
name in memory
a) Both A and R are true and R is the correct explanation for A
b) Both A and R are true and R is not the correct explanation for A
c) A is True but R is False
d) A is false but R is True

46 Assertion (A): Python Standard Library consists of various modules.


Reasoning(R): A function in a module is used to simplify the code and avoids
repetition.
a) Both A and R are true and R is the correct explanation for A
b) Both A and R are true and R is not the correct explanation for A
c) A is True but R is False
d) A is false but R is True

47 Assertion(A): List is an immutable data type


Reasoning(R): When an attempt is made to update the value of an immutable
variable, the old variable is destroyed and a new variable is created by the same
name in memory.
a) Both A and R are true and R is the correct explanation for A
b) Both A and R are true and R is not the correct explanation for A
c) A is True but R is False
d) A is false but R is True

48 Assertion (A) : List can not become key in a dictionary.


Reasoning(R) : Only integers can be keys in a dictionary.
a) Both A and R are true and R is correct explanation of A
b) Both A and R are true but R is not correct explanation of A
c) A is True but R is false
d) R is true but A is false

Weightage : 2 marks
1 Rewrite the following code in python after removing all syntax error(s). Underline
each correction done in the code.
30=To
for K in range(0,To)
IF k%4==0:
print (K*4)
Else:
print (K+3)

2 Rewrite the following code after removing all syntax error(s) and underline each
correction done:
Runs=(10,5,0,2,4,3)
for I in Runs:
if I=0:
print(Maiden Over)
else:
print(Not Maiden)

3 Evaluate the following Python expression:


a) 2*3+4**2-5//2
b) 6<12 and not (20>15) or (10>5)

4 Predict the output of the following code:


S="LOST"
L=[10,21,33,4]
D={}
for I in range(len(S)):
if I%2==0:
D[L.pop()]=S[I]
else:
D[L.pop()]=I+3
for K,V in D.items():
print(K,V,sep="*")

5 Write the Python statement for each of the following tasks using BUILT- IN
functions/methods only:
(i) To insert an element 200 at the third position, in the list L1.
(ii) To check whether a string named, message ends with a full stop / period or not.

6 A list named studentAge stores age of students of a class. Write the Python
command to import the required module and (using built-in function) to display
the most common age value from the given list.
Weightage : 3 marks
1 Find the output of the following code:
Name="PythoN3.1"
R=""
for x in range(len(Name)):
if Name[x].isupper():
R=R+Name[x].lower()
elif Name[x].islower():
R=R+Name[x].upper()
elif Name[x].isdigit():
R=R+Name[x-1]
else:
R=R+"#"
print(R)

2 Predict the output of the Python code given below:


FUNCTIONS IN PYTHON

1. What will be the output of the following code?

a) 10
b) 30
c) error
d) 20

2. Name the Python Library modules which need to be imported to invoke the
following functions:
a) sin()
b) randint()

3. What is the scope of a variable defined inside a function?


a) Global scope
b) Local scope
c) Universal scope
d) Function scope

4. In Python, can a function return multiple values simultaneously?


a) Yes
b) No

5. What is the purpose of the "return" statement in a function?


a) It specifies the type of the function.
b) It defines the input parameters of the function.
c) It indicates the end of a function.
d) It returns a value from the function to the caller.

6. Which of the following module functions generates an integer?


a) randint()
b) uniform()
c) random()
d) all of these

7. The return type of the input() function is


a) string
b) integer
c) list
d) tuple
8. The values being passed through a function call statements are called
a) Actual parameter
b) Formal parameter
c) default parameter
d) None of these

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

10. Which of the following function header is correct?


a) def cal_si(p=100, r, t=2)
b) def cal_si(p=100, r=8, t)
c) def cal_si(p, r=8, t)
d) def cal_si(p, r=8, t=2)

11. Which of the following is the correct way to call a function?


a) my_func()
b) def my_func()
c) return my_func
d) call my_func()
12. Consider the code given below:
Which of the following statements should be given in the blank for #Missing
Statement, if the output produced is 110?

a) global a
b) global b=100
c) global b
d) global a=100

13. What will be the output?


a) 5
b) 6
c) 4
d) This code will raise an error.

14. A function is defined as below, the function call parameters can be:

a) Two tuples
b) Two numbers
c) One number
d) All of the above

15. Statistics.mode([10,10,11,12,14,11,11,15,15,16,15]) will return


(consider module is imported)
a) 10
b) 15
c) 11
d) Error

16. 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 Lower and Upper.

a) 10#40#70#
b) 30#40#50#
c) 50#60#70#
d) 40#50#70#
17. What will be the output of the Python code?
>>> def testify(a,b):
return a-b
>>> sum=testify(22,55)
>>> sum+30
a) 33
b) -33
c) 3
d) -3

18. What will be the output of the following code?


>>> def a(b=11, c=21):
b += 13
c -= 13
return b+c 0.77
>>> print(a(25), a(35))
a) 15 18
b) 46 56
c) 25 35
d) 13 12

19. What will be the output of the following code?


num=100
def showval(X):
global num
num = 85
if(X%2==0):
num += X
else:
num -= X
print(num,end="#")
showval(33)
print(num)
a) 100#52
b) 85#52
c) 85#33
d) 185#52

20. Find the impossible option from the following


>>> import random
>>> L=[i for i in range(random.randint(3,5))]
a) [0, 1, 2, 3]
b) [0, 1, 2, 3, 4]
c) [0, 1, 2, 3, 4, 5]
d) [0, 1, 2]

21. Look at the function definition and the function call and determine the correct
output
>>> def test(a):
if(a>10):
a += 10
if(a>20):
a += 20
if(a>30):
a +=30
print(a)
>>> test(11)

a) 21
b) 72
c) 61
d) 71

22. Predict output:

a) [1, 2, 3, 4, 5, 6]
b) [100, 2, 3, 4, 5, 6]
c) [100, 2, 3, 4, 5]
d) [1, 2, 3, 4, 5]

23. Predict output:

a) [1, 2, 3, 4]
b) [5, 6, 7]
c) [1, 2, 3, 4, 5, 6, 7]
d) This code will raise an error.

24. Assertion (A): To use a function from a particular module, we need to import
the module.
Reason (R): import statement can be written anywhere in the program,
before using a function from that module.
a) Both A and R are true and R is the correct explanation for A
b) Both A and R are true and R is not the correct explanation for A
c) A is True but R is False
d) A is false but R is True
25. What will be the output of the following Python code?
def add (num1, num2):
sum = num1 + num2
sum = add(20,30)
print(sum)

26. Find and write the output of following python code:


def Alter(M,N=45):
M = M+N
N = M-N
print(M,"@",)
return M
A=Alter(20,30)
print(A,"#")
B=Alter(30)
print(B,"#")

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

a) 10#40#70#
b) 30#40#50#
c) 50#60#70#
d) 40#50#70#

28. Predict output:


29. Predict output:

30. Rewrite the following code after removing the syntactical errors (if any).
Underline each correction.

31. What will be the output of the following code?


def my_func(var1=100, var2=200):
var1+=10
var2 = var2 - 10
return var1+var2
print(my_func(50),my_func())

32. What will be the output of the following code?

33. What will be the possible outcomes:

a) Delhi#Mumbai#Chennai#Kolkata#
b) Mumbai#Chennai#Kolkata#Mumbai#
c) Mumbai# Mumbai #Mumbai # Delhi#
d) Mumbai# Mumbai #Chennai # Mumbai
34. What will be the output of the following code?

35. What is the output of the following code snippet?

i. ii.

36. What will be the output of the following code?

37. Find and write the output of the following Python code:
def Display(str):
m=""
for i in range(0,len(str)):
if(str[i].isupper()):
m=m+str[i].lower()
elif str[i].islower():
m=m+str[i].upper()
else:
if i%2==0:
m=m+str[i-1]
else:
m=m+"#" print(m)
Display('Fun@Python3.0')
38. Find and write the output of the following python code:

I ii

39. What are the possible outcome/(s) for the following code.Also specify the
maximum and minimum value of R when K is assigned value as 2:

a) Stop # Wait # Go
b) Wait # Stop #
c) Go # Wait #
d) Go # Stop #

40. Write the output of the following Python code:


41. Explain the positional parameters in Python function with the help of
suitable example.
42. Predict the output of following:

i. ii.

iii. iv.

v vi

43. Predict output :

44. What possible outputs(s) will be obtained when the following code is
executed?

Options:
a) RED* b) WHITE*
WHITE* BLACK*
BLACK*
c) WHITE* WHITE* d) YELLOW*
BLACK* BLACK* WHITE*WHITE*
BLACK* BLACK* BLACK*
45. 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 BEGIN and END.

a) 60#35#
b) 60#35#70#50#
c) 35#70#50#
d) 40#55#60#

• MAKE ART INTEGRATION ON COMPUTER NETWORK

• COMPLETE YOUR PRACTICAL FILE AND PROJECT SYNOPSIS

You might also like