DS301222 PYTHON questions 21/2/23

1)What will be the output:

li=[1,2,3,4]
tup=(1,2,3,4,li)
li.append(6)
print(li)
print(tup)

ans [1, 2, 3, 4, 6]
(1, 2, 3, 4, [1, 2, 3, 4, 6])

2)What is a correct syntax to return the first character in a string?

x=“Hello”.sub(0,1)
x=sub(“Hello”,0,1)
x=“Hello”[0]

ans x=“Hello”[0]

which method can be used to return a string in upper case letters?

toUpperCase()
upperCase()
upper()
uppercase()

ans upper()

Which collection is ordered , provide changes

1)list
2)set
3)dict
4)tuple

ans set is ordered

#Which statement is used to stop a loop
1)break
2)continue
3)stop
4)pause

ans break

2 Likes

All answers are correct except 4 in this all collections which provide changes are list,set,dict
@kinnukeshiya

1 Like