Question

PYTHON You are to write a program that will analyze the frequency of letters in a...

PYTHON

You are to write a program that will analyze the frequency of letters in a string. The user will enter a string, your program will output the number of times the letters of the alphabet appear in that string. The user is to enter a string that has upper or lower case letters only, no spaces or other characters. You should convert the string entered to all lowercase letters before you conduct your analysis.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
print("This program will find the frequency of letters in a string.")
print("The string you enter must have letters only, no spaces or other characters.")
s = input("Please enter the string: ").lower()

for i in range(26):
    ch = chr(ord('a') + i)
    print(ch + ": " + str(s.count(ch)))
Add a comment
Know the answer?
Add Answer to:
PYTHON You are to write a program that will analyze the frequency of letters in a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Python: Write a program that lets the user enter a string and displays the letter that...

    Python: Write a program that lets the user enter a string and displays the letter that appears most frequently in the string, ignore spaces, punctuation, and Upper vs Lower case. Create a list to hold letters based on the length of the user input Convert all letters to the same case Use a loop to check for each letter in the alphabet Have a variable to hold the largest number of times a letter appears, and replace the value when...

  • 1. Write a python program that reads a file and prints the letters in increasing order...

    1. Write a python program that reads a file and prints the letters in increasing order of frequency. Your program should convert entire input to lower case and only counts letters a-z. Special characters or spaces should not be counted. Each letter and it's occurrences should be listed on a separate line. 2. Test and verify your program and it's output. ---Please provide a code and a screenshot of the code and output. Thank you. ----

  • C Program In this assignment you'll write a program that encrypts the alphabetic letters in a...

    C Program In this assignment you'll write a program that encrypts the alphabetic letters in a file using the Vigenère cipher. Your program will take two command line parameters containing the names of the file storing the encryption key and the file to be encrypted. The program must generate output to the console (terminal) screen as specified below. Command Line Parameters Your program must compile and run from the command line. The program executable must be named “vigenere” (all lower...

  • Write a C program that prompts the user for an input string with all lowercase letters....

    Write a C program that prompts the user for an input string with all lowercase letters. Your program should then sort the characters in the string and print the sorted string. Assume that the string contains no spaces and has at most 30 lowercase characters. Your program should loop continually until the user enters “q” to quit.

  • Exercise #4: Some Operations on Strings Write a program that uses a C-string to store a...

    Exercise #4: Some Operations on Strings Write a program that uses a C-string to store a string entered from the keyboard (in lower case letters). The program will then provide 6 options about operations performed on the input string in the form of a menu, as shown in the following sample Input/Output. The 6 operations are given below: 1. print the string 2 reverse the string 3. print the length of the string 4. convert the lower letters to upper...

  • Write a Java program which takes a string as a user input. Create 2 functions. The...

    Write a Java program which takes a string as a user input. Create 2 functions. The first function expects a string as argument and returns void. It converts all upper case characters to lower case and converts all lower case characters to upper case. It then prints out the converted string to a console. The second function also expects a string as argument and returns void. It will find first charactor that is repeated exactly 2 times in the string....

  • Swap Cases - Write a python program to swap cases. LowerCase letters to Upper case and...

    Swap Cases - Write a python program to swap cases. LowerCase letters to Upper case and vice versa (10 points) Input : Www.PyDev.com Output: wWW.pYdEV.COM Input: Pythonist 2 Output: pYTHONIST 2 b) Manipulate Strings - Insert a sequence of characters into the specified position in the given String(10 points) Input : First Line contains the string to be manipulated Second Line contains the string to be inserted and the position Number Output : The modified string Sample Input & Output:-...

  • Write a program that reads a string from the keyboard and computes the two arrays of...

    Write a program that reads a string from the keyboard and computes the two arrays of integers upperCase, and lowerCase, each of size 26. The first one represents the frequency of upper case letters and the second one represents the frequency of lower case letters in the input string. After computing these arrays, the program prints the frequencies in the following format: The frequency of the letter A= The frequency of the letter B= Assume the input string contains only...

  • 1. Write a Python function that accepts a string and calculate the number of upper case...

    1. Write a Python function that accepts a string and calculate the number of upper case letters and lower case letters. Sample String : 'The quick Brow Fox' Expected Output : No. of Upper case characters : 3 No. of Lower case Characters : 12

  • Using basic c++ write 2 separate codes for this assignment. Program #1 Write a program that...

    Using basic c++ write 2 separate codes for this assignment. Program #1 Write a program that calculates the average of a group of test scores, where the lowest score in the group is dropped. It should use the following functions. • void getScore() should ask the user for a test score, store it in the reference parameter variable, and validate it. This function should be called by the main once for each of the five scores to be entered. •...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT