Created
July 22, 2023 17:12
-
-
Save SaikumarKonakanchi0/4d444971424ec5e63ac01d0dc32e5d94 to your computer and use it in GitHub Desktop.
22-07-2023
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def ex_str(n): | |
a=n[0] | |
b=n[-1] | |
print(b+n[1:-1]+a) | |
n=input() | |
ex_str(n) | |
#Expected Output for string Germany | |
#yermanG |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def long_str(n): | |
long_string=n[0] | |
for i in n: | |
if len(i)>len(long_string): | |
long_string=i | |
return long_string | |
n=["apple", "banana", "kiwi", "orange", "grapefruit"] | |
print('Longest String is:',long_str(n)) | |
#Expected Output: | |
#Longest String is: grapefruit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def no_of_words(n): | |
print('The no of words in the sentence are:',len(n)) | |
n=input('Enter the sentence with words seperated by spaces: ') | |
res=n.split() | |
no_of_words(res) | |
#Expected Output: | |
# Enter the sentence with words seperated by spaces: Germany is a beautiful city | |
# The no of words in the sentence are: 5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def palindrome(n): | |
if n==str(n[::-1]): | |
print('Palindrome') | |
else: | |
print('Not Palindrome') | |
n=input('Enter the String: ') | |
palindrome(n) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def remove_vowels(n,remove): | |
res='' | |
for i in n: | |
if i not in remove: | |
res+=i | |
print(res) | |
n=input('Enter tne string: ') | |
remove='aeiou' | |
remove_vowels(n,remove) | |
#Expected Output: | |
# Enter tne string: Germany | |
# Grmny |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment