1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
vesna_86 [32]
3 years ago
6

In this exercise we will practice using loops to handle collections/containers. Your job is to write a program that asks the use

r to enter a sentence, then it counts and displays the occurrence of each letter.
Note: your program should count the letters without regard to case. For example, A and a are counted as the same.
Here is a sample run:
Enter a sentence: It's a very nice day today!
a: 3 times
c: 1 times
d: 2 times
e: 2 times
i: 2 times
n: 1 times
o: 1 times
r: 1 times
s: 1 times
t: 2 times
v: 1 times
y: 3 times
Notes:
The purpose of this problem is to practice using loops and collections/containers/strings.
Please make sure to submit a well-written program. Good identifier names, useful comments, and spacing will be some of the criteria that will be used when grading this assignment.
This assignment can be and must be solved using only the materials that have been discussed in class: loops, the index system, strings, lists and/or dictionaries. Do not look for or use alternative methods that have not been covered as part of this course.
How your program will be graded:
correctness: the program performs calculations correctly: 40%
complies with requirements (it properly uses loops, and containers/strings): 40%
code style: good variable names, comments, proper indentation and spacing : 20%
Language is python 3
Computers and Technology
1 answer:
kati45 [8]3 years ago
5 0

Answer:

In Python:

chars = 'abcdefghijklmnopqrstuvwxyz'

letter = input("Sentence: ")

for i in range(len(chars)):

   count = 0

   for j in range(len(letter)):

       if chars[i] == letter[j].lower():

           count = count + 1

   if count > 0 :

       print(chars[i]+": "+str(count)+" times")

Explanation:

This initializes the characters of alphabet from a-z

chars = 'abcdefghijklmnopqrstuvwxyz'

This prompts the user for sentence

letter = input("Sentence: ")

This iterates through the initialized characters

for i in range(len(chars)):

This initializes count to 0

   count = 0

This iterates through the input sentence

   for j in range(len(letter)):

This compares the characters of the sentence with alphabet a-z

       if chars[i] == letter[j].lower():

If there is a match, count is incremented by 1

           count = count + 1

If there is an occurrence of character,

   if count > 0 :

The character and its count is printed

       print(chars[i]+": "+str(count)+" times")

You might be interested in
Complete the sentences to describe file options categories
Anit [1.1K]
Where are the senteces
7 0
3 years ago
Read 2 more answers
Edra wants to consolidate the data from each of the regions. Switch to the Consolidated Sales worksheet, then update the workshe
VashaNatasha [74]

Answer:

a. In cell A6, enter a formula without using a function that references cell A6 in the Washington worksheet.

b. Copy the formula from cell A6 to the range A7:A9 without copying the formatting.

Explanation:

Microsoft Excel is a spreadsheet application used for data analysis and statistical calculation. The worksheet is made of columns and rows like a table and labeled alphabetically and numerically respectively. Several worksheets can be referenced in an excel workbook

To consolidate data in excel, reference a cell from another worksheet in the formula of the current worksheet and copy the formula from the cell to a given range of cells, without copying the formatting of the cell.

7 0
3 years ago
For homework, we were given this photo and to figure out what it is. It is up close and labelled “ too close to tell” but I have
dalvyx [7]
I honestly have no idea on what this is... but im guessing its some sort of tool or food in somebodys mouth... probably isn't but oh well..
7 0
3 years ago
What is the arc of technology it can't be a brand or app
Maru [420]

aim or audacity or avatar

bluetooth or blogspot

camera or cpu or core

5 0
3 years ago
Operation code field is present in:
Tasya [4]
The answer is most likely C
6 0
3 years ago
Other questions:
  • Explain how abstraction is used in a GPS system
    12·2 answers
  • What is a critique of the feature detector model of object recognition?​?
    8·1 answer
  • Collins and quillian explained the results of priming experiments by introducing the concept of _____ into their network model.
    12·1 answer
  • True and False: High-speed Internet service is free form of information technology that these businesses can utilize.
    13·1 answer
  • What is a society that has moved to the internet Rather than relying on physical media called
    11·1 answer
  • Which of the following statements about arrays are true?
    10·1 answer
  • ¿Por qué es importante generar proyectos innovadores?
    8·1 answer
  • Some loops are controlled by ____ (or reducing) a variable and testing whether the value remains greater than some benchmark val
    15·1 answer
  • write a pay-raise program that requests a person's first name, last name, and current annual salary, and then displays the perso
    6·1 answer
  • What is it called when u want 2 or more cells into 1
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!