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
)duplicate hash code
mash [69]

Answer:A) Create collisions

Explanation: Hash codes are the numeric codes present in the programming infrastructures which are responsible for focusing on the object while the equality testing is in process. Hash codes does not display the property of having a permanent value.

When there is the creation of the duplicate hash codes then ,chances of collision arise because they search for the particular object and cannot have the same numeric value.

5 0
3 years ago
What advantage does digital storytelling have over oral storytelling traditions?
Marysya12 [62]
Pretty sure the answer is D
6 0
4 years ago
(5 pt.) The name of a variable in the C programming language is a string that can contain uppercase letters, lowercase letters,
lilavasa [31]

Answer:

The different variable in C is 21213316700.

Explanation:

Given value:

Total value  = letters + underscore value

Total value  = 52 + 1

Total value =53

choice for first character = 53 letters +10 digits

first character = 63

choice for remaining characters

So,

Variable number With one 1 character = 53

Variable number With 2 character  = 53 × 63

Variable number With 3 character = 53 × 63²

Variable number With 4 character  = 53 × 63³

.

.

.

Variable number With 7 character  = 53 \times  63^{7}

Total difference variable = 53 + 53 × 63+ 53 × 63²+ 53 × 63³+....+ 63^{7}

Total difference variable = 53(1 + 63 + 63²+ 63³+ .... + 63^{7})

Formula:

1+x+x^2+x^3+x^4+........x^n\\\\\Rightarrow  \frac{x^{(n+1)} -1}{x-1}

Total difference variable

53 \times \frac{63^{7+1} -1 }{63-1}\\\\53 \times \frac{63^{8} -1 }{63-1} \\\\ \therefore 63^8 = 2.48 \times 10^{14}\\\\53 \times \frac{2.48 \times 10^{14} -1  }{62}\\\\53 \times \frac{1.48 \times 10^{14}}{62}\\\\21213316700

6 0
4 years ago
Please Help meeeeeeeeeee:
Akimi4 [234]

Answer:

D) save as

Explanation:

If you press save as it'll give you the option where to save to.

6 0
3 years ago
Read 2 more answers
PLEASE HELP ME ASAP!!! Looking at the misty rain and fog (pictured above) Explain at least two defensive driving techniques you
JulsSmile [24]
1.Slow down 2. Break earlier
7 0
3 years ago
Other questions:
  • To move to the most extreme right cell containing data in your worksheet, what basic key combination can you use?
    7·1 answer
  • What OS is most commonly used by businesses? Linux Macintosh Microsoft Windows
    11·1 answer
  • To remove an embedded chart, you should _____ it and press the DELETE key.
    14·2 answers
  • You wish to enter your exam scores in a spreadsheet. Which function will help you find how each subject’s score relates to the o
    15·2 answers
  • How to can you avoid becoming a victim of identity theft?
    10·1 answer
  • You would use the _______ conditional formatting options when analyzing a worksheet in which you want to highlight the highest o
    13·1 answer
  • Every telecommunication setup uses two devices: one device to transmit data and one device to receive data. Which device transmi
    15·1 answer
  • PLEASE HELP! 100 POINTS!
    7·1 answer
  • Which of the following is NOT true about a USB stick?
    5·2 answers
  • Which approach to bandwidth usage consumes all of the available frequencies on a medium to transmit data
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!