Strings: Indexing, slicing, split(), strip(), find(), replace(), formatting using f-strings

  1. Write a Python program to extract characters from index 2 to index 6 using string slicing ?
  2. Write a Python program to count how many vowels are present at even index positions using indexing ?
  3. Write a Python program to access and display the first and last characters of a string using string indexing ?
  4. Write a Python program to extract a substring from a given string using string slicing ?
  5. Write a Python program to split a sentence into individual words using the split() method ?
  6. Write a Python program to remove leading and trailing spaces from a string using the strip() method ?
  7. Write a Python program to find the position of a word in a string using the find() method ?
  8. Write a Python program to replace a word in a string using the replace() method ?
  9. Write a Python program to display student information using f-string formatting ?
  10. Write a Python program to reverse a string using slicing ?
  11. Write a Python program to extract the domain name from an email address using string slicing and find() ?
  12. Write a Python program to count the number of words in a sentence using split() ?
  13. Write a Python program to mask a mobile number except for the last four digits using string slicing ?
  14. Write a Python program to convert a comma-separated string into a list and display each item separately ?
  15. Write a Python program to generate a formatted employee ID card using f-strings ?
  16. Write a Python program to remove multiple unwanted characters (#, @, *) from both ends of a string using strip() ?
  17. Write a Python program to replace multiple spaces in a sentence with a single space using string methods ?
  18. Write a Python program to generate a username from a full name by extracting initials and formatting them using string methods ?
  19. Write a Python program to check whether the first three characters and last three characters of a string are the same using slicing ?
  20. Write a Python program to replace underscores (_) in a username with spaces using the replace() method.
Previous Topic Functions (def, return, scope, positional arguments, default arguments, keyword arguments) Next Topic Lists: Creation, indexing, slicing, methods (append(), pop(), sort()), intro to list comprehension