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...
You have been asked to create a python program that will ask the user how many...
You have been asked to create a python program that will ask the user how many tickets the user would like to purchase for graduation. The user will then choose the number of tickets needed and the program will list the cost of the tickets, a service fee, tax, and the total of the purchase. Specifications: The program should only accept whole numbers when receiving input for the number of tickets needed. No calculations should be performed if input is...
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...
In python, write a program that asked the user to enter the monthly costs for the...
In python, write a program that asked the user to enter the monthly costs for the following expenses incurred from operating his automobile: loan payment, insurance, gas, oil, tires, and maintenance. The program should display total monthly cost and annual cost. Also, should contain main and calcExpenses functions, calcExpenses should only calculate the expenses and everything else should happen in the main function.
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT