Index number: 5240101337
Name: Nigel Kofi Acheampong
1. Reverse a string
def reverse
_string():
text = "Programming"
reversed
_text = text[::-1]
print(f"1. Reversed '{text}': {reversed_text}")
2. Get initials from a full name
def get_initials():
full
_name = "Suzzane Agyekum"
initials = ".".join([word[0].upper() for word in full_name.split()]) + "."
print(f"2. Initials for '{full_name}': {initials}")
3. Check if a word is a palindrome
def check
_palindrome():
word = input("3. Enter a word to check if it's a palindrome: ")
if word.lower() == word.lower()[::-1]:
print(f" '{word}' is a palindrome!")
else:
print(f" '{word}' is NOT a palindrome.")
4. Count words in a sentence
def count
_words():
sentence = input("4. Enter a sentence to count words: ")
word
_count = len(sentence.split())
print(f" Word count: {word_count}")
5. Replace 'is' with 'was' in a sentence
def replace_
is
with
_
_was():
text = "This is a string and it is an example."
modified
_text = text.replace("is", "was")
print(f"5. Original: {text}")
print(f" Modified: {modified_text}
Index number: 5240101337
Name: Nigel Kofi Acheampong
1. Reverse a string
def reverse
_string():
text = "Programming"
reversed
_text = text[::-1]
print(f"1. Reversed '{text}': {reversed_text}")
2. Get initials from a full name
def get_initials():
full
_name = "Suzzane Agyekum"
initials = ".".join([word[0].upper() for word in full_name.split()]) + "."
print(f"2. Initials for '{full_name}': {initials}")
3. Check if a word is a palindrome
def check
_palindrome():
word = input("3. Enter a word to check if it's a palindrome: ")
if word.lower() == word.lower()[::-1]:
print(f" '{word}' is a palindrome!")
else:
print(f" '{word}' is NOT a palindrome.")
4. Count words in a sentence
def count
_words():
sentence = input("4. Enter a sentence to count words: ")
word
_count = len(sentence.split())
print(f" Word count: {word_count}")
5. Replace 'is' with 'was' in a sentence
def replace_
is
with
_
_was():
text = "This is a string and it is an example."
modified
_text = text.replace("is", "was")
print(f"5. Original: {text}")
print(f" Modified: {modified_text}