2 problems, please write in Python. Accumulator Pattern point Compose a program
ID: 3738520 • Letter: 2
Question
2 problems, please write in Python.
Accumulator Pattern point Compose a program which tests whether each character in a title-cased string text is upper-case or not. If it is, then the character should be appended to a accumulator string uppers The text used is taken from T. S. Eliot's "Choruses from The Rock. Starter code (alck to xiex) text :'Knowledge of speech, but not of silence ;..title() uppers??? for??? Accumulator Pattern 1 point Compose a program which counts the number of times the word / appears (indicating a stanza break). You may use any coding means available, but an accumulator pattern is preferred for this exercise. The result should be stored in an int word_count The text used is William Carlos Williams' "The Red Wheelbarrow" Starter code (lick to view) text 'so much depends/upon//a red wheel/barrow//glazed with rain/water//beside the white/chickens wordcount -Explanation / Answer
1)
text='Knowledge of speech, but not of silence;'.title()
uppers=str() #creating empty string
for character in text:
if character.isupper(): #checks each character is in upper case or not
uppers=uppers+character
2)
text='so much depends/upon//a red wheel/barrow//glazed with rain/water//beside the white/chickens.'
word_count=0
word_count=text.count('//')
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.