Function: get_total_cases() takes the a 2D-list (similar to database) and an integer x from this set {0, 1, 2} as input parameters. This function computes the total number of reported cases for each instance of x in the text file, and it stores this information in a dictionary in this form {an_instance_of_x : total_case}. Finally, it returns the dictionary and the total number of all reported cases saved in this dictionary
Q: Write the function called add_dictionaries(d1, d2) which takes as parameters two dictionaries whose…
A: This python program's code is given in the next step using a for loop.
Q: inverted_word_counts(word_count_dict, banned) that takes as a parameter a Write a function…
A: Python Code: # Utility function which deletes the banned keys from the word_count_dictionary def…
Q: a) read both code to figure out what they do. b) supply am appropriate content to the main function…
A: Actually, the code has given below:
Q: """ pass In the main program (the grade management system defined in the breakout room lab), add…
A: CODE SNIPPET: import math def create_grade_list(grade_info): l=[] d=grade_info.split()…
Q: Write a function that takes a dictionary representing points in 3D space and an associated color for…
A: Program: # method to find centroid def centroid(dict1): dictRes={} #traverse the dictionary…
Q: Write a function that takes two arguments: stock and ingr (short for ingredients) and returns the…
A: Given: To write a python program to check the availability of ingredients in the stock.
Q: Write a function with the given signature that will take a sorted array of integers and return the…
A: using System;class HelloWorld { public static int[] CompactArray(int[] input){ //method…
Q: Consider the following python code: def carDict(data): d = dict() for c in data: if…
A: Program Approach : Define the function carsDict and pass data into it . Define dictionary variable…
Q: python code Write a Python function listDictPrime() that gets as parameter a list of integers,…
A: Given Solution Contains: listDictPrime() function. Screenshot of code of listDictPrime() function.…
Q: You're given the pointer to the head nodes of two linked lists. Compare the data in the nodes of the…
A: The program is written in C++
Q: Write a function get key that takes as input a dictionary with integers as values, and a function.…
A: Given:
Q: how do i test this javascript function the function and directions for function are as follows…
A: Please refer to the following step for the complete solution of the problem above.
Q: Write a function call Occurrence that receives two arguments: an array of vectors (generic type) and…
A: Here is code in C++ as follows: Code: #include <iostream>#include <vector>#include…
Q: Write a function called safeAdd(d, k, v, unsafe=False) that takes either three or four input…
A: 1.in safe add function a. check if key is already in dict.keys() i. if unsafe is…
Q: On Assignment 4, Question 1, you were asked to solve the Assignment Difficulty problem. Now you're…
A: The test function details is given in next step:
Q: 1 -> 6 -> 2 -> 4 -> 5 -> 3 -> 8
A: #include <bits/stdc++.h>using namespace std; /* Link list node */class Node {public: int…
Q: Write a python program... Write a function called merge1(d1,d2) that takes two dictionaries as…
A: If you want to run the code you can run it on, online GDB compiler for python or you can run it on…
Q: Use the following input DataFrame: import pandas as pd rng np.random. RandomState (6) df pd.…
A: Answer:
Q: Implement the function below void swap(int pos1, int pos2) {}
A: void swap(node** hRef, int pos1, int pos2){ // Nothing to do if pos1 and pos2 are same if…
Q: Write a function that takes two arguments: stock and ingr (short for ingredients) and returns the…
A: In step 2, you will the python code.In step 3, you can see the sample output.
Q: get_topx_hotspots() that takes the 2D-list (similar to database), a dictionary (similar to dict) and…
A: Answer:
Q: 1. Write a Python function called add_daily temp that is given a (possibly empty) dictionary meant…
A: 1) Below is program that defines a function add_daily_temp which accept a dictionary containing…
Q: Create a generic function sum that takes two integer/double numbers as paramet and prints the sum.…
A: We need to define a generic method that accepts a subclass of Number as parameters and compute the…
Q: 1. Write a Python function called add_daily_temp that is given a (possibly empty) dictionary meant…
A: 1) Below is program that defines a function add_daily_temp which accept a dictionary containing…
Q: Write a sample function with one parameter that is a head pointer for a linked list of items. The…
A: THE ANSWER IS
Q: PROGRAM IN PLAIN C PLEASE! Write a void function that will merge the contents of two text files…
A: Solved BY C programming
Q: In the cell below, there is a function that is not operating as anticipated. count_consonants is…
A: def Check_Vow(string): # casefold has been used to ignore cases string = string.casefold()…
Q: Write a function that takes a dictionary representing points in 3D space and an associated color for…
A: Program: # method to find centroid def centroid(dict1): dictRes={} #traverse the dictionary…
Q: Please implement this function: void swap(int pos1, int pos2) {}. There's an answer from the…
A: C program to implement function void swap(int pos1, int pos2) {}: #include <stdio.h> #include…
Q: You are now working for Prof. Midas on a research project. You are given this piece of code to…
A: The built in lookUp function in python dictionary has complexity of O(1). The given user define…
Q: Consider the following function heading. void modifyList(int list[], int length)In the definition of…
A: Given: A function heading "void modifyList(int list[], int length)" Description: This function…
Q: Write a function named dictMax which takes two arguments: a dictionary and a list. Your function…
A: Initialize the return value to None and in the initial value we simply update None with our…
Q: Given a string that represents a matrix. Reshape the matrix into a new one with different…
A: Code: #include<stdio.h> #include<string.h> int main() { int len; //…
Q: Write a function report(filename) that consumes a string file and returns the grades of each student…
A: class Coursegrade: ''' Fields: grade(Str) course(Str) Requires: grade in ['4', '5', '6', '7',…
Q: Write a function called merge2(d2,d2) that takes two dictionaries as input parameters. This function…
A: def merge(d1, d2): d3 = {} for key in d1: d3.setdefault(key, [])…
Q: Write a function that takes two arguments: stock and ingr (short for ingredients) and returns the…
A: The program loops through each item in stock for the required item i.e.for the first item in the…
Q: Write a function get_key that takes as input a dictionary with integers as values, and a function.…
A: Python get() method return the value for the given key if present in the dictionary. If not then it…
Q: As discussed in class, using pointers, write a function named xstrcmp() to mimic strcmp() (click…
A: Below is the code:
Q: Look at the two functions Merge-and-Count & Sort-and-Count. You are also given an array-…
A: 1. Write down the output values: (total_count & L) for Sort-and-Count(Awesome_Array).
Q: IS Write a function named number_of_pairs whose parameter is an object/dictionary with strings as…
A: ALGORITHM:- 1. Declare and initialise a dictionary. 2. Pass this dictionary to the function which…
Q: You are now working for Prof. Midas on a research project. You are given this piece of code to…
A: Language is one of the most widely used programming language which has been used to create different…
Q: Write a function that takes two arguments: stock and ingr (short for ingredients) and returns the…
A: Source code in Python: def checkStock(stock, ingr): result = [] for item, count in ingr: if…
Q: Similar to the previous two problems, using pointers, write a function named xstrchr() to mimic…
A: Below i have written program:
Q: QUESTION 2 1) Write a maxConsecutiveDiff function which returns the maximum difference between any…
A: // MaxDifferenceOfConsecutive Numbers #include<iostream>#include<cstdlib> // including c…
Q: Write a function called list_to_dict(lst) that takes a 2-D list of sales records of this form.…
A: I have provided PYTHON CODE along with CODE SCREENSHOT and OUTPUT…
Q: how do i test this function in javascript function breakup(list,partitioner) { var result = {};…
A: Please refer to the following step for the complete solution of the problem above.
Q: Consider the following function that takes reference to head of a Doubly Linked List as parameter.…
A: A doubly linked list is a linked list in which it contains two pointers such as a pointer to the…
Q: Please answer it in Python Write a function show_plateau that takes as an argument a dictionary…
A: Code: def show_plateau(dlings): s="" #Iterating through dictionary for key,value in…
Q: Write a function called safeAdd(d, k, v, unsafe=False) that takes either three or four input…
A: def safeAdd(d, k, v, unsafe=False): if (k in d.keys()) and unsafe == False: print(f'{k} is…
Hi, I need help implementing this function into my code. This topic is about getting information out of text files:
Function:
get_total_cases() takes the a 2D-list (similar to
the total number of reported cases for each instance of x in the text file, and it stores this information in a dictionary in this form {an_instance_of_x : total_case}. Finally, it returns the dictionary and the total number of all reported cases saved in this dictionary
Step by step
Solved in 2 steps with 1 images
- Write in C++ Now, what if Sam wants to insert Eevee after Pikachu but he doesn't know where Pikachu is located in his list. Let's help him search for a Pokemon by its name and insert another Pokemon directly after it. Write a function secondPlace() that takes six parameters and inserts a new Pokemon into a list right after another specified pokemon. Once you find the specified Pokemon, use the insertAfter() function from the previous sub-question to add the new Pokemon. The function should return the new number of strings in the array. Note The same Pokemon may appear in the list multiple times (Sam has a bad memory). Assume that Sam wants every instance of the Pokemon he is searching for to be followed by the Pokemon he is attempting to insert. If the array is already full or if the number of strings that are going to be added to the array plus the current number of strings exceeds the total size of the array, the array should remain unchanged. Assume all inputs are lowercase…(PYTHON) a) get_total_cases() takes the a 2D-list (similar to database) and an integer x from this set {0, 1, 2} as input parameters. Here, 0 represents Case_Reported_Date, 1 represents Age_Group and 2 represents Client_Gender (these are the fields on the header row, the integer value represents the index of each of these fields on that row). This function computes the total number of reported cases for each instance of x in the text file, and it stores this information in a dictionary in this form {an_instance_of_x : total_case}. Finally, it returns the dictionary and the total number of all reported cases saved in this dictionary. (Suppose we want to know the total number of cases reported on each date, so use x = 0.) >>> result, total_cases = get_total_cases(database, 0) >>> display_dict(result) 2021-05-19: 8 2021-05-20: 2 2021-05-21: 1 2021-05-22: 1 >>> print(total_cases) 12Write a function named dictMax which takes two arguments: a dictionary and a list. Your function must look for the keys provided in the list argument, within the dictionary argument and return the maximum of the corresponding values. For example: dictMax({1:3, 3:2, 4:5, 2:6, 7:-1, 6:-3}, [3,2,6]) will return 6, because key 3 in the dictionary corresponds to value 2, key 2 to value 6 and key 6 to value -3, and among 2, 6 and -3, the maximum is 6. If a key does not exist in the dictionary, you should omit it. If none of the keys exist in the dictionary, you should return None.
- in python write a function where it makes a dictionary from given text file. If no value is present then it is an empty set. should work for any textfile. data with no spaces are keys, data after the tab space is the value def new_dict (textfile): return {} textfile input node1 node2 expected output {'node1': {'node2'}, 'node2': set()} should work with this text file as well: A B C B A C C A B D E E D F G G F H H G I I H G J J I K L L K M M LWrite a function called list_to_dict(lst) that takes a 2-D list of sales records of this form.[["customer1", "bread", 5], ["customer2", "bread", 4.5], ["customer1", "egg", 6.75]]Your function will store the sales information in a dictionary, where each {key:value} pair of the dictionary stores {a unique customer: [ a list of all products purchased by this customer, total cost of these products]}, and returns the dictionary. Sample run,sales = [ ["customer1", "bread", 5], ["customer2", "bread", 4.5], ["customer1", "egg", 6.75],["customer2", "milk", 4.35], ["customer3", "egg", 3.6], ["customer4", "bread", 4.5],["customer1", "milk", 4.35], ["customer2", "egg", 3.6], ["customer4", "milk", 4.35] ]>>> record = list_to_dict(sales)>>> display(record)customer1 : [['bread', 'egg', 'milk'], 16.1]customer2 : [['bread', 'milk', 'egg'], 12.45]customer3 : [['egg'], 3.6]customer4 : [['bread', 'milk'], 8.85]Write a python program... Write a function called merge1(d1,d2) that takes two dictionaries as input parameters. This function will create a new dictionary that contains everything from the two input dictionaries and return it. For this problem, you can assume that the input dictionaries do not have any keys in common. Create a few dictionaries, print them to screen using the function created above. After this, merge them using the function you wrote and print the result to the terminal. Sample run,>>> d1 = {'A': 100, ‘C':300}>>> d2 = {'B': 200, 'D':400}>>> d3 = merge1(d1,d2)>>> display(d3)A, 100B, 200D, 400C, 300
- Implement the function below void swap(int pos1, int pos2) {} For LinkedList, to maintain integrity of data in the structure, you are not to swap directly the element, nor remove a node. Instead, you are to only change the nodes' next pointers. Inital code to be completed: class LinkedList : public List { node* head; node* tail; int index; node* create_node(int num) { node* n = (node*) malloc(sizeof(node)); n->element = num; n->next = NULL; return n; } public: LinkedList() { index = 0; head = NULL; tail = NULL; } int add(int num) { addTail(num); return index; } int get(int pos) { node* currnode = head; int count =0; while (currnode != NULL){ count++; if (count == pos){ return currnode -> element; }else{ currnode = currnode -> next; } }…get_total_cases() takes the a 2D-list (similar to database) and an integer x from this set {0, 1, 2} as input parameters. Here, 0 represents Case_Reported_Date, 1 represents Age_Group and 2 represents Client_Gender (these are the fields on the header row, the integer value represents the index of each of these fields on that row). This function computes the total number of reported cases for each instance of x in the text file, and it stores this information in a dictionary in this form {an_instance_of_x : total_case}. Finally, it returns the dictionary and the total number of all reported cases saved in this dictionary.The question should be done in C++, please give explanation and running result. 1. For this question, we need to provide more information about where the mismatch of the text file is happening. Write a recursive function called list_mismatched_lines that takes 2 filenames as input arguments and displays to the screen all mismatched lines in those files. This function should use hashing techniques and shall not compare strings to detect mismatch. The signature of this function should be: void list_mismatched_lines(std::string file1, std::string file2); In file1.txt, it contains "My dear C++ class. I hope that you enjoy this assignment. " In file2.txt, it contains "My dear C++ class. I hope that you like this assignment. " Example: Running the following line of code, should print to the screen the mismatched lines only, from both files. list_mismatched_lines(file1, file2); The following output should be seen on the screen: file1.txt: I hope that you enjoy this assignment.file2.txt:…
- Merge2AscListsRecur that combines the nodes in X-list and Y-list into Z-list such that, after calling the function, Z-list is a sorted list (in non-decreasing order) containing all the nodes initially contained in X-list and Y-list – X-list and Y-list should both be empty after the call. The function should: ► Have only three parameters (each a pointer-to-Node) and no return value (be a void function). ► Not use any global variables or static local variables. ► Not use any looping constructs (for, while, do-while, ...). ► Be directly (not indirectly) recursive. ► Not create any new nodes, destroy any existing nodes or copy/replace the data item of any node. ► Not make temporary copies of the data involved using any other storage structures (arrays, stacks, queues, etc.). ► Use (if ever needed) no more than a small number of pointers to hold certain link addresses. ○ Not make temporary copies of the…Write a function that gets a linked list of ints, and reverses it. For example - on input 1 -> 2 -> 3 -> 4, after the function finishes the execution, the list becomes 4 -> 3 -> 2 -> 1 - If the list has one element, then it doesn’t change - If the list is empty, then it doesn’t change You may use the data fields in the struct and the functions provided in LL.h and LL.c. // reverses a linked list void LL_reverse(LL_t* list); Test for the Function: void test_q3() { LL_t* lst = LLcreate(); LL_add_to_tail(lst, 1); LL_add_to_tail(lst, 3); LL_add_to_tail(lst, 8); LL_add_to_tail(lst, 4); LL_add_to_tail(lst, 3); LL_reverse(lst); intcorrect[] = {3,4,8,3,1}; inti; node_t* n = lst->head; for(i=0;i<5;i++) { if (n==NULL) { printf("Q3 ERROR: node %d==NULL unexpected\n", i); return; } if (n->data != correct[i]) { printf("Q3 ERROR: node%d->data==%d, expected %d\n", i, n->data, correct[i]); return; } n = n->next; } if (n==NULL) printf("Q3 ok\n"); } Support…Write a function that gets a linked list of ints, and reverses it. For example - on input 1 -> 2 -> 3 -> 4, after the function finishes the execution, the list becomes 4 -> 3 -> 2 -> 1 - If the list has one element, then it doesn’t change - If the list is empty, then it doesn’t change You may use the data fields in the struct and the functions provided in LL.h and LL.c. // reverses a linked list void LL_reverse(LL_t* list); Test for the Function; void test_q3() { LL_t* lst = LLcreate(); LL_add_to_tail(lst, 1); LL_add_to_tail(lst, 3); LL_add_to_tail(lst, 8); LL_add_to_tail(lst, 4); LL_add_to_tail(lst, 3); LL_reverse(lst); intcorrect[] = {3,4,8,3,1}; inti; node_t* n = lst->head; for(i=0;i<5;i++) { if (n==NULL) { printf("Q3 ERROR: node %d==NULL unexpected\n", i); return; } if (n->data != correct[i]) { printf("Q3 ERROR: node%d->data==%d, expected %d\n", i, n->data, correct[i]); return; } n = n->next; } if (n==NULL) printf("Q3 ok\n"); } Support File…