NEW
Font size
WorksheetsPython Revision Tour - I
Total questions: 15
Worksheet time: 5mins
Given the lists L=[1,3,6,82,5,7,11,92] , write the output of print(L[2:5])
[6,82,5,7]
[1,3,6,82,5]
[6,82,5]
None of these
Suppose a tuple T is declared as T = (10, 12, 43, 39), which of the following is incorrect?
print(T[1])
T[2] = -29
print(max(T))
print(len(T))
A tuple is declared as
T = (2,5,6,9,8)
What will be the value of sum(T)?
30
0
Error
29
If the following code is executed, what will be the output of the following code?
name="ComputerSciencewithPython"
print(name[3:10])
puterSci
puterSc
mputerSc
none
The statement: bval=str1>str2 shall return __________________ as the output, if str1="Delhi" and str2="New Delhi".
True
Delhi
New Delhi
False
Which of the following statements returns a list?
tup(list)
len(tup)
list(string)
dict(string)
What is the output?
a=[5,10,15,20,25]
k=1
i=a[1]+1
j=a[2]+1
m=a[k+1]
print(i,j,m)
11 15 16
11 16 15
11 15 15
16 11 15
Which of the function is used to iterate over a sequence of numbers by specifying a numeric end value within its parameters?
range()
len()
substring()
random()
what is the output?
d={0:'a',1:'b',2:'c'}
for i in d:
print(i)
0
1
2
a
b
c
0
a
1
b
2
c
2
a
2
b
2
c
what is the output?
x=123
for i in x:
print(i)
1 2 3
123
error
infinite loop
suppose list1=[0.5* x for x in range(0,4)], list 1 is:
[0,1,2,3]
[0,1,2,3,4]
[0.0,0.5, 1.0, 1.5]
[0.0,0.5, 1.0, 1.5, 2.0]
T=('A',('B','C',('d','E'),'F'),'G','H')
What is the length of the above tuple?
8
7
6
4
T=('a','b','c')
Write the statement to unpack the values of the above Tuple with three different variables in a single statement.
T=a,b,c
print(a,b,c)
a b c =T
print(a,b,c)
a,b,c=T
print(a,b,c)
a=T
print(a)
T=(2,5,6,9,8)
Which is the correct statement to print the tuple in ascending order using built in function?
print(sort(T))
print(sorted(T))
print(sort(T) ascending)
Not possible
val=1,2,3,4,5
What will be the type of the variable 'val'?
<Tuple>
<List>
<int>
None of these
