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
A media strategy that involves high ________ most likely involve creating broad exposure using many media vehicles, while a stra
Tom [10]

Answer: Reach and frequency

Explanation:

 The media strategy is the planning and action that basically involve high reach in the exposure by using the media vehicle. It basically improve the overall conversation rate of customers.

The conversation rate is refers to the total percentage of the users which involve using the website and various applications.

This strategy also involve with high frequency that limited the list of the media vehicle.

 

5 0
3 years ago
Test if value is not less than 13.6.
svetoff [14.1K]

value = whatever you want

if not value < 13.6:

   print("Value is greater than or equal to 13.6.")

else:

   print("Value is less than 13.6.")

5 0
3 years ago
HELP I WILL GIVVE BRAINLY AND 15 POINTS
levacccp [35]

Answer:

Because someone was hittting the space bar in the message instead of typing letters and numbers

Explanation:

Because they were bored or it was a glitch

4 0
3 years ago
Help to how to write pseudo code to insert a new node to Binary Search Tree. Using C++.
dimulka [17.4K]

Answer:

Let the function be Node* ins(Node *root,int k)

if root node is NULL then return new node with data equal to k.

If the k <root->data

root->left=ins(root->left,k);

else if k >root->data

root->right =ins(root->right,k);

At last return root.

Explanation:

Node is always inserted at the at the leaf node.We will search k in the tree if we hit a the leaf node the new node is inserted as the child of the leaf node.

4 0
2 years ago
What defines which part of the IP address is the Network ID and the Host ID?
Brilliant_brown [7]

Answer:

Subnet Mask

Explanation:

Literally the answer.

5 0
2 years ago
Read 2 more answers
Other questions:
  • Identify the function for the following computer part: Printer Question 23 options: Input
    6·1 answer
  • How does Hadoop work? It breaks up Big Data into multiple parts so each part can be processed and analyzed at the same time on o
    5·1 answer
  • Algorithm for arithmetic mean program
    13·1 answer
  • Write a program that uses for loops to perform the following steps: Prompt the user to input two integers: firstNum and secondNu
    15·1 answer
  • You are a developer for a company that is planning on using the AWS RDS service. Your Database administrator spins up a new MySQ
    7·1 answer
  • To copy both character attributes and paragraph attributes, such as alignment and indentation, select the entire paragraph. TRUE
    14·1 answer
  • Jared recently sent an email to all the members of his department asking them for their opinions about where the department shou
    11·1 answer
  • A sales transaction was coded with an invalid customer account code (XXX-XX-XXX rather than XXX-XXX-XXX). The error was not dete
    12·1 answer
  • Declare an ArrayList of Strings. Add eight names to the collection. Output the Strings onto the console using the enhanced for l
    9·1 answer
  • What is the plan to make optimum usage of available spaces?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!