Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is for Python 3 Progamming... Write a function fctz that takes a string st

ID: 3903489 • Letter: T

Question

This is for Python 3 Progamming...
Write a function fctz that takes a string st as argument and return a new string built as follows: turn all lower case letters of st into upper case letters and reciprocally. The letters should appear in the same order than in st (same string message). To check if a letter in st at index i is upper case, use st[i].isupper()
The result on IDLE should be aBcDe
# print(ex2('AbCdE')) This is for Python 3 Progamming...
Write a function fctz that takes a string st as argument and return a new string built as follows: turn all lower case letters of st into upper case letters and reciprocally. The letters should appear in the same order than in st (same string message). To check if a letter in st at index i is upper case, use st[i].isupper()
The result on IDLE should be aBcDe
# print(ex2('AbCdE'))
Write a function fctz that takes a string st as argument and return a new string built as follows: turn all lower case letters of st into upper case letters and reciprocally. The letters should appear in the same order than in st (same string message). To check if a letter in st at index i is upper case, use st[i].isupper() Write a function fctz that takes a string st as argument and return a new string built as follows: turn all lower case letters of st into upper case letters and reciprocally. The letters should appear in the same order than in st (same string message). To check if a letter in st at index i is upper case, use st[i].isupper()
The result on IDLE should be aBcDe
# print(ex2('AbCdE')) The result on IDLE should be aBcDe
# print(ex2('AbCdE'))

Explanation / Answer

ScreenShot

-------------------------------------------

Program

#function to convert entered string's character cases
def fctz(st):
    #length of the string to loop through the string
    l=len(st)
    #Empty string for create a new string
    s=""
    #loop to get each characer of the string
    for i in range(0,l):
        #Check the character is upper case
        if st[i].islower():
            #then change into lowercase
            s+=(st[i].upper())
        else:
            #Otherwise change into uppercase
            s+=(st[i].lower())
    #return new string
    return s
          
#test part
#ask user to enter a string
str=input("Enter a string:")
#print the original string
print("Original string is:"+str)
#call conversion function string then display new string
print("New string is:"+(fctz(str)))

---------------------------------------------

Output:-

Enter a string:AbCdE
Original string is:AbCdE
New string is:aBcDe

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote