Computer Science
The statement: bval = str1 > str2 shall return …………… as the output if two strings str1 and str2 contains "Delhi" and "New Delhi".
- True
- Delhi
- New Delhi
- False
Python Data Handling
2 Likes
Answer
False
Reason — Python's lexicographical comparison compares strings character by character based on their ASCII values. In the case of "Delhi" and "New Delhi", the comparison stops at the first difference encountered, which is the comparison between 'D' and 'N'. Since 'N' has a greater ASCII value than 'D', the lexicographical comparison returns False.
Answered By
2 Likes
Related Questions
Which of the following statements are not correct?
(A) An element in a dictionary is a combination of key-value pair.
(B) A tuple is a mutable data type.
(C) We can repeat a key in a dictionary.
(D) clear() function is used to delete the dictionary.
- A, B, C
- B, C, D
- B, C, A
- A, B, C, D
Which of the following statements converts a tuple into a list ?
- len(string)
- list(tuple)
- tup(list)
- dict(string)
What will be the output generated by the following snippet?
a = [5,10,15,20,25] k = 1 i = a [1] + 1 j = a [2] + 1 m = a [k + 1] print (i, j , m)
- 11 15 16
- 11 16 15
- 11 15 15
- 16 11 15
The process of arranging the array elements in a specified order is termed as:
- Indexing
- Slicing
- Sorting
- Traversing