Revision Tour
Revision Tour
Fillinthe mising lines of eode in the follewing tode Thecode 1etlsin a hnmit anunt
prices and prints the larget price that is lessthan the limit You tan 6Un thatalprias
are positive humbers. Wlhen a price 0 is eitered the progiatiterBals and prlits the iae
is less than the limit.
vgest phes
#Read the limit
limit float (input ("Inter the 1imit"))
max price 0
#Read the next price
next price =float (input ("Enter a price or 9 to stop")
XX 1 print(", 1)
y y+1
() C
(c) keepgoing= True for x in range(10):
X= 100 for y in range
while keepgoing:
(5):
C4 1
print(x) print(c)
X=X 10
ifx < 50:
) X=[1,2,3]
COunter = 0
keepgoing = False
while counter < len (x):
(d) X= 45
print(x[counter] *)
while x < 50: for y in x
print(x) print(y *'% ')
for
Name in ['Jayes, 'Ramya', Taruna, 'Suraj']
print (Name)
i fName[ej == 'T':
break
else:
print ('Finished!)
print ("Got it!')
4. How many times will the following for loop execute and what's the output ?
n=5
whilen <10:
n-1
n=2#n-m
print (n, m)
>>>str[:2]
(a) he (b) lo (c) olleh (d) hello
5. What data type is the object below ?
L =
[1, 23, 'hello', 1]
(a) list (b) dictionary (c) array (d) tuple
6. What data type is the object below?
L= 1, 23, 'hello', 1
(a) list (b) dictionary (c) array (d) tuple
7. To store values in terms of key and value, what core data type does Python provide ?
(a) list (b) tuple (c) class (d) dictionary
8. What is the value of the following expression ?
3+3.00, 3**3.0
(a) (6.0, 27.0) (6) (6.0, 9.00) () (6, 27)
(d) [6.0, 27.0] (e) [6, 27]
9. List AL is defined as follows:
AL [1, 2, 3, 4, 51
Which of the following statements removes the middle element 3 from it so that the ist qua
[1, 2, 4, 5]?
(a) del a[2 (6)a[2:3][ C) a[2:2]= []
(4) al2] - [
(e)a.remove(3)
Thopt 2 THON EPSO OUR
79
Ths is a strg
This is a strin
3 ovu haswe the taillowing
qude segment
Sturimgl= "my
Strmg2="wOr
prait St1rimgl Stirimg2)
What is the quruit oi thiS COde ?
work (mywork )my
12 o tEve the
iliomE COde segmemit
SUreng="my
Strimgz="wCrk
rimtStrimgl +String2.upper(0))
What is the autgutt of his cnde ?
MY WNork (c)my
WORK d) My Work
13. Wich lime of de podaces am emor?
()1-2 ()one+"2" (d)1+2
4What is the outgut ot his code ?
(c)34 ()24
5wWhich line of code will ause an emor ?
mum= 5, 4, 3, [2], 1]
primt(mum @])
3. primt(mum[3][@])
prämt(mum 5])
(a)Line 3 )Line 2 (c)Line 4 (4)Line 1
h. Which is the omect tom af decdaraion ot dictionary ?
A ist
may contain any
type of objects except another
list.
here is mo coniceptual mit to the
size of a list.
Al eiements in a ist
must be of the same type.
Agwen object may appear na ist
The keys of a
more than once.
dictionary must be of immutable types.
You can
comibine
numeric value and a
a
A list of
cdharacters is sinmilar to
11
(a, b, c, d) =
ntpl
print("a is:", a)
print("b is:", b)
print("c is:", c)
print ("d is : ", d)
ntpl= (a, b, c, d)
print(ntpl[0][e]+ntpl[1][1], ntpl[1])
following code ?
8. What will be the output of the
tuple_a 'a', 'b'
tuple_b=('a', 'b')
print (tuple_a tuple_b) ==
code snippet ?
10. What will be the output of the following
my_dict = {}
my_dict[ (1,2,4) ] = 8
my_dict[ (4,2,1)] = 10
my_dict[(1,2)] = 12
sum 0
for k in my_dict:
sum += my_dict [k]
print (s um)
print (my_dict)
11. Write a method in python to display the elements of list thrice if it is a number and display the element
terminated with # if it is not a number. ICBSE D 2015]
For example, if the content of list is as follows
List =
['41', 'DROND , GIRIRAJ', '13, ZARA']
The output should be
414141
DROND#
GIRIRAJ#
131313
ZARA#