2 problems, please write in Python Accumulator Pattern 1 point Compose a program
ID: 3738490 • Letter: 2
Question
2 problems, please write in Python
Accumulator Pattern 1 point Compose a program which counts the total number of letters (not characters) in a string text. This code should use an accumulator pattern. The result should be stored in a string text_length The text used is taken from T. S. Eliot's "Choruses from The Rock. text The Hunter with his dogs pursues his circuit. alphabet = "ABCDEFGHlJKLMNOPQRSTUVWXYZ text-length for?? in text; if ??? in alphabet: text_length??? Accumulator Pattern point Compose a program which counts the total number of vowels in a string text. This code should use an accumulator pattern. The result should be stored in a string vowel_count The text used is taken from T. S. Eliot's "Choruses from The Rock". text o perpetual revolution of configured stars, vowel_count 0 for ??? in text: if ??? in AEIOU vowel_count? else: continueExplanation / Answer
text = "The Hunter with his dogs pursues his circuit."
alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
text_length = 0
for c in text:
if c.upper() in alphabet:
text_length = text_length + 1
print(text_length)
Output:
37
text = '0 perpetual revolution of configured stars,'
vowel_count = 0
for c in text:
if c.upper() in 'AEIOU':
vowel_count = vowel_count + 1
else:
continue
print(vowel_count)
Output:
15
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.