61. What is the output of print('Python'[1])?
- a) y
- b) P
- c) t
- d) h
Test your knowledge of Python with these interactive multiple-choice questions.
61. What is the output of print('Python'[1])?
62. Which method converts a string to title case?
'hello world'.title() returns 'Hello World'.
63. What does the join() method do?
'-'.join(['a','b']) returns 'a-b'.
64. Which operator checks if a value is in a sequence?
'a' in ['a','b'] returns True.
65. What is the output of print(bool('False'))?
66. Which method removes the first occurrence of a value in a list?
my_list.remove(value) removes the first matching item.
67. What is the output of print('Python'.find('z'))?
find() returns -1 when substring isn't found.
68. Which function returns the length of an object?
len('Python') returns 6.
69. What is the output of print('Python'.startswith('Py'))?
70. Which method returns a list of dictionary values?
my_dict.values() returns a view of all values.
71. What does the all() function do?
all([True, 1, 'a']) returns True.
72. Which Python data type is mutable and unordered?
{1, 2, 3}.
73. What is the output of print(bool(0))?
74. Which function returns the sum of all items in an iterable?
sum([1,2,3]) returns 6.
75. What does sorted() function do?
sorted() returns a new list without modifying the original.
76. Which module is used for working with regular expressions?
re module provides regex support.
77. What is the output of print('Python'.isalpha())?
78. Which method removes whitespace from the left end of a string?
' hello '.lstrip() returns 'hello '.
79. What is the output of print('Python'.replace('P', 'J'))?
80. Which function returns a list of tuples containing keys and values?
my_dict.items() returns key-value pairs.