Programming Assignment Unit 5
Programming Assignment Unit 5
Write program to display your name and perform following operations on it:
1. Display n characters from left. (Accept n as input from the user)
2. Count the number of vowels.
3. Reverse it.
Solution:
# Main program
your_name = input("Enter your name: ")
while True:
print("\nChoose an operation:")
print("1. Display n characters from left")
print("2. Count the number of vowels")
print("3. Reverse the name")
print("4. Exit")
if choice == '1':
n = int(input("Enter the number of characters from the left: "))
display_left_characters(your_name, n)
elif choice == '2':
count_vowels(your_name)
elif choice == '3':
reverse_name(your_name)
elif choice == '4':
break
else:
print("Invalid choice. Please enter a valid option (1/2/3/4).")
print("Goodbye!")