Strings mcq questions

  1. What does the input() function do in Python? a) It prints text to the console. b) It returns user input as a string. c) It splits a string into substrings. d) It converts a string to uppercase.
  2. Which of the following is used to split a string into a list of substrings in Python? a) concat() b) substring() c) split() d) join()
  3. Which built-in function is used to find the position of a substring within a string in Python? a) locate() b) find() c) search() d) position()
  4. What does the replace() function do for strings in Python? a) It removes all whitespace characters from the string. b) It replaces all occurrences of one substring with another. c) It counts the number of occurrences of a substring. d) It converts the string to lowercase.
  5. Which of the following string functions is used to convert a string to uppercase in Python? a) to_upper() b) upper() c) uppercase() d) convert_upper()
  6. What does the count() function do for strings in Python? a) It returns the number of occurrences of a substring in the string. b) It counts the total characters in a string. c) It counts the number of vowels in a string. d) It returns the length of the string.
  7. Which string function can be used to check if all characters in a string are lowercase? a) islower() b) tolower() c) check_lower() d) is_lowercase()
  8. What does the title() function do for strings in Python? a) It converts the first character of each word to lowercase. b) It capitalizes the first character of each word. c) It removes all spaces from the string. d) It converts the string to uppercase.
  9. Which function is used to join a list of strings into a single string in Python? a) merge() b) join() c) concatenate() d) combine()
  10. What is the purpose of the istitle() function for strings in Python? a) It checks if the string is a title of a book. b) It converts the string to title case. c) It checks if the first character of each word is capitalized. d) It checks if the string is entirely in uppercase.
  1. b
  2. c
  3. b
  4. b
  5. b
  6. b
  7. a
  8. b
  9. b
  10. c
1 Like