1) WAP IN PYTHON TO CHECK WHETHER THE STRING IS SYMMETRICAL OR PALINDROME. =========================================================================== # WAP IN PYTHON TO CHECK WHETHER THE STRING IS SYMMETRICAL OR PALINDROME # creating two functions # function1 ==> to check palindrome # function2 ==> to check the string symmetrical def isPalindrome(s): rev = s[::-1] return rev == s def isSymmetrical(s): length = len(s) center = length // 2 # the center of the string if length % 2 == 0: return s[:center] == s[center:] else: return s[:center] == s[center+1:] string = input("Enter a string:") if isSymmetrical(string): print("The Given String is Symmetrical.") else: print("The Given string is not Symmetrical") if isPalindrome(string): print("The Given String is Palindrome") else: print("The Given string is Not palindrome") =========================================================================== # WAP TO REVERSE THE STRING WITHOUT SLICING string = input("Enter a string:") rev = "" for i in string: rev = i + rev # rev + i print("The String after the reverse = ",rev) ================================================================= # WAP IN PYTHON TO REVERSE WORDS IN A GIVEN STRING # HINT: # S = "OBJECT ORIENTED PROGRAMMING LANGUAGE" # OP = "LANGUAGE PROGRAMMING ORIENTED OBJECT" string = input("Enter a string:") # string into list # reverse the list words # we need join that list into string # ld = string.split() # # print(string) # print(ld) # # rev_ld = ld[::-1] # print(rev_ld) # # res_string = ' '.join(rev_ld) # # print(res_string) res_list = string.split()[::-1] res_string = ' '.join(res_list) print(res_string) ============================================ # WAP IN PYTHON TO FIND THE MAXIMUM OF LIST. # max() ==> return the maximum from group of numbers # min() ==> return the minimum from group of numbers ld = eval(input("Enter a list:")) # print("The Maximum of the list = ",max(ld)) # print("The Minimum of the list = ",min(ld)) ld.sort() # sorting in ascending order print("The Maximum = ",ld[len(ld)-1]) print("The Minimum = ",ld[0]) =================================================== # WAP IN PYTHON TO INTERCHANGE FIRST AND LAST ELEMENTS IN A LIST myList = eval(input("Enter a list:")) def ListOperation(myList): # length = len(myList) # # dummy = myList[0] # myList[0] = myList[length - 1] # myList[length-1] = dummy # list packing dummy = myList[-1],myList[0] # [1024, 121] # Unpacking the list myList[0],myList[-1] = dummy # [0] = 1024 [-1] = 121 return myList print("The List After the modification = ",ListOperation(myList)) Assignment: ========== 1) WAP TO REMOVE THE I'TH CHARACTER FROM THE GIVEN STRING. 2) WAP TO COUNT THE NUMBER OF CHARACTERS FROM THE GIVEN STRING WITHOUT BUILT-IN METHOD. 3) WAP TO AVOID SPACES IN THE STRING LENGTH. 4) WAP TO CHECK IF A STRING HAS AT LEAST ONE LETTER AND ONE NUMBER.