Hướng dẫn how do you find the top 3 values in python? - làm thế nào để bạn tìm thấy 3 giá trị hàng đầu trong python?

Nếu các giá trị có thể xuất hiện trong danh sách của bạn nhiều lần, bạn có thể thử giải pháp này.

def search[Fscore_list, num=3]:
    l = Fscore_list
    res = dict[[[v, []] for v in sorted[set[l], reverse=True][:num]]]
    for index, val in enumerate[l]:
        if val in res:
            res[val].append[index]
    return sorted[res.items[], key=lambda x: x[0], reverse=True]

Đầu tiên, nó tìm thấy các giá trị cao nhất num=3 và tạo dict với list trống cho các chỉ mục cho nó. Tiếp theo, nó đi qua danh sách và cho mọi giá trị cao nhất [____10] lưu các chỉ mục của nó. Sau đó, chỉ cần trả lại danh sách các bộ dữ liệu được sắp xếp như

>>> l = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4]
>>> print[search[l]]
[[43, [2, 6]], [9, [0]], [8, [7, 9]]]
1. ví dụ.

>>> l = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4]
>>> print[search[l]]
[[43, [2, 6]], [9, [0]], [8, [7, 9]]]

Để in các vị trí làm điều gì đó như:

>>> Fscore_list = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4, 43, 43, 43]
>>> result = search[Fscore_list]
>>> print["1st. %d on positions %s" % [result[0][0], result[0][1]]]
1st. 43 on positions [2, 6, 11, 12, 13]
>>> print["2nd. %d on positions %s" % [result[1][0], result[1][1]]]
2nd. 9 on positions [0]
>>> print["3rd. %d on positions %s" % [result[2][0], result[2][1]]]
3rd. 8 on positions [7, 9]

Từ điển trong Python là một bộ sưu tập các giá trị dữ liệu không được đặt hàng, được sử dụng để lưu trữ các giá trị dữ liệu như bản đồ, không giống như các loại dữ liệu khác chỉ chứa một giá trị đơn như một phần tử, từ điển giữ khóa: cặp giá trị.

Examples:  

Input : my_dict = {'A': 67, 'B': 23, 'C': 45,
                   'D': 56, 'E': 12, 'F': 69} 

Output : {'F': 69, 'A': 67, 'D': 56}

Hãy cho chúng tôi xem các phương thức khác nhau, chúng tôi có thể tìm thấy 3 giá trị cao nhất trong từ điển. & NBSP;

Phương pháp số 1: Sử dụng Collection.Count []Using collections.Counter[]

Một quầy là một lớp con Dict để đếm các đối tượng có thể băm. Đây là một bộ sưu tập không có thứ tự trong đó các yếu tố được lưu trữ dưới dạng các khóa từ điển và số lượng của chúng được lưu trữ dưới dạng giá trị từ điển. Số lượng được phép là bất kỳ giá trị số nguyên nào bao gồm số không hoặc số âm. Lớp quầy tương tự như túi hoặc multiset trong các ngôn ngữ khác.Counter is a dict subclass for counting hashable objects. It is an unordered collection where elements are stored as dictionary keys and their counts are stored as dictionary values. Counts are allowed to be any integer value including zero or negative counts. The Counter class is similar to bags or multisets in other languages.

Hầu hết_Common [[n]] trả về một danh sách các yếu tố phổ biến nhất và số lượng của chúng từ số phổ biến nhất đến ít nhất. & nbsp;

Python3

>>> l = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4]
>>> print[search[l]]
[[43, [2, 6]], [9, [0]], [8, [7, 9]]]
2
>>> l = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4]
>>> print[search[l]]
[[43, [2, 6]], [9, [0]], [8, [7, 9]]]
3
>>> l = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4]
>>> print[search[l]]
[[43, [2, 6]], [9, [0]], [8, [7, 9]]]
4
>>> l = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4]
>>> print[search[l]]
[[43, [2, 6]], [9, [0]], [8, [7, 9]]]
5

>>> l = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4]
>>> print[search[l]]
[[43, [2, 6]], [9, [0]], [8, [7, 9]]]
6
>>> l = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4]
>>> print[search[l]]
[[43, [2, 6]], [9, [0]], [8, [7, 9]]]
7
>>> l = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4]
>>> print[search[l]]
[[43, [2, 6]], [9, [0]], [8, [7, 9]]]
8
>>> l = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4]
>>> print[search[l]]
[[43, [2, 6]], [9, [0]], [8, [7, 9]]]
9
>>> Fscore_list = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4, 43, 43, 43]
>>> result = search[Fscore_list]
>>> print["1st. %d on positions %s" % [result[0][0], result[0][1]]]
1st. 43 on positions [2, 6, 11, 12, 13]
>>> print["2nd. %d on positions %s" % [result[1][0], result[1][1]]]
2nd. 9 on positions [0]
>>> print["3rd. %d on positions %s" % [result[2][0], result[2][1]]]
3rd. 8 on positions [7, 9]
0
>>> Fscore_list = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4, 43, 43, 43]
>>> result = search[Fscore_list]
>>> print["1st. %d on positions %s" % [result[0][0], result[0][1]]]
1st. 43 on positions [2, 6, 11, 12, 13]
>>> print["2nd. %d on positions %s" % [result[1][0], result[1][1]]]
2nd. 9 on positions [0]
>>> print["3rd. %d on positions %s" % [result[2][0], result[2][1]]]
3rd. 8 on positions [7, 9]
1
>>> Fscore_list = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4, 43, 43, 43]
>>> result = search[Fscore_list]
>>> print["1st. %d on positions %s" % [result[0][0], result[0][1]]]
1st. 43 on positions [2, 6, 11, 12, 13]
>>> print["2nd. %d on positions %s" % [result[1][0], result[1][1]]]
2nd. 9 on positions [0]
>>> print["3rd. %d on positions %s" % [result[2][0], result[2][1]]]
3rd. 8 on positions [7, 9]
2223
>>> Fscore_list = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4, 43, 43, 43]
>>> result = search[Fscore_list]
>>> print["1st. %d on positions %s" % [result[0][0], result[0][1]]]
1st. 43 on positions [2, 6, 11, 12, 13]
>>> print["2nd. %d on positions %s" % [result[1][0], result[1][1]]]
2nd. 9 on positions [0]
>>> print["3rd. %d on positions %s" % [result[2][0], result[2][1]]]
3rd. 8 on positions [7, 9]
0
>>> Fscore_list = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4, 43, 43, 43]
>>> result = search[Fscore_list]
>>> print["1st. %d on positions %s" % [result[0][0], result[0][1]]]
1st. 43 on positions [2, 6, 11, 12, 13]
>>> print["2nd. %d on positions %s" % [result[1][0], result[1][1]]]
2nd. 9 on positions [0]
>>> print["3rd. %d on positions %s" % [result[2][0], result[2][1]]]
3rd. 8 on positions [7, 9]
5
>>> Fscore_list = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4, 43, 43, 43]
>>> result = search[Fscore_list]
>>> print["1st. %d on positions %s" % [result[0][0], result[0][1]]]
1st. 43 on positions [2, 6, 11, 12, 13]
>>> print["2nd. %d on positions %s" % [result[1][0], result[1][1]]]
2nd. 9 on positions [0]
>>> print["3rd. %d on positions %s" % [result[2][0], result[2][1]]]
3rd. 8 on positions [7, 9]
2227________________
>>> Fscore_list = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4, 43, 43, 43]
>>> result = search[Fscore_list]
>>> print["1st. %d on positions %s" % [result[0][0], result[0][1]]]
1st. 43 on positions [2, 6, 11, 12, 13]
>>> print["2nd. %d on positions %s" % [result[1][0], result[1][1]]]
2nd. 9 on positions [0]
>>> print["3rd. %d on positions %s" % [result[2][0], result[2][1]]]
3rd. 8 on positions [7, 9]
9
Input : my_dict = {'A': 67, 'B': 23, 'C': 45,
                   'D': 56, 'E': 12, 'F': 69} 

Output : {'F': 69, 'A': 67, 'D': 56}
0

Input : my_dict = {'A': 67, 'B': 23, 'C': 45,
                   'D': 56, 'E': 12, 'F': 69} 

Output : {'F': 69, 'A': 67, 'D': 56}
1
Input : my_dict = {'A': 67, 'B': 23, 'C': 45,
                   'D': 56, 'E': 12, 'F': 69} 

Output : {'F': 69, 'A': 67, 'D': 56}
2
>>> Fscore_list = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4, 43, 43, 43]
>>> result = search[Fscore_list]
>>> print["1st. %d on positions %s" % [result[0][0], result[0][1]]]
1st. 43 on positions [2, 6, 11, 12, 13]
>>> print["2nd. %d on positions %s" % [result[1][0], result[1][1]]]
2nd. 9 on positions [0]
>>> print["3rd. %d on positions %s" % [result[2][0], result[2][1]]]
3rd. 8 on positions [7, 9]
0
Input : my_dict = {'A': 67, 'B': 23, 'C': 45,
                   'D': 56, 'E': 12, 'F': 69} 

Output : {'F': 69, 'A': 67, 'D': 56}
4
>>> Fscore_list = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4, 43, 43, 43]
>>> result = search[Fscore_list]
>>> print["1st. %d on positions %s" % [result[0][0], result[0][1]]]
1st. 43 on positions [2, 6, 11, 12, 13]
>>> print["2nd. %d on positions %s" % [result[1][0], result[1][1]]]
2nd. 9 on positions [0]
>>> print["3rd. %d on positions %s" % [result[2][0], result[2][1]]]
3rd. 8 on positions [7, 9]
2
Input : my_dict = {'A': 67, 'B': 23, 'C': 45,
                   'D': 56, 'E': 12, 'F': 69} 

Output : {'F': 69, 'A': 67, 'D': 56}
6
>>> Fscore_list = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4, 43, 43, 43]
>>> result = search[Fscore_list]
>>> print["1st. %d on positions %s" % [result[0][0], result[0][1]]]
1st. 43 on positions [2, 6, 11, 12, 13]
>>> print["2nd. %d on positions %s" % [result[1][0], result[1][1]]]
2nd. 9 on positions [0]
>>> print["3rd. %d on positions %s" % [result[2][0], result[2][1]]]
3rd. 8 on positions [7, 9]
0
Input : my_dict = {'A': 67, 'B': 23, 'C': 45,
                   'D': 56, 'E': 12, 'F': 69} 

Output : {'F': 69, 'A': 67, 'D': 56}
8
>>> Fscore_list = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4, 43, 43, 43]
>>> result = search[Fscore_list]
>>> print["1st. %d on positions %s" % [result[0][0], result[0][1]]]
1st. 43 on positions [2, 6, 11, 12, 13]
>>> print["2nd. %d on positions %s" % [result[1][0], result[1][1]]]
2nd. 9 on positions [0]
>>> print["3rd. %d on positions %s" % [result[2][0], result[2][1]]]
3rd. 8 on positions [7, 9]
2
Initial Dictionary:
{'C': 45, 'B': 23, 'D': 56, 'A': 67, 'E': 12, 'F': 69} 

Dictionary with 3 highest values:
Keys: Values
F  : 69  
A  : 67  
D  : 56
0
>>> Fscore_list = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4, 43, 43, 43]
>>> result = search[Fscore_list]
>>> print["1st. %d on positions %s" % [result[0][0], result[0][1]]]
1st. 43 on positions [2, 6, 11, 12, 13]
>>> print["2nd. %d on positions %s" % [result[1][0], result[1][1]]]
2nd. 9 on positions [0]
>>> print["3rd. %d on positions %s" % [result[2][0], result[2][1]]]
3rd. 8 on positions [7, 9]
0
Initial Dictionary:
{'C': 45, 'B': 23, 'D': 56, 'A': 67, 'E': 12, 'F': 69} 

Dictionary with 3 highest values:
Keys: Values
F  : 69  
A  : 67  
D  : 56
2
Initial Dictionary:
{'C': 45, 'B': 23, 'D': 56, 'A': 67, 'E': 12, 'F': 69} 

Dictionary with 3 highest values:
Keys: Values
F  : 69  
A  : 67  
D  : 56
3

Initial Dictionary:
{'C': 45, 'B': 23, 'D': 56, 'A': 67, 'E': 12, 'F': 69} 

Dictionary with 3 highest values:
Keys: Values
F  : 69  
A  : 67  
D  : 56
4
>>> l = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4]
>>> print[search[l]]
[[43, [2, 6]], [9, [0]], [8, [7, 9]]]
7
Initial Dictionary:
{'C': 45, 'B': 23, 'D': 56, 'A': 67, 'E': 12, 'F': 69} 

Dictionary with 3 highest values:
Keys: Values
F  : 69  
A  : 67  
D  : 56
6

Initial Dictionary:
{'C': 45, 'B': 23, 'D': 56, 'A': 67, 'E': 12, 'F': 69} 

Dictionary with 3 highest values:
Keys: Values
F  : 69  
A  : 67  
D  : 56
7
>>> l = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4]
>>> print[search[l]]
[[43, [2, 6]], [9, [0]], [8, [7, 9]]]
7
Initial Dictionary:
{'C': 45, 'B': 23, 'D': 56, 'A': 67, 'E': 12, 'F': 69} 

Dictionary with 3 highest values:
Keys: Values
F  : 69  
A  : 67  
D  : 56
9
Initial Dictionary:
{'D': 56, 'E': 12, 'F': 69, 'C': 45, 'B': 23, 'A': 67} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56
0
Initial Dictionary:
{'D': 56, 'E': 12, 'F': 69, 'C': 45, 'B': 23, 'A': 67} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56
1

Initial Dictionary:
{'D': 56, 'E': 12, 'F': 69, 'C': 45, 'B': 23, 'A': 67} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56
2
Initial Dictionary:
{'D': 56, 'E': 12, 'F': 69, 'C': 45, 'B': 23, 'A': 67} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56
3
Initial Dictionary:
{'D': 56, 'E': 12, 'F': 69, 'C': 45, 'B': 23, 'A': 67} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56
4
Initial Dictionary:
{'D': 56, 'E': 12, 'F': 69, 'C': 45, 'B': 23, 'A': 67} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56
1

Initial Dictionary:
{'D': 56, 'E': 12, 'F': 69, 'C': 45, 'B': 23, 'A': 67} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56
2
Initial Dictionary:
{'D': 56, 'E': 12, 'F': 69, 'C': 45, 'B': 23, 'A': 67} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56
7
Initial Dictionary:
{'D': 56, 'E': 12, 'F': 69, 'C': 45, 'B': 23, 'A': 67} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56
8
Initial Dictionary:
{'D': 56, 'E': 12, 'F': 69, 'C': 45, 'B': 23, 'A': 67} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56
1

Initial Dictionary:
{'D': 56, 'E': 12, 'F': 69, 'C': 45, 'B': 23, 'A': 67} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56
2
Initial Dictionary:
{'D': 56, 'E': 12, 'F': 69, 'C': 45, 'B': 23, 'A': 67} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56
3
Initial Dictionary:
{'A': 67, 'B': 23, 'C': 45, 'D': 56, 'E': 12, 'F': 69} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56
2
Initial Dictionary:
{'D': 56, 'E': 12, 'F': 69, 'C': 45, 'B': 23, 'A': 67} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56
1

Initial Dictionary:
{'D': 56, 'E': 12, 'F': 69, 'C': 45, 'B': 23, 'A': 67} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56
2
Initial Dictionary:
{'D': 56, 'E': 12, 'F': 69, 'C': 45, 'B': 23, 'A': 67} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56
3
Initial Dictionary:
{'A': 67, 'B': 23, 'C': 45, 'D': 56, 'E': 12, 'F': 69} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56
6
Initial Dictionary:
{'D': 56, 'E': 12, 'F': 69, 'C': 45, 'B': 23, 'A': 67} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56
1

Initial Dictionary:
{'A': 67, 'B': 23, 'C': 45, 'D': 56, 'E': 12, 'F': 69} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56
8
Initial Dictionary:
{'A': 67, 'B': 23, 'C': 45, 'D': 56, 'E': 12, 'F': 69} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56
9num=30 num=31

num=32

Initial Dictionary:
{'D': 56, 'E': 12, 'F': 69, 'C': 45, 'B': 23, 'A': 67} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56
2num=34num=35num=36num=37num=38num=39num=36dict1
Initial Dictionary:
{'D': 56, 'E': 12, 'F': 69, 'C': 45, 'B': 23, 'A': 67} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56
1

Output:

Initial Dictionary:
{'C': 45, 'B': 23, 'D': 56, 'A': 67, 'E': 12, 'F': 69} 

Dictionary with 3 highest values:
Keys: Values
F  : 69  
A  : 67  
D  : 56

Phương pháp #2: Sử dụng Heapq.nlargest [] Using heapq.nlargest[]

Python3

>>> l = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4]
>>> print[search[l]]
[[43, [2, 6]], [9, [0]], [8, [7, 9]]]
2 dict4
>>> l = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4]
>>> print[search[l]]
[[43, [2, 6]], [9, [0]], [8, [7, 9]]]
4 dict6

>>> l = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4]
>>> print[search[l]]
[[43, [2, 6]], [9, [0]], [8, [7, 9]]]
6
>>> l = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4]
>>> print[search[l]]
[[43, [2, 6]], [9, [0]], [8, [7, 9]]]
7
>>> l = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4]
>>> print[search[l]]
[[43, [2, 6]], [9, [0]], [8, [7, 9]]]
8
>>> l = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4]
>>> print[search[l]]
[[43, [2, 6]], [9, [0]], [8, [7, 9]]]
9
>>> Fscore_list = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4, 43, 43, 43]
>>> result = search[Fscore_list]
>>> print["1st. %d on positions %s" % [result[0][0], result[0][1]]]
1st. 43 on positions [2, 6, 11, 12, 13]
>>> print["2nd. %d on positions %s" % [result[1][0], result[1][1]]]
2nd. 9 on positions [0]
>>> print["3rd. %d on positions %s" % [result[2][0], result[2][1]]]
3rd. 8 on positions [7, 9]
0
>>> Fscore_list = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4, 43, 43, 43]
>>> result = search[Fscore_list]
>>> print["1st. %d on positions %s" % [result[0][0], result[0][1]]]
1st. 43 on positions [2, 6, 11, 12, 13]
>>> print["2nd. %d on positions %s" % [result[1][0], result[1][1]]]
2nd. 9 on positions [0]
>>> print["3rd. %d on positions %s" % [result[2][0], result[2][1]]]
3rd. 8 on positions [7, 9]
1
>>> Fscore_list = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4, 43, 43, 43]
>>> result = search[Fscore_list]
>>> print["1st. %d on positions %s" % [result[0][0], result[0][1]]]
1st. 43 on positions [2, 6, 11, 12, 13]
>>> print["2nd. %d on positions %s" % [result[1][0], result[1][1]]]
2nd. 9 on positions [0]
>>> print["3rd. %d on positions %s" % [result[2][0], result[2][1]]]
3rd. 8 on positions [7, 9]
2223
>>> Fscore_list = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4, 43, 43, 43]
>>> result = search[Fscore_list]
>>> print["1st. %d on positions %s" % [result[0][0], result[0][1]]]
1st. 43 on positions [2, 6, 11, 12, 13]
>>> print["2nd. %d on positions %s" % [result[1][0], result[1][1]]]
2nd. 9 on positions [0]
>>> print["3rd. %d on positions %s" % [result[2][0], result[2][1]]]
3rd. 8 on positions [7, 9]
0
>>> Fscore_list = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4, 43, 43, 43]
>>> result = search[Fscore_list]
>>> print["1st. %d on positions %s" % [result[0][0], result[0][1]]]
1st. 43 on positions [2, 6, 11, 12, 13]
>>> print["2nd. %d on positions %s" % [result[1][0], result[1][1]]]
2nd. 9 on positions [0]
>>> print["3rd. %d on positions %s" % [result[2][0], result[2][1]]]
3rd. 8 on positions [7, 9]
5
>>> Fscore_list = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4, 43, 43, 43]
>>> result = search[Fscore_list]
>>> print["1st. %d on positions %s" % [result[0][0], result[0][1]]]
1st. 43 on positions [2, 6, 11, 12, 13]
>>> print["2nd. %d on positions %s" % [result[1][0], result[1][1]]]
2nd. 9 on positions [0]
>>> print["3rd. %d on positions %s" % [result[2][0], result[2][1]]]
3rd. 8 on positions [7, 9]
2227________________
>>> Fscore_list = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4, 43, 43, 43]
>>> result = search[Fscore_list]
>>> print["1st. %d on positions %s" % [result[0][0], result[0][1]]]
1st. 43 on positions [2, 6, 11, 12, 13]
>>> print["2nd. %d on positions %s" % [result[1][0], result[1][1]]]
2nd. 9 on positions [0]
>>> print["3rd. %d on positions %s" % [result[2][0], result[2][1]]]
3rd. 8 on positions [7, 9]
9
Input : my_dict = {'A': 67, 'B': 23, 'C': 45,
                   'D': 56, 'E': 12, 'F': 69} 

Output : {'F': 69, 'A': 67, 'D': 56}
0

Input : my_dict = {'A': 67, 'B': 23, 'C': 45,
                   'D': 56, 'E': 12, 'F': 69} 

Output : {'F': 69, 'A': 67, 'D': 56}
1
Input : my_dict = {'A': 67, 'B': 23, 'C': 45,
                   'D': 56, 'E': 12, 'F': 69} 

Output : {'F': 69, 'A': 67, 'D': 56}
2
>>> Fscore_list = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4, 43, 43, 43]
>>> result = search[Fscore_list]
>>> print["1st. %d on positions %s" % [result[0][0], result[0][1]]]
1st. 43 on positions [2, 6, 11, 12, 13]
>>> print["2nd. %d on positions %s" % [result[1][0], result[1][1]]]
2nd. 9 on positions [0]
>>> print["3rd. %d on positions %s" % [result[2][0], result[2][1]]]
3rd. 8 on positions [7, 9]
0
Input : my_dict = {'A': 67, 'B': 23, 'C': 45,
                   'D': 56, 'E': 12, 'F': 69} 

Output : {'F': 69, 'A': 67, 'D': 56}
4
>>> Fscore_list = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4, 43, 43, 43]
>>> result = search[Fscore_list]
>>> print["1st. %d on positions %s" % [result[0][0], result[0][1]]]
1st. 43 on positions [2, 6, 11, 12, 13]
>>> print["2nd. %d on positions %s" % [result[1][0], result[1][1]]]
2nd. 9 on positions [0]
>>> print["3rd. %d on positions %s" % [result[2][0], result[2][1]]]
3rd. 8 on positions [7, 9]
2
Input : my_dict = {'A': 67, 'B': 23, 'C': 45,
                   'D': 56, 'E': 12, 'F': 69} 

Output : {'F': 69, 'A': 67, 'D': 56}
6
>>> Fscore_list = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4, 43, 43, 43]
>>> result = search[Fscore_list]
>>> print["1st. %d on positions %s" % [result[0][0], result[0][1]]]
1st. 43 on positions [2, 6, 11, 12, 13]
>>> print["2nd. %d on positions %s" % [result[1][0], result[1][1]]]
2nd. 9 on positions [0]
>>> print["3rd. %d on positions %s" % [result[2][0], result[2][1]]]
3rd. 8 on positions [7, 9]
0
Input : my_dict = {'A': 67, 'B': 23, 'C': 45,
                   'D': 56, 'E': 12, 'F': 69} 

Output : {'F': 69, 'A': 67, 'D': 56}
8
>>> Fscore_list = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4, 43, 43, 43]
>>> result = search[Fscore_list]
>>> print["1st. %d on positions %s" % [result[0][0], result[0][1]]]
1st. 43 on positions [2, 6, 11, 12, 13]
>>> print["2nd. %d on positions %s" % [result[1][0], result[1][1]]]
2nd. 9 on positions [0]
>>> print["3rd. %d on positions %s" % [result[2][0], result[2][1]]]
3rd. 8 on positions [7, 9]
2
Initial Dictionary:
{'C': 45, 'B': 23, 'D': 56, 'A': 67, 'E': 12, 'F': 69} 

Dictionary with 3 highest values:
Keys: Values
F  : 69  
A  : 67  
D  : 56
0
>>> Fscore_list = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4, 43, 43, 43]
>>> result = search[Fscore_list]
>>> print["1st. %d on positions %s" % [result[0][0], result[0][1]]]
1st. 43 on positions [2, 6, 11, 12, 13]
>>> print["2nd. %d on positions %s" % [result[1][0], result[1][1]]]
2nd. 9 on positions [0]
>>> print["3rd. %d on positions %s" % [result[2][0], result[2][1]]]
3rd. 8 on positions [7, 9]
0
Initial Dictionary:
{'C': 45, 'B': 23, 'D': 56, 'A': 67, 'E': 12, 'F': 69} 

Dictionary with 3 highest values:
Keys: Values
F  : 69  
A  : 67  
D  : 56
2
Initial Dictionary:
{'C': 45, 'B': 23, 'D': 56, 'A': 67, 'E': 12, 'F': 69} 

Dictionary with 3 highest values:
Keys: Values
F  : 69  
A  : 67  
D  : 56
3

Initial Dictionary:
{'D': 56, 'E': 12, 'F': 69, 'C': 45, 'B': 23, 'A': 67} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56
2
Initial Dictionary:
{'D': 56, 'E': 12, 'F': 69, 'C': 45, 'B': 23, 'A': 67} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56
3
Initial Dictionary:
{'D': 56, 'E': 12, 'F': 69, 'C': 45, 'B': 23, 'A': 67} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56
4
Initial Dictionary:
{'D': 56, 'E': 12, 'F': 69, 'C': 45, 'B': 23, 'A': 67} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56
1

Initial Dictionary:
{'D': 56, 'E': 12, 'F': 69, 'C': 45, 'B': 23, 'A': 67} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56
2
Initial Dictionary:
{'D': 56, 'E': 12, 'F': 69, 'C': 45, 'B': 23, 'A': 67} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56
7
Initial Dictionary:
{'D': 56, 'E': 12, 'F': 69, 'C': 45, 'B': 23, 'A': 67} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56
8
Initial Dictionary:
{'D': 56, 'E': 12, 'F': 69, 'C': 45, 'B': 23, 'A': 67} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56
1

>>> l = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4]
>>> print[search[l]]
[[43, [2, 6]], [9, [0]], [8, [7, 9]]]
23
>>> l = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4]
>>> print[search[l]]
[[43, [2, 6]], [9, [0]], [8, [7, 9]]]
7
>>> l = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4]
>>> print[search[l]]
[[43, [2, 6]], [9, [0]], [8, [7, 9]]]
25
Initial Dictionary:
{'D': 56, 'E': 12, 'F': 69, 'C': 45, 'B': 23, 'A': 67} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56
0
>>> l = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4]
>>> print[search[l]]
[[43, [2, 6]], [9, [0]], [8, [7, 9]]]
27__17
>>> l = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4]
>>> print[search[l]]
[[43, [2, 6]], [9, [0]], [8, [7, 9]]]
29

Initial Dictionary:
{'D': 56, 'E': 12, 'F': 69, 'C': 45, 'B': 23, 'A': 67} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56
2
Initial Dictionary:
{'D': 56, 'E': 12, 'F': 69, 'C': 45, 'B': 23, 'A': 67} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56
3
Initial Dictionary:
{'A': 67, 'B': 23, 'C': 45, 'D': 56, 'E': 12, 'F': 69} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56
2
Initial Dictionary:
{'D': 56, 'E': 12, 'F': 69, 'C': 45, 'B': 23, 'A': 67} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56
1

Initial Dictionary:
{'D': 56, 'E': 12, 'F': 69, 'C': 45, 'B': 23, 'A': 67} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56
2
Initial Dictionary:
{'D': 56, 'E': 12, 'F': 69, 'C': 45, 'B': 23, 'A': 67} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56
3
Initial Dictionary:
{'A': 67, 'B': 23, 'C': 45, 'D': 56, 'E': 12, 'F': 69} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56
6
Initial Dictionary:
{'D': 56, 'E': 12, 'F': 69, 'C': 45, 'B': 23, 'A': 67} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56
1

Initial Dictionary:
{'A': 67, 'B': 23, 'C': 45, 'D': 56, 'E': 12, 'F': 69} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56
8
>>> l = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4]
>>> print[search[l]]
[[43, [2, 6]], [9, [0]], [8, [7, 9]]]
39num=30
>>> l = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4]
>>> print[search[l]]
[[43, [2, 6]], [9, [0]], [8, [7, 9]]]
41

num=32

Initial Dictionary:
{'D': 56, 'E': 12, 'F': 69, 'C': 45, 'B': 23, 'A': 67} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56
2
>>> l = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4]
>>> print[search[l]]
[[43, [2, 6]], [9, [0]], [8, [7, 9]]]
44
>>> l = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4]
>>> print[search[l]]
[[43, [2, 6]], [9, [0]], [8, [7, 9]]]
45
>>> l = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4]
>>> print[search[l]]
[[43, [2, 6]], [9, [0]], [8, [7, 9]]]
46

Output:

Initial Dictionary:
{'D': 56, 'E': 12, 'F': 69, 'C': 45, 'B': 23, 'A': 67} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56

Phương pháp số 3: Sử dụng các phương thức Keys [], Giá trị [] và Sắp xếp []

Python3

>>> l = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4]
>>> print[search[l]]
[[43, [2, 6]], [9, [0]], [8, [7, 9]]]
6
>>> l = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4]
>>> print[search[l]]
[[43, [2, 6]], [9, [0]], [8, [7, 9]]]
7
>>> l = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4]
>>> print[search[l]]
[[43, [2, 6]], [9, [0]], [8, [7, 9]]]
8
>>> l = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4]
>>> print[search[l]]
[[43, [2, 6]], [9, [0]], [8, [7, 9]]]
9
>>> Fscore_list = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4, 43, 43, 43]
>>> result = search[Fscore_list]
>>> print["1st. %d on positions %s" % [result[0][0], result[0][1]]]
1st. 43 on positions [2, 6, 11, 12, 13]
>>> print["2nd. %d on positions %s" % [result[1][0], result[1][1]]]
2nd. 9 on positions [0]
>>> print["3rd. %d on positions %s" % [result[2][0], result[2][1]]]
3rd. 8 on positions [7, 9]
0
>>> Fscore_list = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4, 43, 43, 43]
>>> result = search[Fscore_list]
>>> print["1st. %d on positions %s" % [result[0][0], result[0][1]]]
1st. 43 on positions [2, 6, 11, 12, 13]
>>> print["2nd. %d on positions %s" % [result[1][0], result[1][1]]]
2nd. 9 on positions [0]
>>> print["3rd. %d on positions %s" % [result[2][0], result[2][1]]]
3rd. 8 on positions [7, 9]
1
>>> Fscore_list = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4, 43, 43, 43]
>>> result = search[Fscore_list]
>>> print["1st. %d on positions %s" % [result[0][0], result[0][1]]]
1st. 43 on positions [2, 6, 11, 12, 13]
>>> print["2nd. %d on positions %s" % [result[1][0], result[1][1]]]
2nd. 9 on positions [0]
>>> print["3rd. %d on positions %s" % [result[2][0], result[2][1]]]
3rd. 8 on positions [7, 9]
2223
>>> Fscore_list = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4, 43, 43, 43]
>>> result = search[Fscore_list]
>>> print["1st. %d on positions %s" % [result[0][0], result[0][1]]]
1st. 43 on positions [2, 6, 11, 12, 13]
>>> print["2nd. %d on positions %s" % [result[1][0], result[1][1]]]
2nd. 9 on positions [0]
>>> print["3rd. %d on positions %s" % [result[2][0], result[2][1]]]
3rd. 8 on positions [7, 9]
0
>>> Fscore_list = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4, 43, 43, 43]
>>> result = search[Fscore_list]
>>> print["1st. %d on positions %s" % [result[0][0], result[0][1]]]
1st. 43 on positions [2, 6, 11, 12, 13]
>>> print["2nd. %d on positions %s" % [result[1][0], result[1][1]]]
2nd. 9 on positions [0]
>>> print["3rd. %d on positions %s" % [result[2][0], result[2][1]]]
3rd. 8 on positions [7, 9]
5
>>> Fscore_list = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4, 43, 43, 43]
>>> result = search[Fscore_list]
>>> print["1st. %d on positions %s" % [result[0][0], result[0][1]]]
1st. 43 on positions [2, 6, 11, 12, 13]
>>> print["2nd. %d on positions %s" % [result[1][0], result[1][1]]]
2nd. 9 on positions [0]
>>> print["3rd. %d on positions %s" % [result[2][0], result[2][1]]]
3rd. 8 on positions [7, 9]
2227________________
>>> Fscore_list = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4, 43, 43, 43]
>>> result = search[Fscore_list]
>>> print["1st. %d on positions %s" % [result[0][0], result[0][1]]]
1st. 43 on positions [2, 6, 11, 12, 13]
>>> print["2nd. %d on positions %s" % [result[1][0], result[1][1]]]
2nd. 9 on positions [0]
>>> print["3rd. %d on positions %s" % [result[2][0], result[2][1]]]
3rd. 8 on positions [7, 9]
9
Input : my_dict = {'A': 67, 'B': 23, 'C': 45,
                   'D': 56, 'E': 12, 'F': 69} 

Output : {'F': 69, 'A': 67, 'D': 56}
0

>>> l = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4]
>>> print[search[l]]
[[43, [2, 6]], [9, [0]], [8, [7, 9]]]
62
Input : my_dict = {'A': 67, 'B': 23, 'C': 45,
                   'D': 56, 'E': 12, 'F': 69} 

Output : {'F': 69, 'A': 67, 'D': 56}
2
>>> Fscore_list = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4, 43, 43, 43]
>>> result = search[Fscore_list]
>>> print["1st. %d on positions %s" % [result[0][0], result[0][1]]]
1st. 43 on positions [2, 6, 11, 12, 13]
>>> print["2nd. %d on positions %s" % [result[1][0], result[1][1]]]
2nd. 9 on positions [0]
>>> print["3rd. %d on positions %s" % [result[2][0], result[2][1]]]
3rd. 8 on positions [7, 9]
0
Input : my_dict = {'A': 67, 'B': 23, 'C': 45,
                   'D': 56, 'E': 12, 'F': 69} 

Output : {'F': 69, 'A': 67, 'D': 56}
4__22222222222222

Initial Dictionary:
{'D': 56, 'E': 12, 'F': 69, 'C': 45, 'B': 23, 'A': 67} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56
2
Initial Dictionary:
{'D': 56, 'E': 12, 'F': 69, 'C': 45, 'B': 23, 'A': 67} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56
3
Initial Dictionary:
{'D': 56, 'E': 12, 'F': 69, 'C': 45, 'B': 23, 'A': 67} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56
4
Initial Dictionary:
{'D': 56, 'E': 12, 'F': 69, 'C': 45, 'B': 23, 'A': 67} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56
1

Initial Dictionary:
{'D': 56, 'E': 12, 'F': 69, 'C': 45, 'B': 23, 'A': 67} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56
2
Initial Dictionary:
{'D': 56, 'E': 12, 'F': 69, 'C': 45, 'B': 23, 'A': 67} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56
7
Initial Dictionary:
{'D': 56, 'E': 12, 'F': 69, 'C': 45, 'B': 23, 'A': 67} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56
8
Initial Dictionary:
{'D': 56, 'E': 12, 'F': 69, 'C': 45, 'B': 23, 'A': 67} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56
1

Initial Dictionary:
{'D': 56, 'E': 12, 'F': 69, 'C': 45, 'B': 23, 'A': 67} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56
2
Initial Dictionary:
{'D': 56, 'E': 12, 'F': 69, 'C': 45, 'B': 23, 'A': 67} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56
3
Initial Dictionary:
{'A': 67, 'B': 23, 'C': 45, 'D': 56, 'E': 12, 'F': 69} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56
2
Initial Dictionary:
{'D': 56, 'E': 12, 'F': 69, 'C': 45, 'B': 23, 'A': 67} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56
1

Initial Dictionary:
{'D': 56, 'E': 12, 'F': 69, 'C': 45, 'B': 23, 'A': 67} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56
2
Initial Dictionary:
{'D': 56, 'E': 12, 'F': 69, 'C': 45, 'B': 23, 'A': 67} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56
3
Initial Dictionary:
{'A': 67, 'B': 23, 'C': 45, 'D': 56, 'E': 12, 'F': 69} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56
6
Initial Dictionary:
{'D': 56, 'E': 12, 'F': 69, 'C': 45, 'B': 23, 'A': 67} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56
1

>>> l = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4]
>>> print[search[l]]
[[43, [2, 6]], [9, [0]], [8, [7, 9]]]
91
>>> l = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4]
>>> print[search[l]]
[[43, [2, 6]], [9, [0]], [8, [7, 9]]]
7list
>>> l = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4]
>>> print[search[l]]
[[43, [2, 6]], [9, [0]], [8, [7, 9]]]
94

>>> l = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4]
>>> print[search[l]]
[[43, [2, 6]], [9, [0]], [8, [7, 9]]]
95
>>> l = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4]
>>> print[search[l]]
[[43, [2, 6]], [9, [0]], [8, [7, 9]]]
7dict
>>> l = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4]
>>> print[search[l]]
[[43, [2, 6]], [9, [0]], [8, [7, 9]]]
98

>>> l = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4]
>>> print[search[l]]
[[43, [2, 6]], [9, [0]], [8, [7, 9]]]
99
>>> l = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4]
>>> print[search[l]]
[[43, [2, 6]], [9, [0]], [8, [7, 9]]]
7
>>> Fscore_list = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4, 43, 43, 43]
>>> result = search[Fscore_list]
>>> print["1st. %d on positions %s" % [result[0][0], result[0][1]]]
1st. 43 on positions [2, 6, 11, 12, 13]
>>> print["2nd. %d on positions %s" % [result[1][0], result[1][1]]]
2nd. 9 on positions [0]
>>> print["3rd. %d on positions %s" % [result[2][0], result[2][1]]]
3rd. 8 on positions [7, 9]
01
Initial Dictionary:
{'D': 56, 'E': 12, 'F': 69, 'C': 45, 'B': 23, 'A': 67} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56
1

>>> l = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4]
>>> print[search[l]]
[[43, [2, 6]], [9, [0]], [8, [7, 9]]]
91
>>> l = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4]
>>> print[search[l]]
[[43, [2, 6]], [9, [0]], [8, [7, 9]]]
7
>>> Fscore_list = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4, 43, 43, 43]
>>> result = search[Fscore_list]
>>> print["1st. %d on positions %s" % [result[0][0], result[0][1]]]
1st. 43 on positions [2, 6, 11, 12, 13]
>>> print["2nd. %d on positions %s" % [result[1][0], result[1][1]]]
2nd. 9 on positions [0]
>>> print["3rd. %d on positions %s" % [result[2][0], result[2][1]]]
3rd. 8 on positions [7, 9]
05
Initial Dictionary:
{'D': 56, 'E': 12, 'F': 69, 'C': 45, 'B': 23, 'A': 67} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56
0
>>> Fscore_list = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4, 43, 43, 43]
>>> result = search[Fscore_list]
>>> print["1st. %d on positions %s" % [result[0][0], result[0][1]]]
1st. 43 on positions [2, 6, 11, 12, 13]
>>> print["2nd. %d on positions %s" % [result[1][0], result[1][1]]]
2nd. 9 on positions [0]
>>> print["3rd. %d on positions %s" % [result[2][0], result[2][1]]]
3rd. 8 on positions [7, 9]
07

Initial Dictionary:
{'A': 67, 'B': 23, 'C': 45, 'D': 56, 'E': 12, 'F': 69} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56
8
Initial Dictionary:
{'A': 67, 'B': 23, 'C': 45, 'D': 56, 'E': 12, 'F': 69} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56
9num=30
>>> Fscore_list = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4, 43, 43, 43]
>>> result = search[Fscore_list]
>>> print["1st. %d on positions %s" % [result[0][0], result[0][1]]]
1st. 43 on positions [2, 6, 11, 12, 13]
>>> print["2nd. %d on positions %s" % [result[1][0], result[1][1]]]
2nd. 9 on positions [0]
>>> print["3rd. %d on positions %s" % [result[2][0], result[2][1]]]
3rd. 8 on positions [7, 9]
11

num=32

Initial Dictionary:
{'A': 67, 'B': 23, 'C': 45, 'D': 56, 'E': 12, 'F': 69} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56
8
>>> Fscore_list = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4, 43, 43, 43]
>>> result = search[Fscore_list]
>>> print["1st. %d on positions %s" % [result[0][0], result[0][1]]]
1st. 43 on positions [2, 6, 11, 12, 13]
>>> print["2nd. %d on positions %s" % [result[1][0], result[1][1]]]
2nd. 9 on positions [0]
>>> print["3rd. %d on positions %s" % [result[2][0], result[2][1]]]
3rd. 8 on positions [7, 9]
14num=30
>>> Fscore_list = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4, 43, 43, 43]
>>> result = search[Fscore_list]
>>> print["1st. %d on positions %s" % [result[0][0], result[0][1]]]
1st. 43 on positions [2, 6, 11, 12, 13]
>>> print["2nd. %d on positions %s" % [result[1][0], result[1][1]]]
2nd. 9 on positions [0]
>>> print["3rd. %d on positions %s" % [result[2][0], result[2][1]]]
3rd. 8 on positions [7, 9]
16

>>> l = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4]
>>> print[search[l]]
[[43, [2, 6]], [9, [0]], [8, [7, 9]]]
62
>>> Fscore_list = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4, 43, 43, 43]
>>> result = search[Fscore_list]
>>> print["1st. %d on positions %s" % [result[0][0], result[0][1]]]
1st. 43 on positions [2, 6, 11, 12, 13]
>>> print["2nd. %d on positions %s" % [result[1][0], result[1][1]]]
2nd. 9 on positions [0]
>>> print["3rd. %d on positions %s" % [result[2][0], result[2][1]]]
3rd. 8 on positions [7, 9]
18
>>> Fscore_list = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4, 43, 43, 43]
>>> result = search[Fscore_list]
>>> print["1st. %d on positions %s" % [result[0][0], result[0][1]]]
1st. 43 on positions [2, 6, 11, 12, 13]
>>> print["2nd. %d on positions %s" % [result[1][0], result[1][1]]]
2nd. 9 on positions [0]
>>> print["3rd. %d on positions %s" % [result[2][0], result[2][1]]]
3rd. 8 on positions [7, 9]
19
>>> l = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4]
>>> print[search[l]]
[[43, [2, 6]], [9, [0]], [8, [7, 9]]]
7
>>> l = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4]
>>> print[search[l]]
[[43, [2, 6]], [9, [0]], [8, [7, 9]]]
7
>>> Fscore_list = [9, 7, 43, 2, 4, 7, 43, 8, 5, 8, 4, 43, 43, 43]
>>> result = search[Fscore_list]
>>> print["1st. %d on positions %s" % [result[0][0], result[0][1]]]
1st. 43 on positions [2, 6, 11, 12, 13]
>>> print["2nd. %d on positions %s" % [result[1][0], result[1][1]]]
2nd. 9 on positions [0]
>>> print["3rd. %d on positions %s" % [result[2][0], result[2][1]]]
3rd. 8 on positions [7, 9]
22

Các

Đầu ra

Initial Dictionary:
{'A': 67, 'B': 23, 'C': 45, 'D': 56, 'E': 12, 'F': 69} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56


Bài Viết Liên Quan

Chủ Đề