0% found this document useful (0 votes)
13 views9 pages

Revision Test 1

The document is a revision test for Python programming at AKR Academy School (CBSE). It includes a series of questions covering various topics such as data types, literals, error handling, loops, lists, tuples, dictionaries, and syntax corrections. The test requires students to provide answers, write code snippets, and explain concepts related to Python programming.

Uploaded by

Shibhi Siddarth
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views9 pages

Revision Test 1

The document is a revision test for Python programming at AKR Academy School (CBSE). It includes a series of questions covering various topics such as data types, literals, error handling, loops, lists, tuples, dictionaries, and syntax corrections. The test requires students to provide answers, write code snippets, and explain concepts related to Python programming.

Uploaded by

Shibhi Siddarth
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

AKR ACADEMY SCHOOL (CBSE)

REVISION TEST-1
PYTHON – REVISION TOUR-1
1 “Welcome‟ is literals
Ans.
2 $ symbol can be used in naming an identifier (True/False)
Ans.
3 Write any 2 data types available in Python
Ans.
4 “Division by zero‟ is an example of error.
Ans.
5 range(1,10) will return values in the range of to
Ans.
6 randint(1,10) will return values in the range of to
Ans.
“Computer Science”[0:6] =
7 “Computer Science”[3:10] =
“Computer Science”[::-1] =
“Computer Science”[-8:]=
“Computer Science”[0:6] =
“Computer Science”[3:10] =
Ans.
“Computer Science”[::-1] =
“Computer Science”[-8:] =
8 Output of : print(“Ok”*4 + “Done”)
Ans.
9 Output of : print(print(“Why?”))

Ans.
Raj was working on application where he wanted to divide the two
number (A and B) , he has written the expression as C = A/B, on
execution he entered 30 and 7 and expected answer was 4 i.e. only
10 integer part not in decimal, but the answer was 4.285 approx, help
Raj to correct his expression and achieving the desired output.
Correct Expression :

Ans.
Can you guess the output?
C = -11%4
11
print(C)

Ans.

Page :1
12 Write 2 advantages and disadvantages of Python programming language

Ans.

13 Identify the valid and Invalid identifiers names:


Emp-Code, _bonus, While, SrNo. , for, #count, Emp1, 123Go, Bond007
Valid: _
Ans.
Invalid :
Identify the type of literals for each:
(i) 123
(ii) „Hello‟
14 (iii) „Bye\nSee You‟
(iv) „A‟
(v) 345.55
(vi) 10+4j
(vii) 0x12

Ans.

What is the size of each string?


(i) „Python‟
15
(ii) „Learning@\nCS‟
(iii) „\table‟

Ans.

Output of :
(i) True + True =
16 (ii) 100 + False =
(iii) -1 + True =
(iv) bool(-1 + True) =

Ans.

Output of
(i) 2 * 7 =
(ii) 2 ** 7 =
17 (iii) 2**2**3 =
(iv) 17 % 20 =
(v) not(20>6) or (19>7) and (20==20) =

Ans.

Page :2
Output of :
a,b,c = 20,40,60
18 b+=10
c+=b
print(a,b,c)
Ans.
19 Write a program to enter 2 number and find sum and product

Ans.

Consider a list:
MyFamily = [“Father”,”Mother”,”Brother”,”Sister”,”Jacky”]

a) write statement to print “Brother”


20 b) write statement to print all items of list in reverse order
c) write statement to check “Sister” is in MyFamily or not
d) write statement to update “Jacky” with “Tiger”
e) write statement remove “Jacky” from MyFamily and also print it
f) write statement to add “Tommy” in MyFamily at the end

Ans.

Consider a Tuple:
Record = (10,20,30,40)
Raj wants to add new item 50 to tuple, and he has written
21 expression as
Record = Record + 50, but the statement is giving an error, Help
Raj in writing correct expression.
Correct Expression :
Ans.
22 What is the difference between List and Tuple?
Ans.
23 What is the difference between List and String?

Ans.

Consider a Dictionary
24
Employee = {„Empno‟:1,‟Name‟:‟Snehil‟,‟Salary‟:80000}

Page :3
Write statements:
(i) to print employee name
(ii) to update the salary from 80000 to 90000
(iii) to get all the values only from the dictionary

Ans.

Num = 100
Isok = False
25 print(type(Num)) =
print(type(Isok)) =

Ans.
Name the Python Library module which need to be imported to invoke
the following function:
26 a) floor()
b) randrange()
c) randint()
d) sin()

Ans.

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)
27
IF k%4==0:
print (K*4)
Else:
print (K+3)

Ans.

Rewrite the following code in python after removing all syntax


error(s). Underline each correction done in the code:
a=5
work=true
b=hello
c=a+b
28
FOR i in range(10)
if i%7=0:
continue

Ans.

Page :4
Rewrite the following code in python after removing all syntax
error(s). Underline each correction done in the code:
29
for Name in [Ramesh,Suraj,Priya]
IF Name[0]='S':
print(Name)

Ans.

Rewrite the following code in python after removing all syntax


error(s). Underline each correction done in the code:
a=b=10
30 c=a+b
While c=<20:
print(c,END="*")
c+=10

Ans.

Choose the correct possible answer(s)


a = random.randint(1,5)
b = random.randint(1,3)
31
c = random.randint(2,6)
print(a,b,c)
(i) 2 1 3 (ii) 4 4 4 (iii) 3 2 1 (iv) 5 3 5
Ans.
What is type conversion in Python? What are different types of
32
conversion? Illustrate with example.

Ans.

Fill in the blanks to execute infinite loop:


33 while :
print(“spinning”)

Page :5
Ans.
Write a program to enter any number and check it is divisible by 7
34
or not

Ans.

Fill in the blanks to execute loop from 10 to 100 and 10 to 1


(i)
for i in range( ):
print(i)
35
(ii)
for i in range( ):
print(i)

Ans.

What will be the output if entered number (n) is 10 and 11


i=2
while i<n:
if num % i==0:
break
36
print(i)
i=i+1
else:
print("done")

Ans.

What will be the difference in output


(i)
for i in range(1,10):
if i % 4 == 0:
break
print(i)
37

(ii)

for i in range(1,10):
if i % 4 == 0:

Page :6
continue
print(i)

Ans.

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];
38 FROM=random.randint(1,3)
TO=random.randint(2,4)
for K in range(FROM,TO+1):
print (AR[K],end=”#“)
(i) 10#40#70# (ii) 30#40#50#
(iii) 50#60#70# (iv) 40#50#70#

Ans.

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 minimum and maximum value that can be assigned to the
variable PICKER.
import random
PICKER=random.randint(0,3)
COLORS=["BLUE","PINK","GREEN","RED"]
for I in COLORS:
for J in range(1,PICKER):
39 print(I,end="")
print()
(i) (ii)
BLUE BLUE
PINK BLUEPINK
GREEN BLUEPINKGREEN
RED BLUEPINKGREENRED
(iii) (iv)
PINK BLUEBLUE
PINKGREEN PINKPINK
PINKGREENRED GREENGREEN
REDRED

Ans.

40 What are the correct ways to generate numbers from 0 to 20

Page :7
range(20) (ii) range(0,21) (iii) range(21) (iv) range(0,20)

Ans.
Which is the correct form of declaration of dictionary?
(i) Day={1:‟monday‟,2:‟tuesday‟,3:‟wednesday‟}
41 (ii) Day=(1;‟monday‟,2;‟tuesday‟,3;‟wednesday‟)
(iii) Day=[1:‟monday‟,2:‟tuesday‟,3:‟wednesday‟]
(iv) Day={1‟monday‟,2‟tuesday‟,3‟wednesday‟]
Ans.
Choose the correct declaration from the following code:
42 Info = ({„roll‟:[1,2,3],‟name‟:[„amit‟,‟sumit‟,‟rohit‟]})
List (ii) Dictionary (iii) String (iv) Tuple
Ans.
Which is the valid dictionary declaration?
i) d1={1:'January',2='February',3:'March'}
43 ii) d2=(1:'January',2:'February',3:'March'}
iii) d3={1:'January',2:'February',3:'March'}
iv) d4={1:January,2:February,3:March}
Ans.
What is/are not true about Python‟s Dictionary?
(i) Dictionaries are mutable
44 (ii) Dictionary items can be accessed by their index position
(iii) No two keys of dictionary can be same
(iv) Dictionary keys must be of String data type
Ans.
x="abAbcAba"
for w in x:
if w=="a":
45 print("*")
else:
print(w)

Ans.

Convert the following „for‟ loop using „while‟ loop


46 for k in range (10,20,5):
print(k)

Ans.

Give Output
47 colors=["violet", "indigo", "blue", "green", "yellow", "orange", "red"]
del colors[4]

Page :8
colors.remove("blue")
p=colors.pop(3)
print(p, colors)
Ans.
Output of following code:
A=10
B=15
S=0
while A<=B:
48 S = A + B
A = A + 10
B = B + 10
if A>=40:
A = A + 100
print(S)
Ans.
Output of the following code:
X = 17
if X>=17:
49 X+=10
else:
X-=10
print(X)
Ans.
How many times loop will execute:
P=5
50 Q=35
while P<=Q:
P+=6
Ans.
Find and write the output of the following python code:
Msg="CompuTer"
Msg1=''
for i in range(0, len(Msg)):
if Msg[i].isupper():
51 Msg1=Msg1+Msg[i].lower()
elif i%2==0:
Msg1=Msg1+'*'
else:
Msg1=Msg1+Msg[i].upper()
print(Msg1)
Ans.
A=10
B=10
52 print( A == B) = ?
print(id(A) == id(B) = ?
print(A is B) = ?

Ans.

Page :9

You might also like