ich habe eine Aufgabenstellung und verstehe die Aufgabe des Englischen wegens nicht wirklich.
Ich möchte auch keinen Code von euch, sondern nur falls mir wer helfen kann eine Erklärung.
Assume you are given two dictionaries d1 and d2, each with integer keys and integer values. You are also given a function f, that takes in two integers, performs an unknown operation on them, and returns a value.
Write a function called dict_interdiff that takes in two dictionaries (d1 and d2). The function will return a tuple of two dictionaries: a dictionary of the intersect of d1 and d2 and a dictionary of the difference of d1 and d2, calculated as follows:
intersect: The keys to the intersect dictionary are keys that are common in both d1 and d2. To get the values of the intersect dictionary, look at the common keys in d1 and d2 and apply the function f to these keys' values -- the value of the common key in d1 is the first parameter to the function and the value of the common key in d2 is the second parameter to the function. Do not implement f inside your dict_interdiff code -- assume it is defined outside.
difference: a key-value pair in the difference dictionary is (a) every key-value pair in d1 whose key appears only in d1 and not in d2 or (b) every key-value pair in d2 whose key appears only in d2 and not in d1.
Den roten Text kann ich nicht greifen.Here are two examples:
If f(a, b) returns a + b
d1 = {1:30, 2:20, 3:30, 5:80}
d2 = {1:40, 2:50, 3:60, 4:70, 6:90}
then dict_interdiff(d1, d2) returns ({1: 70, 2: 70, 3: 90}, {4: 70, 5: 80, 6: 90})
If f(a, b) returns a > b
d1 = {1:30, 2:20, 3:30}
d2 = {1:40, 2:50, 3:60}
then dict_interdiff(d1, d2) returns ({1: False, 2: False, 3: False}, {})
Ich habe zwei dic´s. Was ist denn aber der common key?
Mein script funktioniert soweit solange ich den Wert von f(a,b) manipuliere. Also entweder vergleichen > (True, False) oder summieren
Da ich allerdings wie schon geschrieben nicht wirklich verstehe auf welchen Wert sich f(a,b) bezieht kann ich das leider nicht einbauen
Vielen Dank im voraus
Chris