Ethan H.

asked • 03/09/21

Reading questions

Readings: Python_by_Lambert

Chapter 4, Section 4.1 Substrings 


  1. Assume that the variable data refers to the string “myprogram.exe”

     Write the values of the following expressions:

  1. data[2]
  2. data[-1]
  3. len(data)
  4. data[0:8]
  5. “gram” in data and “pro” in data
  6. Assume that the variable data refers to the string “myprogram.exe”.

     Write the expressions that perform the following tasks:

  1. Extract the substring “gram” from data.
  2. Truncate the extension “.exe” from data.
  3. Extract the character at the middle position from data.
  4. Assume that the variable myString refers to a string. Write a code segment

      that uses a loop to print the characters of the string in reverse order.

  1. Assume that the variable myString refers to a string and the variable

      reversedString refers to an empty string. Write a loop that adds the

     characters from myString to reversedString in reverse order.


1 Expert Answer

By:

Andrea M. answered • 03/09/21

Tutor
5 (47)

Data Analyst with 10+ Years of SQL Experience

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.