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
Which of the following is the most effective password?
zzz [600]
I would have to say that the M3(ury would be the MOST effective, because it has more capitals, numbers, and symbols, which would make it harder to hack into.
5 0
3 years ago
Read 2 more answers
When you hide a worksheet, its ______ disappears, however the worksheet itself remains part of the workbook until you select to
Reptile [31]
Cell is the possible answer
8 0
3 years ago
Seven and two eighths minus five and one eighth equals?
lakkis [162]

Answer: 2.125

Explanation

4 0
3 years ago
tcp is sending data at 1 megabyte per second. if the sequence number starts with 7000, how long does it take before the sequence
aksik [14]

Data transmission using TCP is 1 MB/s. It takes [(232 1) 7000] / 1,000,000, or 4295 seconds, for the sequence number to go back to zero.

A communications protocol known as Transmission Control Protocol, or TCP, permits message transmission between computer hardware and software via a network. It is designed to transmit packets across the internet and to guarantee the successful transmission of data and messages over networks.

The Internet Engineering Task Force (IETF) has designated TCP as one of the foundational protocols that serve as the rules for the internet (IETF). One of the most extensively used protocols in digital network communications, it offers end-to-end data delivery.

Before being delivered between a server and a client, data is first structured by TCP. It guarantees the correctness of data sent through a network.

To know more about TCP click here:

brainly.com/question/28119964

#SPJ4

7 0
1 year ago
You have been banned from omegle due to possible terms of service violations by you, or someone else using your computer or netw
Schach [20]

1. Using VPN : Using VPN changes the IP address of your computer, changing the server for VPN again and again will change the IP and thus the omegle may suspect you as a robot or someone trying to load their server traffic and thus their algorithm banns it.

2. Leaving the account logged in : Sometimes when we shut a laptop from a friends house or another computer in house we leave the account logged in and thus if the account is logged in more then 5-6 times the server may think that the account is being used by someone else and thus banns it.

6 0
3 years ago
Read 2 more answers
Other questions:
  • Sidney works in the accounting department. His boss just assigned him a task that involves creating budget formulas for the comp
    7·1 answer
  • What is a valence orbit?
    13·2 answers
  • Customer Premises Equipment (CPE) includes all devices connected to the PSTN, where the ownership and the responsibility for mai
    15·1 answer
  • True or false: when an ospf route sends its link state information, it is sent only to those nodes directly attached neighbors.
    14·1 answer
  • A device which lets you interact with the computer
    6·2 answers
  • Which of the following helps create a positive community?
    11·1 answer
  • Where or what website can I download anime's? For free ​
    6·1 answer
  • 1. Insert a Header that has the following in excel​
    14·1 answer
  • 3<br> Select the correct answer.<br> What is the output of the following HTML code?<br>Please
    8·2 answers
  • What is a possible weakness of an expert-novice pair?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!