import string def getLetterFrequency (phrase: str): letters = [0 for i in range(26)] #creates a list called letters that has 26 elements all set to 0 # write your code here to update letters with the proper values return letters def main(): phrase input("Enter a short phrase: ") frequency = getLetter Frequency (phrase) print("The Frequency of each letter in the phrase is: ") index = 0 for letter in string.ascii_uppercase: print(f"{letter}: {frequency [index]}", end = " ") index + 1 main() You are going to write a function for a program where the overall use of the program is to display the frequence of letters in a string. The function you will write is called getLetter Frequency and it will accept a string as a parameter. It should build a list of 26 integers that represent the frequency of each letter. Index 0 for A's, index 1 for B's and so forth. The function should return the list of letter frequency's. Upper and Lower case letters should be counted as the same letter (ie a == A) This can be done many ways with selections statements and arithmetic. The built in python function ord() will give you the ASCII value of any character. For example ord("A") == 65 and ord("B") == 66

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter8: Arrays
Section: Chapter Questions
Problem 5PE
icon
Related questions
Question

Need help with coding in this in python!

import string
def getLetterFrequency (phrase: str):
letters = [0 for i in range(26)] #creates a list called letters that has 26 elements all set to 0
# write your code here to update letters with the proper values
return letters
def main():
phrase input("Enter a short phrase: ")
frequency = getLetter Frequency (phrase)
print("The Frequency of each letter in the phrase is: ")
index = 0
for letter in string.ascii_uppercase:
print(f"{letter}: {frequency [index]}", end = " ")
index + 1
main()
Transcribed Image Text:import string def getLetterFrequency (phrase: str): letters = [0 for i in range(26)] #creates a list called letters that has 26 elements all set to 0 # write your code here to update letters with the proper values return letters def main(): phrase input("Enter a short phrase: ") frequency = getLetter Frequency (phrase) print("The Frequency of each letter in the phrase is: ") index = 0 for letter in string.ascii_uppercase: print(f"{letter}: {frequency [index]}", end = " ") index + 1 main()
You are going to write a function for a program where the overall use of the program is to display the frequence of letters in a string.
The function you will write is called getLetter Frequency and it will accept a string as a parameter. It should build a list of 26 integers that
represent the frequency of each letter. Index 0 for A's, index 1 for B's and so forth. The function should return the list of letter frequency's.
Upper and Lower case letters should be counted as the same letter (ie a == A)
This can be done many ways with selections statements and arithmetic. The built in python function ord() will give you the ASCII value of
any character. For example ord("A") == 65 and ord("B") == 66
Transcribed Image Text:You are going to write a function for a program where the overall use of the program is to display the frequence of letters in a string. The function you will write is called getLetter Frequency and it will accept a string as a parameter. It should build a list of 26 integers that represent the frequency of each letter. Index 0 for A's, index 1 for B's and so forth. The function should return the list of letter frequency's. Upper and Lower case letters should be counted as the same letter (ie a == A) This can be done many ways with selections statements and arithmetic. The built in python function ord() will give you the ASCII value of any character. For example ord("A") == 65 and ord("B") == 66
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning
Systems Architecture
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning