NEW
Font size
WorksheetsPython strings and lists
Total questions: 12
Worksheet time: 8mins
Which of the operator can be used in Strings?
+
*
Both of the above
None of the above
When we create a program to extract each alphabet from a given string, what is it known as?
Transpose
Traverse
Translate
Terminate
Which method is used to convert a given string in Capital letters?
Capital
Upper
ConverttoUpper
Capitalize
Which of the following is not a valid string function?
isalphanumeric
isspace
islower
isalnum
s1="Hello"
n1=10
print(s1+n1)
What is the error in this code?
Print statement not written in quotes
Numeric value not written in quotes
colon not written after the print statement
string cannot be added to a number
Which brackets are used for Lists?
( )
[ ]
{ }
None of the above
[1, 2, 8, 9] < [9, 1]
What will be the result if we compare these two lists?
True
False
[1, 2, 8, 9] < [1, 2, 8, 4]
What will be the result if we compare these two lists?
True
False
Suppose you have the following tuple definition:
t = ('foo', 'bar', 'baz')
Which of the following statements replaces the second element ('bar') with the string 'qux':
t[1] = 'qux'
t(1) = 'qux'
t[1:1] = 'qux'
It’s a trick question—tuples can’t be modified.
If list1=[10,20,30,40,50]
then list1[2]=35 will result in:
[35,10,20,30,40,50]
[10,20,30,40,50,35]
[10,20,35,40,50]
[10,35,30,40,50]
If list1=[17,23,41,10]
then list1.append(32) will result in:
[32,17,23,41,10]
[17,23,41,10,32]
[10,17,23,32,41]
[41,32,23,17,10]
Can lists contain tuples and vice versa?
Yes
No
