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
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”.
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.
- Write a Python program which asks the user to enter a number, if the number...
- Write a Python program which asks the user to enter a number, if the number is divisible by 6 or 7, the program prints “The number X is divisible by 6 or 7” and if the number is neither divisible by 6 nor by 7, then it prints “The number X is not divisible by 6 and 7”.
(SumDigits.java) Write code that asks the user to enter an integer between 100 and 999. The...
(SumDigits.java) Write code that asks the user to enter an integer between 100 and 999. The program finds and displays the three digits in the number. The program also calculates and displays the sum of the three digits. A sample run is shown below: Enter a number between 100 and 999: 528 The three digits in the number are: 5 2 8 The sum of the three digits is: 15 Note: You must use integer division and modulo division to...
in c++ Write a C++ program that asks the user to enter an integer number and...
in c++ Write a C++ program that asks the user to enter an integer number and prints it back "vertically" to the screen. Use recursion in your solution. As an example of how the program will work: Please enter an integer: 12345 The integer you entered will print vertically as: 1 2 3 4 5
IN PYTHON : Write a program that asks the user for a number. Write the number...
IN PYTHON : Write a program that asks the user for a number. Write the number to a file called total.txt. Then ask the user for a second number. Write the new number on line 2 with the total for both numbers next to it separated by a comma. Then ask the user for a third number and do the same. Keep asking for numbers until the person puts in a zero to terminate the program. Close the file. Be...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT