Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
2 views

Program Flowchart

The document outlines a flowchart for a program that performs various advanced string operations based on user input. The operations include finding the longest and shortest words, displaying words that start with 'a', searching for specific words, and analyzing character types. The program continues until the user chooses to exit by inputting option 11.

Uploaded by

nandinijhts24
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Program Flowchart

The document outlines a flowchart for a program that performs various advanced string operations based on user input. The operations include finding the longest and shortest words, displaying words that start with 'a', searching for specific words, and analyzing character types. The program continues until the user chooses to exit by inputting option 11.

Uploaded by

nandinijhts24
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

2/9/25, 3:57 PM Program Flowchart

START

input a string in variable s

word = s.split()

print("\n" + "=" * 60)


print("\t ADVANCED STRING OPERATIONS MENU")
print("=" * 60)
print("1. Find the longest word and its length")
print("2. Identify the shortest word and its length")
print("3. Display all words that begin with 'a'")
print("4. Search for a specific word in the string")
print("5. Reverse every word in the string")
print("6. Display all words with exactly 3 letters")
print("7. Display words ending with 'e'")
print("8. Count occurrences of each word")
print("9. Analyze vowels, consonants, digits, spaces, uppercase, lowercase, and special characters")
print("10. Sort words using advanced insertion sort technique")
print("11. Exit")
print("=" * 60)

choice = input("Enter your choice (1-11): ")

max_length = -1

if choice == "1"
YES longest = ""
for word in words:
print(f"Longest word:
'{longest}' with length
if len(word) > max_length:
{max_length}.")
max_length = len(word)
longest = word

NO

min_length = float('inf')
shortest = ""

if choice == "2" YES for word in words:


if len(word) < min_length:
print(f"Shortest word:
'{shortest}' with length
{min_length}.")
min_length = len(word)
shortest = word

NO

YES found = []
for word in words:
print("Words starting with
if choice == "3" 'a':", ", ".join(found) if found
if word.startswith("a"):
else "None")
found.append(word)

NO

search_word = input("Enter word to search: ")

YES
present = False
for word in words: print("Word found!" if present
if choice == "4"
if word == search_word: else "Word not found!")
present = True
break

YES
word_count = {}
for word, count in for word in words:
word_count.items():
print(f"'{word}':
if word in word_count:
word_count[word] += 1
if choice == "8" NO
{count} occurrence(s)") else:
word_count[word] = 1
YES reversed_words = []
print("Reversed words:", "
if choice == "5" for word in words:
".join(reversed_words))
reversed_words.append(word[::-1])

NO
NO

print("Words ending with 'e':", ending_with_e = [] three_letter_words = [] print("Three-letter words:", ",


", ".join(ending_with_e) if for word in words: YES if choice == "7" NO if choice == "6" YES for word in words: ".join(three_letter_words) if
ending_with_e else "None") if word.endswith("e"): if len(word) == 3: three_letter_words else
ending_with_e.append(word) three_letter_words.append(word) "None")

vowels = consonants = digits = spaces = uppercase =


lowercase = special = 0
for char in s:
print(f"Vowels: {vowels}, if char.isdigit(): for i in range(1, len(words)):
Consonants: {consonants}, digits += 1 key = words[i]
Digits: {digits}, Spaces: elif char.isalpha(): j=i-1 print("Sorted words
{spaces}, Uppercase: if char.lower() in "aeiou": if choice == "9" if choice == "10" while j >= 0 and words[j] > key: (Insertion Sort):", ",
{uppercase}, Lowercase: vowels += 1 words[j + 1] = words[j] ".join(words))
{lowercase}, Special else: j -= 1
Characters: {special}") consonants += 1 words[j + 1] = key
if char.isupper():
uppercase += 1
else:
lowercase += 1
elif char.isspace():
spaces += 1
else:
special += 1

print("Program terminated.
print("Invalid input! Please
if choice == "11" Goodbye!")
choose a valid option.")
break

STOP

https://whimsical.com/program-flowchart-6z6qNaZmmEgrhuppP5PycC 1/1

You might also like