Learn how to use the SUM function and AutoSum in Microsoft Excel to quickly add values across cells, columns, or rows. Includes syntax, examples, and tips for efficient usage.
To build a menu-driven Python program that allows users to perform different string operations like:
This helps students:
print("Welcome to the String Formatter Toolkit!")
sentence = input("Enter a sentence: ")
while True:
print("\nWhat would you like to do?")
print("1. Find a word")
print("2. Replace a word")
print("3. Split into words")
print("4. Partition at a word")
print("5. Exit")
choice = input("Enter your choice (1-5): ")
if choice == '1':
word = input("Enter the word to find: ")
pos = sentence.find(word)
if pos != -1:
print(f"'{word}' found at position {pos}")
else:
print(f"'{word}' not found.")
elif choice == '2':
old = input("Word to replace: ")
new = input("New word: ")
sentence = sentence.replace(old, new)
print("Updated sentence:", sentence)
elif choice == '3':
words = sentence.split()
print("Words in sentence:", words)
elif choice == '4':
sep = input("Enter the word to partition by: ")
before, middle, after = sentence.partition(sep)
print("Before:", before)
print("Separator:", middle)
print("After:", after)
elif choice == '5':
print("Goodbye!")
break
else:
print("Invalid choice. Please enter a number from 1 to 5.")
Welcome to the String Formatter Toolkit!
Enter a sentence: Python is easy and fun to learn
What would you like to do?
1. Find a word
2. Replace a word
3. Split into words
4. Partition at a word
5. Exit
Enter your choice (1-5): 1
Enter the word to find: fun
'fun' found at position 19
find
, replace
, split
, partition
)Tutorials, Roadmaps, Bootcamps & Visualization Projects