1.Python Program to Check weather a Given String is Palindrome or not.
2.Python Program to check weather a string is Anangram or not.
3.Python Program to reverse a string if it’s length is a multiple of 4
1.Python program to check weather a Given string is palindrome
string = input("Enter a string : ").lower()
a = string[::-1]
if a == string:
print("Given string is palindrome ")
else:
print("Given string is not palindrome ")
2.Python Program to check weather a string is Anangram or not
string1 = input("Enter a string : ").lower()
string2 = input("Enter a string : ").lower()
if sorted(string1)==sorted(string2):
print(“given strings are anangram”)
else:
print(“given string are not anangram”)
3.Python program to reverse a string if it’s length is a multiple of 4
string = input("Enter a string : ")
if len(string)%4==0:
print(string[::-1])
else:
print(“Lenght of the string is not multiple of 4”)
1.Python Program to Check weather a Given String is Palindrome or not.
string = (input())
if string == string[::-1]:
print(string,“is a palindrom”)
else:
print(string,“is not a palindrom”)
def palindrom(string):
if string == string[::-1]:
print(string,“is a palindrom”)
else:
print(string,“is not a palindrom”)
return ‘’
string = ‘madam’
print(palindrom(string))
2.Python Program to check weather a string is Anangram or not.
str1 = input().lower()
str2 = input().lower()
if len(str1)==len(str2):
if sorted(str1) == sorted(str2):
print(‘anagram’)
else:
print(‘not anagram’)
else:
print(‘length of string is greater’)
3.Python Program to reverse a string if it’s length is a multiple of 4
string = “hussainahmed”
length = len(string)
if length % 4 == 0:
print(string[::-1])
else:
print(‘string length is not multiple of 4’)
def rev(str):
if len(str) % 4 == 0:
return(str[::-1])
else:
return(‘string length is not multiple of 4’)
print(rev(‘hussainahmed’))
1.Python Program to Check weather a Given String is Palindrome or not
string = input("Enter a string: ")
if string == string[::-1]:
print(“Palindrome”)
else:
print(“Not Palindrome”)
#2.Python Program to check weather a string is Anangram or not
string_1 = input("Enter a string: ")
string_2 = input("Enter a string: ")
if sorted(string_1)==sorted(string_2):
print(“Anangram”)
else:
print(“notAnangram”)
#3.Python Program to reverse a string if it’s length is a multiple of 4
string = input("enter a string: ")
if len(string)%4==0:
print(string[::-1])
else:
print(“Length of string is not multiple of 4”)
1. Python Program to Check weather a Given String is Palindrome or not.
x=input("Enter the String: ")
rev_x=x[::-1]
if x==rev_x:
print(“The String is Palindrome”)
else:
print(“The String is Not a Palindrome”)
2. Python Program to check weather a string is Anangram or not.
x=input("Enter the 1st String: ").lower()
y=input("Enter the 2nd String: ").lower()
if sorted(x)==sorted(y):
print(“The Strings are Anagrams”)
else:
print(“The Strings are not Anagrams”)
3.Python Program to reverse a string if it’s length is a multiple of 4
x=input("Enter the String: ")
if len(x)%4==0:
print("Reversed String: ",x[::-1])
else:
print("Original String: ",x)
s=input(“enter the string”)
if len(s)%4==0:
print(s[::-1])
else:
print(“length is not multiple of four”)
Python Program to Check whether a Given String is Palindrome or not.
def Palindrome(String):
return String==String[::-1]
String=“rotator”
Result=Palindrome(String)
if Result:
print(“String is Palindrome”)
else:
print(“String is not Palindrome”)
Palindrome(String)
Python Program to reverse a string if it’s length is a multiple of 4
string=str(input(“Enter the word:”))
if len(string)%4==0:
print(‘’.join(reversed(string)))
else:
print(“Original string:”,string)
Python Program to reverse a string if it’s length is a multiple of 4
string=str(input(“Enter the word:”))
if len(string)%4==0:
print(string[::-1])
else:
print(“Original string:”,string)
2.Python Program to check whether a string is Anagram or not.
Word1=input(“Enter a string:”)
Word2=input(“Enter a string:”)
if sorted(Word1)==sorted(Word2):
print(“It is an Anagram String”)
else:
print(“It is not an Anagram String”)
#1
str=“wow”
if str==str[::-1]:
print(“palindrome”)
else:
print(“not palindrome”)
#2
str=“listen”
str1=“silent”
if sorted(str)==sorted(str1):
print(“anagram”)
else:
print(“not anagram”)
#3
str=“good”
if len(str)%4==0:
print(str[::-1])
else:
print(“not a four letter word”)