Question

In: Computer Science

(PYTHON) Q2 Strings, a more complex program from requirements In part A you are asked to...

(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:

  1. Accepts the user response to the prompt "What is your favorite quote from a book?"
  2. Accepts the user response to the prompt "What book was that quote from?"
  3. Accepts the user response to the prompt "What page was that quote from?"
  4. Count the number of upper case letters
  5. Count the total number of characters
  6. Display "This includes 'dog' in the quote" if the quote includes the three characters to form the series of characters dog any place in the quote.
  7. Use a loop
  8. Print the total number of characters

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!

Solutions

Expert Solution

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!")


Related Solutions

For Python: In this assignment you are asked to write a Python program to determine the...
For Python: In this assignment you are asked to write a Python program to determine the Academic Standing of a studentbased on their CGPA. The program should do the following: Prompt the user to enter his name. Prompt the user to enter his major. Prompt the user to enter grades for 3 subjects (A, B, C, D, F). Calculate the CGPA of the student. To calculate CGPA use the formula: CGPA = (quality points * credit hours) / credit hours...
Python 8.17 LAB: Strings of a Frequency Write a program that reads whitespace delimited strings (words)...
Python 8.17 LAB: Strings of a Frequency Write a program that reads whitespace delimited strings (words) and an integer (freq). Then, the program outputs the strings from words that have a frequency equal to freq in a case insensitive manner. Your specific task is to write a function wordsOfFreqency(words, freq), which will return a list of strings (in the order in which they appear in the original list) that have a frequency same as the function parameter freq. The parameter...
Python This part involves creating a function that will manage a List of unique strings. The...
Python This part involves creating a function that will manage a List of unique strings. The function is passed a string and a list as arguments. It passes a list back. The function to add a word to a List if word does not exist in the List. If the word does exist in the List, the function does nothing. Create a test program that takes a string as input and then calls the function over and over until the...
You are asked to write a simple C++ phonebook application program. Here are the requirements for...
You are asked to write a simple C++ phonebook application program. Here are the requirements for the application. read the contact information from a given input file (phonebook.txt) into a dynamically created array of Contact objects. Each line of the input line includes name and phone information of a contact. Assume that each name has a single part Allow to perform operations on array of data such as search for a person, create a new contact or delete an existing...
Write a program that uses Python List of strings to hold the five student names, a...
Write a program that uses Python List of strings to hold the five student names, a Python List of five characters to hold the five students’ letter grades, and a Python List of four floats to hold each student’s set of test scores. The program should allow the user to enter each student’s name and his or her four test scores. It should then calculate and display each student’s average test score and a letter grade based on the average....
Python Language: The Marietta Country Club has asked you to write a program to gather, then...
Python Language: The Marietta Country Club has asked you to write a program to gather, then display the results of the golf tournament played at the end of March. The Club president Mr. Martin has asked you to write two programs. The first program will input each player's first name, last name, handicap and golf score and then save these records in a file named golf.txt (each record will have a field for the first name, last name, handicap and...
Q) You have been asked to develop a program which processes C++ null-terminated strings to extract...
Q) You have been asked to develop a program which processes C++ null-terminated strings to extract character and numerical data separately. Assume that the users runs the application (examTest.exe) from the command line as follows: examTest.exe X-Axis:10,Y-Axis:17,Z-Axis:-6 Your application should step through the input arguments and extract the values of the XAxis, Y-Axis and Z-Axis commands. The user must always enter the arguments in the specified order, however your application should check they are correct. At the end of your...
Using Python, write a program named hw3b.py that meets the following requirements: Welcome the user to...
Using Python, write a program named hw3b.py that meets the following requirements: Welcome the user to Zion's Pizza Restaurant and ask the user how many people are in their dinner group. If the answer is more than eight (8), print a message saying they'll have to wait for a table. Otherwise, report that their table is ready and take their order. Assume the client orders one pizza, and ask what he/she would like on their pizza, include a loop that...
Using Python, write a program that meets the following requirements: Make a list called sandwich_orders and...
Using Python, write a program that meets the following requirements: Make a list called sandwich_orders and fill it with the names of various sandwiches. Make an empty list called finished_sandwiches. Loop through the list of sandwich orders and spring a message for each order such as "I am working on your tuna sandwich" As each sandwich is made, move it to the list of finished sandwiches. After all the sandwiches have been made, print a message listing each sandwich that...
Write a C program that does the following In this part, you will write more complicated...
Write a C program that does the following In this part, you will write more complicated functions. They will require parameters and return values. The purpose is to give you experience with these components, and to show you how functions can be used to break your code down into smaller parts. You will also get some more experience with iterating through arrays.Open repl project Lab: User-Defined Functions 2. Write a program that does the following: 1.(20 pts.) Allows the user...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT