and Answers
In Python, if you executed name = 'Lizz', what would be the output of print(name[0:2])? -
Answer-Li
In Python, if you executed var = '01234567', what would be the result of print(var[::2])? -
Answer-0246
In Python, what is the result of the following operation '1'+'2' - Answer-'12'
Given myvar = 'hello', how would you convert myvar into uppercase? - Answer-
myvar.upper()
What is the syntax to obtain the first element of the tuple:
A=('a','b','c') - Answer-A[0]
After applying the following method,L.append(['a','b']), the following list will only be one
element longer. - Answer-True
How many duplicate elements can you have in a set? - Answer-0, you can only have
one unique element in a set
Consider the following Python Dictionary:
Dict={"A":1,"B":"2","C":[3,3,3],"D":(4,4,4),'E':5,'F':6}
, what is the result of the following operation: Dict["D"] - Answer-(4, 4, 4)
What is an important difference between lists and tuples? - Answer-Lists are mutable
tuples are not
What is the output of the following lines of code:
x=1
if(x!=1):
print('Hello')
else: