PYTHON Interview Questions and Answers
Question - 71 : - How will you check in a string that all characters are in uppercase?
Answer - 71 : - isupper() − Returns true if string has at least one cased character and all cased characters are in uppercase and false otherwise.
Question - 72 : - How will you merge elements in a sequence?
Answer - 72 : - join(seq) − Merges (concatenates) the string representations of elements in sequence seq into a string, with separator string.
Question - 73 : - How will you get the length of the string?
Answer - 73 : - len(string) − Returns the length of the string.
Question - 74 : - How will you get a space-padded string with the original string left-justified to a total of width columns?
Answer - 74 : - ljust(width[, fillchar]) − Returns a space-padded string with the original string left-justified to a total of width columns.
Question - 75 : - How will you convert a string to all lowercase?
Answer - 75 : - lower() − Converts all uppercase letters in string to lowercase.
Question - 76 : - How will you remove all leading whitespace in string?
Answer - 76 : - lstrip() − Removes all leading whitespace in string.
Question - 77 : - How will you get the max alphabetical character from the string?
Answer - 77 : - max(str) − Returns the max alphabetical character from the string str.
Question - 78 : - How will you get the min alphabetical character from the string?
Answer - 78 : - min(str) − Returns the min alphabetical character from the string str.
Question - 79 : - How will you replaces all occurrences of old substring in string with new string?
Answer - 79 : - replace(old, new [, max]) − Replaces all occurrences of old in string with new or at most max occurrences if max given.
Question - 80 : - How will you remove all leading and trailing whitespace in string?
Answer - 80 : - strip([chars]) − Performs both lstrip() and rstrip() on string.