Use the Pythone programming language. see the #bold hashtags in the code for instructions. Also use the website provided for an idea on how the code should be approached. please provide the code along with a screen shot of the code working with the outcome.
s1 = str("abc text xyz")
print("String s1 =", s1)
print("First letter of s1 = ", s1[0])
print("length of s1= ", len(s1))#len for length
length = len(s1)
last = s1[length-1]
print("Last letter = ", last)
print("First four letters:", s1[4:8])
# copy the content of one string to another
s2 = s1.upper()
print("length of s2 =", len(s2))
print("String s2 =", s2)
# Copy the letters form s1 into s2 in the reverse
order
# output = zyx txet cba
#
https://www.w3schools.com/python/python_howto_reverse_string.asp
s2 = s1[::-1]
# the a reverse count
print("[reverse s1] String s2 =", s2)
i = 0
aList = ['a']*len(s1)
while i < len(s1):
aList[i] = s1[len(s1)-1-i]
i = i + 1
print("String s1 =", s1)
print("aList =", aList)
In python, we have a feature called slicing.
s1=str("abc text xyz") #input the sentence
s2=s1[::-1] #copying the sentence and applying slicing
print(s2) #print the reverse
Below is the screenshot of the code and the output
Get Answers For Free
Most questions answered within 1 hours.