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
Setler79 [48]
3 years ago
12

Define a function below, sum_numeric_vals, which takes a single dictionary as a parameter. The dictionary has only strings for k

eys, but can have string or integer values. Complete the function to calculate and return the sum of the integer values in the dictionary.
Computers and Technology
1 answer:
notka56 [123]3 years ago
3 0

Answer:

Following are the program in the Python Programming language.

#define function

def sum_numeric_vals(dic):

 #set and initialize the integer variable to 0

 sum_total = 0

 #set the for loop to extract the value of dictionary

 for val in dic.values():

   #set if condition to find the sum

   if type(val)==int:

     sum_total += val

 #return the sum of the values

 return sum_total

#set and initialize dictionary type variable

dic={"Two":2,"Four":4}

#call and print the function

print(sum_numeric_vals(dic))

<u>Output:</u>

6

Explanation:

Here, we define the function "sum_numeric_vals()" and pass an argument "dic", inside the function.

  • Set and initialize an integer data type variable "sum_total" to 0.
  • Set the for loop which extract the values of the dictionary.
  • Set the if conditional statement inside the loop to find the sum of the values of the dictionary.
  • Then, return the sum of the values of the dictionary.

Finally, we set and initialize the dictionary type variable "dic" and pass it in the function's argument list then, call the function through the print function

You might be interested in
What was bill gates first operating system he created?
vagabundo [1.1K]
Microsoft windows was his first

3 0
3 years ago
A food web is shown below. In this food web, energy is transferred directly from the to the
Irina18 [472]

That answer would be the producer

8 0
3 years ago
A car with a 20-gallon gas tank averages 23.5 miles per gallon when driven in town and 28.9 miles per gallon when driven on the
katovenus [111]
Highway: 
<span>cout << "The car can drive " << 20*26.8 << " miles on the highway." << endl; </span>
<span>Town: </span>
<span>cout << "The car can drive " << 20*21.5 << " miles in the town." << endl;</span>
5 0
3 years ago
What the repeal of online privacy protections means for you?
kvv77 [185]
Online Privacy is well, our privacy while on the internet. If they have repealed that, then we have no privacy while on the internet. I feel like now a days there is no privacy at all anywhere. Everywhere you go, there are cameras watching you. So for them to take away online privacy is pretty messed up.
7 0
3 years ago
Question 3
prohojiy [21]

The Answer Should Be:

<u>The first thing for you to do when you arrive at an intersection is to stop at the traffic light. Your going to want to listen to the instructions or signals of the traffic Police.</u>

I Hope This Helps? :)

8 0
3 years ago
Other questions:
  • Nancy would like to configure an automatic response for all emails received while she is out of the office tomorrow, during busi
    13·2 answers
  • Objective:This assignment is designed to give you experience with thinking about algorithm analysis and performanceevaluation.Pr
    11·1 answer
  • Write a function addOne that adds 1 to its integer referenceparameter. The function returns nothing.
    11·1 answer
  • You need to find out how much ram is installed in a system. what command do you execute to launch the system information utility
    12·1 answer
  • The objective of ____ testing is to identify and eliminate execution errors that could cause a program to terminate abnormally,
    15·1 answer
  • You are in the middle of a big project at work. all of your work files are on a server at the office. you want to be able to acc
    14·1 answer
  • COMPUTER CODING
    5·1 answer
  • Something I should look for when trying to decide if a source is credible is the publication's ....
    10·1 answer
  • 4.7 Code Practice: Question 2
    7·1 answer
  • What does the following process describe?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!