Page 389 - Computer Science Class 11 Without Functions
P. 389
24. Name the method that works reverse of split() method in strings.
Ans. join() method.
25. What is a dictionary?
Ans. A Python dictionary is a collection of key-value pairs. The elements in a dictionary are indexed by keys which
must be unique.
26. What is the purpose of using update() method with dictionary?
Ans. The update() method modifies or updates the dictionary with the elements from another dictionary or from
another sequence of key-value pairs.
27. Name the built-in mathematical function/method that is used to return an absolute value of a number.
Ans. To yield an absolute value: abs()
28. Write any one difference between insert() and append() function.
Ans. insert() function adds elements at the specified index of list while append() function adds single element at the
end of the list.
29. What types of tokens are allowed in Python?
Ans. The types of tokens are as follows:
• Keywords
• Identifiers
• Literals
• Operators
• Delimiters
30. What will be the output on the execution of the following code segment?
str1 = 'This is Mohit\'s "CS" book'
print(len(str1))
Ans. 25
31. Differentiate between indexing and traversing a string.
Ans. Indexing: Accessing individual characters of the string by using the subscript or index value is called indexing.
The index specifies the character to be accessed in the string and is written in square brackets [].
Traversing: Accessing each character one after the other by iterating through the elements of a string using
either for or while loop.
32. Consider a string myStr comprising some whitespaces at the beginning of the string as follows:
myStr = " Python Program"
Write a statement to remove these whitespaces from the left.
Ans. The command is: str1.lstrip()
33. Can list used as keys in Python dictionaries? Justify your answer.
Ans. No, we cannot use lists as keys of dictionary because lists are mutable and keys in the dictionary are
immutable.
34. What is the similarity between strings and tuples?
Ans. Tuples are immutable like strings, i.e., once created, we cannot update their elements.
35. Can tuples be used as keys in Python dictionaries?
Ans. Yes, tuples can be used as keys in Python dictionaries as keys of dictionary cannot be modified and tuples are
immutable by default and hence can be used.
36. What is an Exception?
Ans. Exceptions are erroneous events that arise during the execution of a program, causing a deviation from the
normal flow of code.
Viva Voce Questions 387

