You are on page 1of 8

GREENFIELD CHENNAI INTERNATIONAL SCHOOL

MADHAVARAM
Class:12
PYTHON REVISION TOUR -1 WORKSHEET

1. Predict the output


NUM1=4
NUM2=NUM1+1
NUM1=print(NUM1,NUM2)

print(NUM1)
2. int(‘X’) produces error but the expression
len(‘X’) or int(‘X’) will not. Why?
3. What is the output of the statement
print(print(print(“Jackfruit”,end=”***”)))
4. Consider the loop given below:
for I in range(-50):
print(i)
How many times will this loop run
5. Write the output for the following code.
X=100
P=10
Q=25
if P%6==0:
X+=100
else:
X+=50
Sum=P+Q+X
print(P,'#',Q,'$',Sum)
6. What will be the output of the following statement?
print(2+9*((3*12)-8)/10)

7. What will be the output of the following statement?


print(2**5+8.5//3*2**0-2)

8. What will be the output of the following statement?


n1=4
n2=3
n1**=n2+1
print(n1)
9. print(18%4**3//7+9)
10.print(2>5 or 5==5 and not 12 <= 9)
11.for i in range(-1,-7,-2):
for j in range(3): print(1,j,'\
t',end='', ,sep="@")
12.a=5-4-3
b=3**2**3
print(a,b)
d=3+5/8
e=int(3+5/8)
f=int(3+5/8.0)
g=3+float(5//8)
print(d,e,f,g)
13.State True or False:
“The else part of a loop gets executed only when a break statement terminates
it.”

14.print(5-(2+3)*99/11+2**3**2)
15. What possible outputs(s) are expected to be displayed on screen at the time of

execution of the program from the following code?

import random
AR=[20,30,40,50,60,70]
FROM=random.randint(1,3)
TO=random.randint(2,4)
for K in range(FROM,TO+1):
print (AR[K],end="#")

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

16. Predict the output of the following code:


s="First Model 2023"
r=' '
for i in range(len(s)):
if s[i].isupper():
r=r+s[i].lower()
elif s[i].islower():
r=r+s[i].upper()
elif i%2==0:
r=r+s[i-1]
else:
r=r+'&'
print(r)
17. Which of the following is an invalid identifier to be used in Python?

a. per%marks b. _for c. While d. true


18. Which of the following is not a component of the math module in Python?
a. ceil() b. mean() c. fabs() d. pi
19. a=‟3‟
b=‟2‟
c=a+b
20. predict output.
a = "Hello"
b = "llo"
c = a-b
print(c)
21. print("he"+1+2)
22. print(True or not False and True)
23. print(2**3**2//8)
24. Which of the following is not considered a valid identifier in Python:
(i)three3 (ii)_main (iii)hello_kv1 (iv)2 thousand
25. Which of the following is the mutable data type in python:
(i)int (ii) string (iii)tuple (iv)list

26. Which of the following statement converts a tuple into a list in Python:
(i) len(string) (ii)list(tuple) (iii)tup(list) (iv)dict(string)
27. Name of the process of arranging array elements in a specified order is termed as
i)indexing ii)slicing iii)sorting iv) traversing
28. What type of value is returned by input() function by default?
i)int ii)float iii)string iv)list
29. Write the output of the following python code:
x = 123
for i in x:
print(i)
i)1 2 3 ii) 123 iii)infinite loop iv) error
30. write the ouput of following code
A = 10/2
B = 10.0//3
print(A,B)
i)5,3.3 ii) 5.0 , 3.3 iii) 5.0 , 3.0 3 iv) 5,4
31. Name the built-in mathematical function / method that is used to return square
root of a number.
i)SQRT() ii)sqrt() iii) sqt() iv) sqte()
32. i.print( (3-10**2+99/11))
ii. print( not 12 > 6 and 7 < 17 or not 12 < 4)
iii. print( 2 ** 3 ** 2)
iv. print(7//5+8*2/4-3)
v. print(not False and True or False and True)
33. Differentiate between break and continue statement used in python.
What is comment in python ? Explain its significance.
Explain the types of errors occurring in python programming language.
Differentiate between type conversion and type casting in python with examples.
Explain mutable and immutable objects in python with examples.
What is the use of else statement in for loop and in while loop ? Explain.
c. Dictionaries are also called mappings or hashes or associative arrays
34. State True or False
“break keyword skips remaining part of an iteration in a loop and compiler goes
to starting of the loop and executes again”
35. Which of the following are random number generators ?
(a) randint() (b) randrange() (c) random() (d) All of these
36. Which of the following are sequence of character data?
(a) Lists (b) Tuples (c) Strings (d) Dictionaries
37. a = 1.0
b = 1.0
c=float(input("enter")) #c=1.0
print(a is b)
print(a is c)

38. a = 6
b = 5.5
sum = a+b
print(sum)
print(type (sum))
39. print(print("Biscope"))
40. in and not in are.......Operators. (a) Arithmetic (b) Membership (c) Logical (d)
Identity
41. which of the following operator cannot be used with string data type?
(a) + (b) in (c) * (d) /

42. num = 4 + float (7)/int (2.0)


print (“num =”, num)

43. num = 4 + float (7)//int (2.0)

print (“num =”, num)

44. mul=3

value=10

for i in range (1, 6, 1):

if (value % mul ==0):


print (value * mul)
else:
print (value + mul)

45. is and is not are Operators

46. What will the following code display?


name = “Neha”

type (name)

47. b = 1

for a in range(1, 10, 2):

b += a + 2

print(b)
48. Predict the output of the following program:
a=5
b = a = 15
c = (a <
15)
print (“a = ”, a)

print (“b = ”, b)

print (“c = ”, c)
49. for i in range (-5,-7,-1):
print (i + 1)
50. a, b = 10, 5
x, y = a + b, b -2
z=x–y
51. State True or False : “All elements in Python list must be of same data type

52. Which of the following statement is correct syntactically?

(a) print('hello',end='%',sep='#')

(b) print('hello',sep='#',end=’%’)

(c) Both (a) and (b)

(d) Neither (a) not (b)

53. What will be the output of the following code :


print(eval('150+300'))
(a) 450 (b) 150+300 (c) 150300 (d) 300
54. If a is (1, 2, 3) then what is the difference between a * 3 and (a, a, a) ?

55. import random

VALUE = random.randint (0,3)


SUBJECT=["PHY","CHEM","MATHS","COMP"];
for I in SUBJECT:
for J in range(1, VALUE):
print(I, end="")
print()

i) PHYPHY
CHEMCHEM
MATHSMATHS
COMPCOMP
ii) PHY
PHYCHEM
PHYCHEMMATHS
iii) PHY
CHEMCHEM
COMPCOMPCOMP
v) PHY
CHEM
MATHS
COMP
56. State True or False:
“The else part of a loop gets executed only when a break statement terminates it.”

57. Evaluate the following expression and identify the correct answer.
5-(2+3)*99/11+2**3**2

58. What possible outputs(s) are expected to be displayed on screen at the time of
execution of the program from the following code
import random
AR=[20,30,40,50,60,70];
FROM=random.randint(1,3)
TO=random.randint(2,4)
for K in range(FROM,TO+1):
print (AR[K],end="#")

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

59. Which of the following is not a valid python operator?


a) % b) in c) # d) **

60. Suppose t = (1, 2, 4, 3), which of the following is incorrect?


(a) print(t[3]) (b) t[3] = 45 (c) print(max(t)) (d) print(len(t))

61. What is the output of print( 0.1 + 0.2 == 0.3)?

62. State True or False: “In Python, the result of sorted() is always a tuple.”

63. What will be the output of the following statement?


print(73 and not 10!=10 or 17>4)

64. x="abcdef"
i="i"
while i in x:
print(i,end="")

65. What will be the output of the following statement?


t=(10,20,[30,40,100],60,70)
t[2][1]=100
print(t)
66. x=10
y=5
for i in range(x-y*2):
print("%",end="")
67.how many times loop will execute?
for i in range(-5,-7,-1):
print(i)
continue
68.how many times loop will execute?
for i in range(-5,-7):
print(i)
continue
69. predict the output:
print(int(7.6),"and"*2,sep='%',end="@")
x=1,
y=" "
print(type(x),bool(y),sep="$")
70. S="Swinging"

T=2

for i in S:
print(i,sep="$",end="@")
if (1,2):

print(T)
elif[]:
print(S)

x= range(10,5,-3)
for y in x:
print(y)

You might also like