What is the output of the following program:
print ("Hello World"[::-1])
dlroW olleH
Hello Worl
D
error
What will be the output of the following code snippet?
a=[1,2,3,4,5,6,7,8,9] a[::2]=10,20,30,40,50,60 print(a)
ValueError: attempt to assign sequence of size 6 to extended slice of size 5
[10, 2, 20, 4, 30, 6, 40, 8, 50, 60]
[1, 2, 10, 20, 30, 40, 50, 60]
[1, 10, 3, 20, 5, 30, 7, 40, 9, 50, 60]
What is the correct command to shuffle the following list?
fruit=['apple', 'banana', 'papaya', 'cherry']
fruit.shuffle()
shuffle(fruit)
random.shuffle(fruit)
random.shuffleList(fruit)
Tuples have structure; lists have an order
Tuples are homogeneous, lists are heterogeneous.
Tuples are immutable, lists are mutable.
All of them
What is the output of the following code:
L=['a','b','c','d'] print ( "".join(L))
Error
None
abcd
[‘a’,’b’,’c’,’d’]
. List is mutable & Tuple is immutable
List is immutable & Tuple is mutable
Both are mutable
Both are immutable
Sequence value pair
Key value pair
Tuple value pair
Record value pair
Removes all spaces from the string.
Removes the first and last character of the string.
Removes whitespace from the beginning and end of the string.
Converts the string into a list of characters.
startswith()
startswith_prefix()
startswithwith()
startswiths()
19
18
17
Strings can be modified using indexing.
Strings are immutable.
Strings can only contain alphabetic characters.
Strings must end with a newline character.
capitalize()
pop()
find()
insert()
append()
extend()
add()
It returns None.
It raises an IndexError
It creates a new element at that index.
It returns an empty list.
empty_tuple = ()
empty_tuple = tuple()
empty_tuple = []
Both A and B
t1=1,2,4
t1=(1,)
t1=tuple(“123”)
All of these
(1)
(1,)
[1]
{1}
index()
remove()
('abc’)
('a', 'b', 'c’)
['a', 'b', 'c’]
count()
len()