EBK STARTING OUT WITH PYTHON
EBK STARTING OUT WITH PYTHON
4th Edition
ISBN: 9780134484693
Author: GADDIS
Publisher: PEARSON CUSTOM PUB.(CONSIGNMENT)
Question
Book Icon
Chapter 8, Problem 11PE
Program Plan Intro

Most Frequent Character

Program Plan:

  • • Declare a function named “findFrequentCharacter()” that accepts a string “my_string” as input. Inside the function,
    • ○ Create a list variable “countList” to store the frequency of all alphabets.
    • ○ Use the “for” loop to process all the characters in the “my_string” to check for frequency.
    • ○ Inside the “for” loop,
      • ■ Check if the current character “ch” is the alphabet.
      • ■ If so, then find the ASCII value of the character and store it in “n”.
      • ■ Check if the ASCII value of the character indicates the uppercase alphabet.
      • ■ If the condition is true, then find the index of the character in the “countList” by subtracting “65” from “n”.
      • ■ If the condition fails, then ASCII value of the character indicates the lowercase alphabet.
      • ■ Thus, find the index of the character in the “countList” by subtracting “97” from “n” value and store it in “n”.
      • ■ Using the “n” as the index, increment the value at “n” in the “countList” by “1”.
    • ○ After processing all the characters in the “my_string”, declare a variable “maxVal” to hold the highest value of occurrences.
    • ○ Also, declare a variable “maxValPos” to hold the position of the “maxVal” in the “countList”.
    • ○ Use the “for” loop to find the highest value in the “countList”.
    • ○ Inside the “for” loop,
      • ■ Check if the current value is higher than “maxVal”.
      • ■ If so, then update the “maxVal” with the current value and update the “maxValPos”.
    • ○ Convert the “maxVal” into the ASCII value by adding “97” with it.
    • ○ After that, convert the “maxVal” into character and return it.
  • • Declare a function named “main()”. Inside the “main()” function,
    • ○ Get a string from the user and store it in “my_string” variable.
    • ○ Call the function “findFrequentCharacter()” and pass “my_string” as input to the function and store the return value in “frequentCharacter”.
    • ○ Display the “frequentCharacter” using the “print()” function.
  • • In the last, call the function “main()” to execute the program.

Blurred answer
Students have asked these similar questions
What did you find most interesting or surprising about the scientist Lavoiser?
1. Complete the routing table for R2 as per the table shown below when implementing RIP routing Protocol? (14 marks) 195.2.4.0 130.10.0.0 195.2.4.1 m1 130.10.0.2 mo R2 R3 130.10.0.1 195.2.5.1 195.2.5.0 195.2.5.2 195.2.6.1 195.2.6.0 m2 130.11.0.0 130.11.0.2 205.5.5.0 205.5.5.1 R4 130.11.0.1 205.5.6.1 205.5.6.0
Analyze the charts and introduce each charts by describing each. Identify the patterns in the given data. And determine how are the data points are related.   Refer to the raw data (table):

Chapter 8 Solutions

EBK STARTING OUT WITH PYTHON

Ch. 8.3 - Prob. 11CPCh. 8.3 - Prob. 12CPCh. 8.3 - Write an if statement that displays Digit" if the...Ch. 8.3 - What is the output of the following code? ch = 'a'...Ch. 8.3 - Write a loop that asks the user Do you want to...Ch. 8.3 - Prob. 16CPCh. 8.3 - Write a loop that counts the number of uppercase...Ch. 8.3 - Assume the following statement appears in a...Ch. 8.3 - Assume the following statement appears in a...Ch. 8 - This is the first index in a string. a. 1 b. 1 c....Ch. 8 - This is the last index in a string. a. 1 b. 99 c....Ch. 8 - This will happen if you try to use an index that...Ch. 8 - This function returns the length of a string. a....Ch. 8 - This string method returns a copy of the string...Ch. 8 - This string method returns the lowest index in the...Ch. 8 - This operator determines whether one string is...Ch. 8 - This string method returns true if a string...Ch. 8 - This string method returns true if a string...Ch. 8 - This string method returns a copy of the string...Ch. 8 - Once a string is created, it cannot be changed.Ch. 8 - You can use the for loop to iterate over the...Ch. 8 - The isupper method converts a string to all...Ch. 8 - The repetition operator () works with strings as...Ch. 8 - Prob. 5TFCh. 8 - What does the following code display? mystr =...Ch. 8 - What does the following code display? mystr =...Ch. 8 - What will the following code display? mystring =...Ch. 8 - Prob. 4SACh. 8 - What does the following code display? name = 'joe'...Ch. 8 - Assume choice references a string. The following...Ch. 8 - Write a loop that counts the number of space...Ch. 8 - Write a loop that counts the number of digits that...Ch. 8 - Write a loop that counts the number of lowercase...Ch. 8 - Write a function that accepts a string as an...Ch. 8 - Prob. 6AWCh. 8 - Write a function that accepts a string as an...Ch. 8 - Assume mystrinc references a string. Write a...Ch. 8 - Assume mystring references a string. Write a...Ch. 8 - Look at the following statement: mystring =...Ch. 8 - Initials Write a program that gets a string...Ch. 8 - Sum of Digits in a String Write a program that...Ch. 8 - Date Printer Write a program that reads a string...Ch. 8 - Prob. 4PECh. 8 - Alphabetic Telephone Number Translator Many...Ch. 8 - Average Number of Words If you have downloaded the...Ch. 8 - If you have downloaded the source code you will...Ch. 8 - Sentence Capitalizer Write a program with a...Ch. 8 - Prob. 10PECh. 8 - Prob. 11PECh. 8 - Word Separator Write a program that accepts as...Ch. 8 - Pig Latin Write a program that accepts a sentence...Ch. 8 - PowerBall Lottery To play the PowerBall lottery,...Ch. 8 - Gas Prices In the student sample program files for...
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage