NEW
Font size
WorksheetsPython Quiz
Total questions: 10
Worksheet time: 20mins
what is the output of print str * 2 if str = 'Hello World!'?
Hello World!Hello World!
Hello World! * 2
Hello World!
None of the above
what is the result of the following operation in Python:
3+ 2 * 2
10
12
9
7
If you executed name = 'Lizz' , what would be the output of print (name[0:2])?
Li
Zz
Lizz
L
If you executed var = '01234567' , what would be the result of print(var[::2])?
0246
01234
1234
7531
what is the result of the following operation '1'+'2'
3
1
2
12
Given myvar = 'hello', how would you convert myvar into uppercase?
len(myvar)
upper(myvar)
myvar.upper()
myvar.upper(myvar)
which of the following are valid ways to specify the string literal foo'bar in Python:
"""foo'bar"""
'foo\'bar'
foo'bar
foo"bar
What is the syntax to obtain the first element of the tuple:
A=('a','b','c')
A[‘1’]
A[1]
A[2]
A[0]
After applying the following method, L.append(['a','b']), the following list will only be one element longer.
True
Flase
what signifies the ends of a statement block or suite in Python?
A line that is indented less than previous line
A comment
End
}
