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
Luden [163]
2 years ago
10

Write a function named count_vowels that accepts two arguments: a string and an empty dictionary. The function should count the

number of times each vowel (the letters a, e, i, o, and u) appears in the string, and use the dictionary to store those counts. When the function ends, the dictionary should have exactly 5 elements. In each element, the key will be a vowel (lowercase) and the value will be the number of times the vowel appears in the string. For example, if the string argument is 'Now is the time', the function will store the following elements in the dictionary: 'a': 0 • 'e': 2 'i': 2 'o': 1 'u': 0 The function should not return a value.
Computers and Technology
1 answer:
SpyIntel [72]2 years ago
7 0

The function that counts the number of times a vowel exist in a string is as follows:

def count_vowels(string, dictionary):

    vowels = 'aeiou'

    dictionary = {}.fromkeys(vowels, 0)

    for i in string:

         if i in vowels:

              dictionary[i] += 1

    return dictionary

print(count_vowels("trouble", {}))

<h3>Code explanation.</h3>

The code is written in python.

  • we defined a function named "count_vowels". The function accept a string and an empty dictionary.
  • Then. we store the vowels in a variable vowels.
  • The dictionary is used to store the key value pair i.e the vowels and the number of times they appear.
  • We looped through the string.
  • If any value in the string is in vowels,  we increase the dictionary values by 1.
  • Then, we return the dictionary.
  • Finally, we call the function with it parameters.

learn more on function here: brainly.com/question/27219031

You might be interested in
In Python, a function is _____.
ad-work [718]

Answer:

a group of instructions that can be used to organize a program or perform a repeated task

Explanation:

A function is a group of commands that can be called upon with extra parameters if needed.

Example:

def foo():                          #defining this function and naming it foo

    return True                 #what is performed when foo is called on

if foo() == True:               #foo() is calling on a function named foo

   print('yes')

8 0
3 years ago
Contemporary operation of networking technology is possible only through the usage of open-use technology and layering approache
eimsori [14]

Answer: TRUE

Explanation: Networking technology is the term used to describe the entire processes through which computer or mobile systems are linked up either through optic fibers,wireless systems in order to enhance effective communication across networks or regions.

OSI (open system interconnection), the earliest models partitions into seven layers and the OSI is known as model that creates partitioning a communication system classing them into abstraction layers.

8 0
3 years ago
3.5 Code Practice
Veseljchak [2.6K]

Answer:

grade = input("Enter grade")

def add(grade):

if grade == 9:

 print("Not in High School Freshman")

elif grade == 10:

 print("In High School")

 print("somophone")

elif grade == 11:

 print("in High School")

 print("Junior")

elif grade == 12:

 print("in High School")

 print("Senior")

else:

 print("Grade Not Accepted:")

return 0;

add(11)

Output:

Enter grade 11

in High School

Junior

Process finished with exit code 0

Explanation:

Firstly remember that this is a function, and not a program. Hence, you need to call the function to test it. A python program is interpreted line by line, Hence, we can test a function as well. Here we input a grade, and through the function find the details related to it and the print it out, which is clearly explained through the definition of the function.

7 0
4 years ago
Read 2 more answers
What is JavaScript? JavaScript is a _____ language.
disa [49]

Answer: dynamic computer language

Explanation:

JavaScript is a dynamic computer language. Hope this helps! (•‿•)

5 0
3 years ago
Read 2 more answers
Rockstar Software, Inc., develops a new series of performance-related video games. This software is most likely protected by
Nimfa-mama [501]
DRM likely is the answer. Anything that prevents duplication really.
6 0
3 years ago
Other questions:
  • Which are examples of embedded systems? Choose two answers.
    15·1 answer
  • Honestly reporting experimental findings is an example of good what?
    7·2 answers
  • How many generations of computer languages have there been since the middle of the 20th century?
    9·2 answers
  • For window 7 explain the steps you will use to find the available program you will list.
    13·1 answer
  • With a two-dimensional array, the ____ field holds the number of rows in the array.
    6·1 answer
  • Which of the following statements about creating arrays and initializing their elements is false?
    6·1 answer
  • Which is a correct way to test whether two variables representing numbers, numOne and numTwo, are equal?
    8·1 answer
  • How to interchange first half of the array with second half of array in python?
    9·1 answer
  • Once the data center routes to the destination server that hosts the website, what's the next step in the Internet process?
    12·1 answer
  • For robot arms the first three axes are called
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!