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
The inventory tracking system shows that 12 laptop were on hand before a customer brings two laptops to the register for purchas
Bingel [31]

Answer:

Inventory errors can cause mismatches between the real numbers of the company, to avoid this you must use software that allows you to avoid these errors.

Explanation:

There is <u>software that line</u> (in the cloud), which is not necessary to install directly on a laptop or server.

Software examples for optimal inventory management:

1. ERP software in the cloud (it is an enterprise resource planner), it is flexible and low cost.

2. my MANAGEMENT

3. Crol

4. bind ERP (for SMEs)

5. Cloudadmin

6. Multi-commerce (license required).

6 0
3 years ago
Hi<br>is it right?<br>"I think there is a small mistake in the quotation(second not first)"​
Molodets [167]

Answer:

The answer to this question is given below in the explanation section.

Explanation:

  The correct option to this question is:

.clr{color:blue;}

I write the complete code of HTML using this CSS style to execute this scenario as given below

<html>

<head>

<style>

.clr

{

color:blue;

}

</style>

</head>

<body>

<a href="pg.html" class="clr">click here</a>

<h2 class="clr">Home</h2>

</body>

</html>

The bold text is a complete code of this question.  When you will run it it will execute a link and Home text on the page in blue color. So the correct option is .clr{color:blue;}

7 0
2 years ago
Which statement best describes a scientific theory?
lisov135 [29]

Answer:

It is supported by many different experiments.

Explanation:

Scientific theory is based on different experiments and tested in different situations and environment will all aspects. If the experiment finds true then observations will become theory. It can be changed in future if it does not meet the newly proposed conditions. But It does not means that, every theory can be changed.

6 0
3 years ago
Can you guys give some samples of STEM-related studies?​
anygoal [31]

Answer:

D :)))))

Explanation:

hope this helps

5 0
3 years ago
Read 2 more answers
Blurring in a photograph can be due to _____ or ______.
scoray [572]
Do you have options? In my personal opinion, however, blur could be caused by motion blur, or focusing on the wrong thing, Hope this helps any!
4 0
3 years ago
Read 2 more answers
Other questions:
  • Which major milestones started off the progression that led to the modern computers we play games on now? What do you think affe
    14·1 answer
  • The most effective way to perform data entry is to keep your hands on the keyboard and press to move to the text cell in the row
    10·1 answer
  • Describe what is meant by the following:
    14·1 answer
  • Can someone help me, please
    7·1 answer
  • It connects computers in different cities and different countries
    9·2 answers
  • ¿Qué ayuda nos proporcionan las herramientas tecnológicas en estos tiempo de pandemia? ayudaaaaa plis
    9·1 answer
  • The higher the ____________________, the faster the ____________________.
    5·1 answer
  • What is a computer please tell me ​
    10·2 answers
  • As part of your regular system maintenance, you install the latest operating system updates on your Windows 10 computer. After s
    12·1 answer
  • External hard drives typically connect to a computer via an external port (such as a usb or ____ port) or a wireless connection.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!