Share Your Feedback

Learn Python String Methods & Formatting with True or False

Test your Python skills with True or False questions on string methods and formatting. Great for beginners learning Python strings through hands-on practice.

๐Ÿ” True or False

๐ŸŸข Beginner

  1. You can use both single (' ') and double (" ") quotes to define a string in Python.
  2. Answer

    โœ… True โ€“ Python allows strings to be defined using either single or double quotes.


  3. The len() function is used to determine the length of a string.
  4. Answer

    โœ… True โ€“ The built-in len() function returns the number of characters in a string.


  5. The upper() method changes all the characters in a string to lowercase.
  6. Answer

    โŒ False โ€“ The upper() method converts all characters in a string to uppercase.


  7. You can concatenate strings using the + operator in Python.
  8. Answer

    โœ… True โ€“ The + operator is used to join or concatenate two or more strings.


  9. The strip() method removes characters from the middle of a string.
  10. Answer

    โŒ False โ€“ The strip() method removes leading and trailing whitespace from a string.


  11. String indexing in Python starts from 1.
  12. Answer

    โŒ False โ€“ Python uses zero-based indexing, so the first character of a string is at index 0.


  13. The replace() method can be used to change specific parts of a string.
  14. Answer

    โœ… True โ€“ The replace() method returns a new string with all occurrences of a substring replaced.


  15. You cannot loop through a string using a for loop.
  16. Answer

    โŒ False โ€“ Strings are iterable in Python, so you can loop through them character by character.


  17. The in keyword checks whether a substring exists in a string.
  18. Answer

    โœ… True โ€“ The in keyword returns True if the specified substring is found in the string.


  19. Strings in Python support slicing.
  20. Answer

    โœ… True โ€“ Python allows slicing of strings using the syntax string[start:stop:step].


  21. Triple quotes are used for multi-line strings in Python.
  22. Answer

    โœ… True โ€“ Triple single (''') or double quotes (""") can define multi-line strings.


  23. The find() method returns -1 if the substring is not found.
  24. Answer

    โœ… True โ€“ The find() method returns the lowest index of the substring, or -1 if not found.


  25. Python allows escape characters like \n for new lines and \t for tabs.
  26. Answer

    โœ… True โ€“ Python uses backslash (\) escape sequences such as \n for newline and \t for tab.


  27. You can change a specific character in a string using indexing.
  28. Answer

    โŒ False โ€“ Strings are immutable in Python, so you cannot change characters via indexing.


๐ŸŸก Intermediate

  1. Strings in Python are mutable.
  2. Answer

    โŒ False โ€“ Strings in Python are immutable, meaning their content cannot be changed after creation.


๐Ÿ”ด Advanced

๐Ÿ“š Related Resources


๐Ÿง  Practice & Progress

Explore More Topics

๐Ÿฃ Python for Beginners

๐Ÿง  Python Advanced