Question

1. Write a code that asks the user to enter a sentence. Then process the sentence...

1.

Write a code that asks the user to enter a sentence. Then process the sentence and let the user know which alphabets/numbers/symbols are used in the sentence and how many times.

please use python

Homework Answers

Answer #1

CODE:

#dictionary which will hold all the unique characters as the keys and its frequency as its value
freq = {}
#asking a sentence from an user
sentence = input('Enter a sentence: ')
#traversing each character in the sentence
for i in sentence:
#if a character is not present in the keys of the dictionary
if(i not in freq.keys()):
#its value is initialized to 0
freq[i] = 0
#then the value is incremented at its respective key value
freq[i] += 1
#printing the key-value pairs will give the frequency of each character in the sentence
for i in freq.keys():
print('Frequency of {} in the sentence: {}'.format(i,str(freq[i])))

__________________________________________________

CODE IMAGES AND OUTPUT:

___________________________________________

Feel free to ask any images in the comments section

Thank You!

Know the answer?
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
Similar Questions
write a program that asks the User to enter a letter, then asks the user to...
write a program that asks the User to enter a letter, then asks the user to enter a sentence. the program will then print out how many time that letter occurred in the sentence. in C Language
Design a program that asks user to enter any three numbers. The program should display the...
Design a program that asks user to enter any three numbers. The program should display the three numbers in ascending order. using python code please
In one C++ program: a.) Write a code to asks the user for her/his full name...
In one C++ program: a.) Write a code to asks the user for her/his full name b.) Write a code that asks the user to enter information related to a car the user likes (year, make, model) c.) Write a code that asks the user to enter the amount of time or gas or money the user spends to commute weekly d.) Write a code that asks the user to enter the number Kwh (used monthly) and compute the user...
WRITE it in Python! how to Write a method named smallest largest that asks the user...
WRITE it in Python! how to Write a method named smallest largest that asks the user to enter numbers, then prints the smallest and largest of all the numbers typed in by the user. You may assume the user enters a valid number greater than 0 for the number of numbers to read. Here is an example dialogue: How many numbers do you want to enter? 4 Number 1: 5 Number 2: 11 Number 3: -2 Number 4: 3 Smallest...
Write a python code that will ask the user to enter an integer number n. Construct...
Write a python code that will ask the user to enter an integer number n. Construct a recursive function that prints numbers 1 to n in the form “11223344..nn”.
1) In Python Use a while loop to ask the user to enter a series of...
1) In Python Use a while loop to ask the user to enter a series of alphabets. The loop terminates when the user presses enter. Once the loop terminates, display the number of vowels and consonants entered by the user. Hint: keep a running count of the number of characters entered by the user. Keep a running count of the number of vowels. Total number of consonants = total number of characters - total number of vowels. Assume that the...
Please use Python 3 4). Write a program that asks the user to enter 10 numbers....
Please use Python 3 4). Write a program that asks the user to enter 10 numbers. The program should store the numbers in a list and then display the following data: • The lowest number in the list • The highest number in the list •The total of the numbers in the list • The average of the numbers in the list   Sample input & output: (Prompt) Enter Number 1: (User enter) 4 (Prompt) Enter Number 2: (User enter) 7...
Please Write code in visual studio Roman Numeral Converter Write a program that asks the user...
Please Write code in visual studio Roman Numeral Converter Write a program that asks the user to enter a number within the range of 1 through 10. Use a switch statement to display the Roman numeral version of that number. Input Validation: Decide how the program should handle an input that is less then 1 or greater than 10.
Write a MATLAB while-loop code that asks a user to enter an integer number until its...
Write a MATLAB while-loop code that asks a user to enter an integer number until its factorial is smaller than 100.
Provide Python code that does the following: 4) Write a program that asks the user to...
Provide Python code that does the following: 4) Write a program that asks the user to enter a 9 character password. Test to see if it is a valid password. The validity test is a) they enter exactly 9 characters AND b) that every 3rd character, starting with the 1st character is the letter z. If it is valid print out the message “valid password” otherwise print the message “invalid password”. Sample output. Please enter a password: zaazbbz12 valid password...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT