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
Write a program to read a list of exam scores given as integer percentages in the range 0-100. Display the total number of grade
Tju [1.3M]

Answer:

import java.util.Scanner;

public class Program

{

  public static void main(String [] Args)

  {

      int totalAGrades = 0, totalBGrades = 0, totalCGrades = 0, totalDGrades = 0, totalFGrades = 0, counter=0,maximum = 0, minimum = 9999, num, total = 0,smallest = 0,largest = 0;

       Scanner in = new Scanner(System.in);

       System.out.println("Enter exam percentage: ");

       System.out.println("Enter a negative examScore: ");

       int examScore = in.nextInt();

       while(examScore > 0)

       {

         counter++;

         if(examScore < 0){          

             break;}  

         else if(examScore > maximum){      

              maximum = examScore;}

         else if(examScore < minimum)   {  

              minimum = examScore;}

         

          total = total + examScore;  

     

          if(examScore <= 50 && examScore>0)

              smallest = examScore;

              if(examScore > 90 && examScore <=100)

              largest = examScore;

         

      if(examScore>=90 && examScore<=100)

          totalAGrades++;

      else if(examScore>=80 && examScore<=89)

          totalBGrades++;

      else if(examScore>=70 && examScore<=79)

          totalCGrades++;

      else if(examScore>=60 && examScore<=69)

          totalDGrades++;

      else if(examScore>=0 && examScore<=59)

          totalFGrades++;

      examScore = in.nextInt();

     

   }

      System.out.println("Total number of scores is = " + counter );

      System.out.println("Total Number of each Letter grade : " + counter);

      System.out.println("Percentage of total for each letter grade : ");

          System.out.println("Total number of A grades = "+ totalAGrades);

          System.out.println("Total number of B grades = "+ totalBGrades);

          System.out.println("Total number of C grades = "+ totalCGrades);

          System.out.println("Total number of D grades = "+ totalDGrades);

          System.out.println("Total number of F grades = "+ totalFGrades);

     

      System.out.println("Lowest exam Score is :"+smallest);

      System.out.println("Highest exam Score is :"+largest);

      System.out.println("Average exam Score = "+ (total / counter));

  }

}  

Explanation:

  • Get the exam information from user as input and run a while loop until examScore is greater than zero.
  • Use conditional statement to check the scores of students and increment the relevant grade accordingly.
  • Finally display all the information including grades and scores.
3 0
3 years ago
What is HTML ? <br>Give a small description about html
Genrish500 [490]
Hypertext Markup Language, a standardized system for tagging text files to achieve font, colour, graphic, and hyperlink effects on World Wide Web pages.
this information was taken from google
7 0
2 years ago
Read 2 more answers
15. How many PC’s can be connected to a UPS?
Alex_Xolod [135]

Answer: Depends on the power of the computer /computers and the UPS

Explanation: For someone who had a big connected network of computers and printers we would plug the computer or server into the UPS as well as the monitor and sometimes a printer sometimes the monitor was plugged into the wall

When you get a UPS you must plug it in for a certain time could be hours or even a day.  A USP has a big battery in it and you must charge it (sometimes it comes semi-charged but you must plug it in to strengthen it. )

there are two connector wires that you affix to the battery and you must put a lot of strength into it to make it secure.

So in closing, you can get away with two like a desktop and a laptop.

Read your documentation that comes with the UPS

6 0
1 year ago
What is cloud computing?
Luba_88 [7]
According to google, cloud computing. <span>the practice of using a network of remote servers hosted on the Internet to store, manage, and process data, rather than a local server or a personal computer.</span>
4 0
3 years ago
Computing hardware, computers using vacuum tubes were called the first generation; transistors and diodes, the second; integrate
boyakko [2]
I think this is true but like think about the computer hardware and stuff
8 0
2 years ago
Other questions:
  • The sequence of folders to a file or folder is known as its _______.
    6·1 answer
  • Flexplace and telecommuting are similar in that both allow you to _____. work in a location away from the office work different
    8·1 answer
  • Discuss in detail why you need to use a write blocker (either hardware or software) in your examinations, whether for a criminal
    6·1 answer
  • Given an list of N integers, Insertion Sort will, for each element in the list starting from the second element: Compare the ele
    8·1 answer
  • What is performance? Multiple Choice measures how quickly a system performs a process or transaction a system that is not operat
    9·2 answers
  • 3. Under the Driver Responsibility Program, you may be assigned a number of points for:
    11·2 answers
  • Https://www.blooket.com/play?id=300932<br> please
    8·2 answers
  • Can able to Computer decide its input by itself? How ?​
    15·1 answer
  • 56- What is the term used when you press and hold the left mouse key and more the mouse
    8·1 answer
  • if the wide area network (wan) is supporting converged applications like voice over internet protocol (voip), which of the follo
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!