1. Write a program to reverse the given string.
str=input("enter the string")
length=len(str) enter the string python
print("the reverse is") the reverse is:
for i in range(length):
print(str[length-1-i],end="") nohtyp
2. Write a program to find the string is palindrome or not.
str=input("enter the string")
length=len(str)
rev=""
enter the stringnitin
for i in range(length): the reverse is
rev+= str[length-1-i] nitin
print("the reverse is ")
yes is a palindrome
print(rev)
if(str==rev):
print(" yes is a palindrome")
else:
print("nh")
3. Write a program to remove the duplicate from the given
string.
def remove_duplicates(s):
seen = set()
result = ""
for char in s: Enter the string: hello
if char not in seen: String after removing duplicates: helo
result += char
seen.add(char) # Mark character as seen
return result
# Input from user
str_input = input("Enter the string: ")
print("String after removing duplicates:",
remove_duplicates(str_input))
4. Write a program to check the given string is Anagram or
not.
def isanagram(s1,s2):
if(len(s1)!=len(s2)):
return False
return sorted(s1)==sorted(s2)
enter the first string:gum
s1=input("enter the first string:")
s2=input("enter the second string:")
enter the second string:mug
yes it is a anagram
if isanagram(s1,s2):
print("yes it is a anagram")
else:
print("no it is not anagram")
Double-tap to enter text
5. Write a program to find the length of the string.
enter the value of string goodmorning
str=input("enter the value of string") 11
length=len(str)
print(length)
6. Write a program to print the even length word in the given
string.
str=input("enter the value of string:") enter the value of string:ankit
length=len(str)
for i in range(1,length,2): ni
print(str[i],end="")
i=i+1
7. Write a program to find the maximum frequency character
in the string.
enter the string:hellohowareyou
def max_frequency(s): the max frewuency is of 'o'appears 3
return max(set(s),key=s.count)
str=input("enter the string:").replace(" ","")
char=max_frequency(str)
print(f"the max frewuency is of '{char}'appears {str.count(char)}")