In: Computer Science
(PYTHON)
Q2 Strings, a more complex program from requirements
In part A you are asked to write the pseudocode for the
program.
In part B you are asked to write the syntax of the code for the
program you outlined in the pseudocode.
Q2 Part A - Pseduocode
Create the Pseudocode for the program outlined in Q5. Make sure that your program includes all the requirements outlined. This cell is markdown, you do NOT need to use markdown to format your response, but when viewing the cell it should be formatted with indents. Write your pseudocode in the cell below.
Q2 Part B - Strings Program
Write the code for the program that you wrote the pseudocode for in Q4 part A and is outlined by the requirements from Q4.
Program requirements:
Example Input:
What is your favorite quote from a book?:
Whatever its immediate consequences, the Paramount decision
launched a transformation of American film as cultural institution,
throwing the industry back into the open state it had emerged from
in the 1920s.
What book was that quote from?:
The Master Switch, The Rise and Fall of Information Empires
What page was that quote from?:
179
Example Output displayed to a user:
The quote "Whatever its immediate consequences, the Paramount decision launched a transformation of American film as cultural institution, throwing the industry back into the open state it had emerged from in the 1920s." comes from the book The Master Switch, The Rise and Fall of Information Empires and is located on page 179.
Upper Case count:3
Number of characters in the quote: 208
Thank you for your quote, this is a very good quote!
Q2 Part A - Pseduocode
quote = get quote from the user
book = get book name from the user
page = get the page number from the user
assign uppercase count to 0
loop through the string to get each character
if character is uppercase
increase the uppercase count by 1
print the quote with the book name & page number
print the uppercase count which are in quote
print the number of characters in the quote
Q2 Part B - String Program
quote = input("What is your favorite quote from a book?: ")
book = input("What book was that quote from?: ")
page = input("What page was that quote from?: ")
ucount = 0;
for uletter in quote:
if uletter.isupper():
ucount = ucount + 1
print("The quote \"" + quote + "\" comes from the book " + book + "
and is located on page " + page + ".")
print("Upper Case count: " + str(ucount))
print("Number of characters in the quote: " +
str(len(quote)))
print("Thank you for your quote, this is a very good quote!")