String Data and Methods

  1. Storing String

    Question 1 of 5

    • Create a variable that stores your name and display it.
    • Store text I'm learning Python in a variable and display it.
    • Store text Ram said, "I've a pen." in a variable and display it.
    • Store below text in a variable (as multiline) and display it. Dear Manager, I am on leave! Thanks
    • Store \n and \t are special character. We use \ to escape in a variable and display it.
  2. Indexing and Slicing

    Question 2 of 5

      Create a variable my_str that stores We are learning Python and it's fun! and
      1. Find and display the first character.
      2. Find and display the character at index 8.
      3. Find and display the last character (using negative indexing).
      4. Find word Python using slicing and display it.
      5. Find word fun using negative slicing and display it.
      6. Find text lrn (i.e. only some part of text learning) and display it.
      7. Reverse the string and display it.
      8. Find sub-string that lies from 5th index till end and display it.
      9. Find sub-string that lies from start till 10th index and display it.
  3. Generic functions

    Question 3 of 5

      Create a variable str_1 that stores Hello, str_2 that stores World and:
      1. Display HelloWorld by concatenating both strings.
      2. Assign greetings variable as Hello World by concatenating both strings and display it.
      3. Assign my_str as HelloHelloHello using str_1 repetition.
      4. Find and display number of characters in string my_str.
      5. Change value of greetings variable to uppercase and display it.
      6. Change value of greetings variable to lowercase and display it.
      7. Change value of greetings variable to title case and display it.
      8. Swap the case of characters in greetings variable and display it.
  4. Data Check Functions

    Question 4 of 5

      Assign str_1 as "Hello", str_2 as "134", str_3 as "##abc123##" and str_4 as " "
      1. Check and display if str_1 has alphabetic characters only.
      2. Check and display if str_1 has numeric characters only.
      3. Check and display if str_2 has alphanumeric characters only.
      4. Check and display if str_4 is empty.
      5. Check and display if str_3 starts with abc
      6. Check and display if str_3 ends with 3
      7. Check and display if str_1 starts with He and ends with lo
      8. Remove leading and trailing # from str_3 and display the result
      9. Remove leading # from str_3 and display the result
  5. Data Manipulation & Cleanup

    Question 5 of 5

    • Assign file_name as report_2026.pdf. Split and display file name and extension.
    • Store my_date as 2026-03-05. Split it into list of year, month, day and display result
    • Store my_str as PYTHON. Use join function to display P.Y.T.H.O.N
    • Store laptop_names as ['Dell', 'HP', 'Mac']. Use join function to display Dell-HP-Mac
    • Assign str_1 as Hello, World!. Replace World with Python and display the result.
    • Assign str_2 as 2026-03-01.csv. Replace - with / and display the result.
    • Assign str_3 as Pineapple. Find at which index apple starts and display the result.
    • Assign my_name as your name. Count the number of vowels in it and display the result.
    • Assign my_str as Hello, World!. Count and display occurrence of letter l in it.