Question: I need help writing this python code. It needs to be in python. Thanks! # The swap () function accepts a String argument displays two

I need help writing this python code. It needs to be in python. Thanks!

# The swap () function accepts a String argument displays two (2) variation: # All occurences of its first character changed to '$', except for the first chracter itself # The String reversed, in alternating UPPER/lower case

#The code () function accepts a String argument and returns one (1) String. The co+ # Converts all characters in the String to UPPER case # Build an encoded version of the String provided by shifting each character (within the ASCII Table) by a value equal to the number of words (3 words=shift all characters by 3) # Return the encoded string

# The main () function accepts no arguments and performs the following tasks # Display a description of the program's fuctionality # Prompt the user for a String # Call the swap () function using the string as an argument # Call the code () function using the String as an argument and assigning the value returned as a variable # Displaying the value returned by the code() function

(this is the code from I got from another, but it does not work)I need help writing this python code. It needs to be in

#swap function def swap(string): c= string[0] #reverse a string reverse=". for i in string: reverse = it reverse index=0 #printing modified string for ele in string: if(index !=0): if(eler=c): print('$', end=""), else: print(ele, end=""), else: print(ele, end=""), index=index+1 print(" ") #reverseing the string with alternate upper and lower characters for ele in range(0, index): if(ele%2==0): print (reverse[ele). upper(), end="") else: print (reverse[ele). lower( ), end ="") #code modifier for string def code(string): words=0 index=0; #counting the number of words for ele in string: if(ele==''): words=words+1 index=index+1 words=words+1 converted=""; output=""; #adding the number of words and printing converted= string.upper(); for i in range(0, index): output = output + chr((ord(converted[i])+words ) %128) return output #the program for swap and code method functionality if _name__ == "__main__": print("The program takes user input and displays the variations of string"); string = input("Enter a String: "); swap(string) print(" ") print(code(string))

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!