Question

exchange rate = {'0.0045': 3, '0.0160': 2, '-0.0028': 6, '-0.0157': 1, '-0.0443': 1, '-0.0232': 1, '-0.0065':...

exchange rate = {'0.0045': 3, '0.0160': 2, '-0.0028': 6, '-0.0157': 1, '-0.0443': 1, '-0.0232': 1, '-0.0065': 9, '-0.0080': 12, '0.0052': 1, '-0.0052': 3, '-0.0283': 1, '-0.0087': 1, '-0.0020': 9, '-0.0290': 2, '0.0180': 3, '0.0030': 15, '-0.0170': 2, '0.0000': 63, '-0.0185': 3, '-0.0055': 5, '0.0148': 1, '-0.0053': 1, '0.0265': 1, '0.0010': 22, '-0.0015': 5, '0.0137': 1, '-0.0137': 2, '-0.0023': 2, '0.0008': 10, '0.0055': 6, '-0.0025': 6, '-0.0125': 2, '0.0040': 14, '0.0260': 1, '0.0070': 8, '0.0210': 1, '-0.0070': 8, '0.0395': 1, '-0.0040': 14, '-0.0255': 2, '0.0037': 3, '0.0060': 7, '0.0025': 7, '0.0095': 2, '-0.0100': 2, '-0.0085': 6, '-0.0248': 1, '0.0028': 8, '-0.0005': 7, '-0.0113': 1, '0.0418': 1, '-0.0075': 4, '0.0130': 4, '-0.0165': 1, '0.0020': 16, '-0.0090': 7, '0.0190': 4, '-0.0245': 1, '0.0240': 2, '-0.0225': 1, '-0.0230': 1, '-0.0295': 1, '-0.0330': 1, '-0.0139': 1, '0.0104': 1, '0.0032': 7, '-0.0117': 1, '-0.0035': 8, '-0.0010': 18, '0.0285': 1, '0.0012': 7, '-0.0202': 1, '-0.0098': 1, '0.0195': 1, '0.0075': 3, '0.0015': 8, '0.0005': 5, '-0.0130': 4, '0.0115': 1, '0.0245': 2, '0.0175': 1, '0.0155': 1, '0.0120': 3, '0.0185': 1, '-0.0078': 3, '0.0023': 2, '0.0340': 1, '-0.0105': 5, '0.0140': 2, '-0.0060': 9, '0.0125': 3, '0.0262': 1, '0.0143': 1, '-0.0120': 3, '-0.0380': 1, '-0.0095': 4, '0.0135': 2, '-0.0045': 6, '0.0100': 8, '0.0145': 2, '-0.0140': 6, '-0.0200': 1, '-0.0030': 11, '0.0035': 6, '-0.0175': 1, '0.0105': 3, '0.0080': 10, '0.0165': 3, '0.0050': 16, '0.0230': 1, '-0.0050': 3, '0.0170': 2, '-0.0110': 2, '-0.0115': 3, '0.0255': 1, '0.0300': 1, '0.0110': 6, '0.0065': 3, '-0.0205': 1, '-0.0145': 2, '-0.0150': 2, '0.0085': 1, '0.0090': 3, '-0.0022': 7, '-0.0068': 5, '-0.0128': 1, '0.0073': 1, '0.0013': 3, '0.0044': 8, '0.0081': 1, '-0.0017': 1, '-0.0061': 1, '0.0088': 1, '-0.0041': 3, '-0.0044': 8, '0.0076': 4, '0.0102': 2, '0.0043': 1, '-0.0007': 2, '-0.0042': 6, '0.0011': 2, '0.0029': 1, '-0.0049': 2, '-0.0046': 9, '-0.0009': 2, '-0.0011': 1, '-0.0101': 2, '0.0022': 3, '0.0058': 2, '-0.0047': 1, '0.0067': 1, '0.0092': 4, '-0.0002': 13, '0.0041': 1, '0.0089': 1, '-0.0021': 1, '0.0006': 11, '-0.0036': 8, '0.0024': 8, '-0.0059': 1, '0.0068': 1, '-0.0260': 1, '0.0062': 3, '0.0064': 2, '0.0004': 16, '0.0048': 3, '0.0086': 1, '0.0096': 3, '-0.0074': 3, '0.0042': 8, '0.0122': 1, '0.0014': 7, '0.0072': 2, '-0.0146': 1, '-0.0048': 6, '-0.0012': 8, '0.0094': 2, '0.0009': 2, '-0.0004': 10, '-0.0038': 6, '0.0034': 6, '0.0016': 12, '-0.0016': 6, '0.0056': 5, '-0.0084': 2, '-0.0026': 6, '-0.0006': 8, '0.0066': 3, '-0.0094': 3, '-0.0014': 8, '0.0019': 1, '0.0101': 1, '0.0186': 1, '0.0084': 1, '-0.0062': 1, '-0.0086': 2, '0.0002': 8, '-0.0072': 2, '0.0057': 2, '0.0033': 1, '-0.0033': 1, '0.0017': 1, '0.0026': 9, '-0.0032': 5, '0.0018': 9, '0.0054': 4, '-0.0155': 1, '0.0074': 3, '0.0194': 1, '0.0202': 1, '-0.0172': 1, '0.0036': 7, '-0.0092': 2, '0.0071': 1, '-0.0186': 1, '0.0162': 1, '-0.0226': 1, '-0.0154': 1, '-0.0066': 3, '-0.0112': 1, '-0.0124': 2, '-0.0106': 4, '0.0027': 1, '0.0082': 2, '-0.0148': 4, '-0.0176': 1, '-0.0024': 4, '-0.0058': 1, '-0.0018': 11, '0.0284': 1, '-0.0195': 1, '-0.0316': 1, '0.0134': 2, '-0.0108': 1, '-0.0136': 1, '-0.0034': 3, '0.0038': 6, '-0.0003': 2, '0.0256': 1, '-0.0073': 1, '-0.0054': 6, '0.0007': 1, '-0.0187': 1, '-0.0118': 1, '-0.0280': 1, '0.0174': 1, '-0.0008': 4, '0.0078': 3, '0.0278': 1, '0.0141': 1, '-0.0138': 2, '0.0091': 1, '0.0136': 1, '-0.0126': 1, '-0.0082': 1, '0.0046': 3, '-0.0203': 1, '-0.0116': 1, '-0.0179': 1, '0.0192': 2, '-0.0064': 2, '-0.0056': 1, '-0.0220': 1, '-0.0134': 1, '0.0114': 1, '-0.0152': 1, '-0.0076': 1, '0.0172': 1, '-0.0001': 1, '-0.0029': 1, '-0.0158': 1}

def most_common_rate_change(d):

'''(dict of {float:int}) -> list of float

Given d where keys are exchange rate changes and values are the number of occurrences of each exchange rate change, return the exchange rate changes that occur the most frequently. Note: there could be multiple exchange rate changes that occur most frequently.

'''

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Please find the required python2.7 script that calculates the highest occurrence values as the following:

#==============================================================================

# Original Dictionary

key_value={'0.0045': 3, '0.0160': 2, '-0.0028': 6, '-0.0157': 1, '-0.0443': 1, '-0.0232': 1, '-0.0065': 9, '-0.0080': 12, '0.0052': 1, '-0.0052': 3, '-0.0283': 1, '-0.0087': 1, '-0.0020': 9, '-0.0290': 2, '0.0180': 3, '0.0030': 15, '-0.0170': 2, '0.0000': 63, '-0.0185': 3, '-0.0055': 5, '0.0148': 1, '-0.0053': 1, '0.0265': 1, '0.0010': 22, '-0.0015': 5, '0.0137': 1, '-0.0137': 2, '-0.0023': 2, '0.0008': 10, '0.0055': 6, '-0.0025': 6, '-0.0125': 2, '0.0040': 14, '0.0260': 1, '0.0070': 8, '0.0210': 1, '-0.0070': 8, '0.0395': 1, '-0.0040': 14, '-0.0255': 2, '0.0037': 3, '0.0060': 7, '0.0025': 7, '0.0095': 2, '-0.0100': 2, '-0.0085': 6, '-0.0248': 1, '0.0028': 8, '-0.0005': 7, '-0.0113': 1, '0.0418': 1, '-0.0075': 4, '0.0130': 4, '-0.0165': 1, '0.0020': 16, '-0.0090': 7, '0.0190': 4, '-0.0245': 1, '0.0240': 2, '-0.0225': 1, '-0.0230': 1, '-0.0295': 1, '-0.0330': 1, '-0.0139': 1, '0.0104': 1, '0.0032': 7, '-0.0117': 1, '-0.0035': 8, '-0.0010': 18, '0.0285': 1, '0.0012': 7, '-0.0202': 1, '-0.0098': 1, '0.0195': 1, '0.0075': 3, '0.0015': 8, '0.0005': 5, '-0.0130': 4, '0.0115': 1, '0.0245': 2, '0.0175': 1, '0.0155': 1, '0.0120': 3, '0.0185': 1, '-0.0078': 3, '0.0023': 2, '0.0340': 1, '-0.0105': 5, '0.0140': 2, '-0.0060': 9, '0.0125': 3, '0.0262': 1, '0.0143': 1, '-0.0120': 3, '-0.0380': 1, '-0.0095': 4, '0.0135': 2, '-0.0045': 6, '0.0100': 8, '0.0145': 2, '-0.0140': 6, '-0.0200': 1, '-0.0030': 11, '0.0035': 6, '-0.0175': 1, '0.0105': 3, '0.0080': 10, '0.0165': 3, '0.0050': 16, '0.0230': 1, '-0.0050': 3, '0.0170': 2, '-0.0110': 2, '-0.0115': 3, '0.0255': 1, '0.0300': 1, '0.0110': 6, '0.0065': 3, '-0.0205': 1, '-0.0145': 2, '-0.0150': 2, '0.0085': 1, '0.0090': 3, '-0.0022': 7, '-0.0068': 5, '-0.0128': 1, '0.0073': 1, '0.0013': 3, '0.0044': 8, '0.0081': 1, '-0.0017': 1, '-0.0061': 1, '0.0088': 1, '-0.0041': 3, '-0.0044': 8, '0.0076': 4, '0.0102': 2, '0.0043': 1, '-0.0007': 2, '-0.0042': 6, '0.0011': 2, '0.0029': 1, '-0.0049': 2, '-0.0046': 9, '-0.0009': 2, '-0.0011': 1, '-0.0101': 2, '0.0022': 3, '0.0058': 2, '-0.0047': 1, '0.0067': 1, '0.0092': 4, '-0.0002': 13, '0.0041': 1, '0.0089': 1, '-0.0021': 1, '0.0006': 11, '-0.0036': 8, '0.0024': 8, '-0.0059': 1, '0.0068': 1, '-0.0260': 1, '0.0062': 3, '0.0064': 2, '0.0004': 16, '0.0048': 3, '0.0086': 1, '0.0096': 3, '-0.0074': 3, '0.0042': 8, '0.0122': 1, '0.0014': 7, '0.0072': 2, '-0.0146': 1, '-0.0048': 6, '-0.0012': 8, '0.0094': 2, '0.0009': 2, '-0.0004': 10, '-0.0038': 6, '0.0034': 6, '0.0016': 12, '-0.0016': 6, '0.0056': 5, '-0.0084': 2, '-0.0026': 6, '-0.0006': 8, '0.0066': 3, '-0.0094': 3, '-0.0014': 8, '0.0019': 1, '0.0101': 1, '0.0186': 1, '0.0084': 1, '-0.0062': 1, '-0.0086': 2, '0.0002': 8, '-0.0072': 2, '0.0057': 2, '0.0033': 1, '-0.0033': 1, '0.0017': 1, '0.0026': 9, '-0.0032': 5, '0.0018': 9, '0.0054': 4, '-0.0155': 1, '0.0074': 3, '0.0194': 1, '0.0202': 1, '-0.0172': 1, '0.0036': 7, '-0.0092': 2, '0.0071': 1, '-0.0186': 1, '0.0162': 1, '-0.0226': 1, '-0.0154': 1, '-0.0066': 3, '-0.0112': 1, '-0.0124': 2, '-0.0106': 4, '0.0027': 1, '0.0082': 2, '-0.0148': 4, '-0.0176': 1, '-0.0024': 4, '-0.0058': 1, '-0.0018': 11, '0.0284': 1, '-0.0195': 1, '-0.0316': 1, '0.0134': 2, '-0.0108': 1, '-0.0136': 1, '-0.0034': 3, '0.0038': 6, '-0.0003': 2, '0.0256': 1, '-0.0073': 1, '-0.0054': 6, '0.0007': 1, '-0.0187': 1, '-0.0118': 1, '-0.0280': 1, '0.0174': 1, '-0.0008': 4, '0.0078': 3, '0.0278': 1, '0.0141': 1, '-0.0138': 2, '0.0091': 1, '0.0136': 1, '-0.0126': 1, '-0.0082': 1, '0.0046': 3, '-0.0203': 1, '-0.0116': 1, '-0.0179': 1, '0.0192': 2, '-0.0064': 2, '-0.0056': 1, '-0.0220': 1, '-0.0134': 1, '0.0114': 1, '-0.0152': 1, '-0.0076': 1, '0.0172': 1, '-0.0001': 1, '-0.0029': 1, '-0.0158': 1};

# Sorting based on values and storing as a new list in ascending order

new_dic = sorted(key_value.items(), key = lambda kv:(kv[1], kv[0]));

# Getting element with the maximum occurrences. It will the last element in an ascending list.

max_val = new_dic[len(new_dic)-1][1];

# printing all the highest values i.e. the number of occurrences

print 'The rates with highest occurrences are: ';

for i in new_dic:

if (i[1]==max_val):

print(i);

#==============================================================================

output:

The rates with highest occurrences are:
('0.0000', 63)

Add a comment
Know the answer?
Add Answer to:
exchange rate = {'0.0045': 3, '0.0160': 2, '-0.0028': 6, '-0.0157': 1, '-0.0443': 1, '-0.0232': 1, '-0.0065':...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • exchange rates = {'0.0045': 3, '0.0160': 2, '-0.0028': 6, '-0.0157': 1, '-0.0443': 1, '-0.0232': 1, '-0.0065':...

    exchange rates = {'0.0045': 3, '0.0160': 2, '-0.0028': 6, '-0.0157': 1, '-0.0443': 1, '-0.0232': 1, '-0.0065': 9, '-0.0080': 12, '0.0052': 1, '-0.0052': 3, '-0.0283': 1, '-0.0087': 1, '-0.0020': 9, '-0.0290': 2, '0.0180': 3, '0.0030': 15, '-0.0170': 2, '0.0000': 63, '-0.0185': 3, '-0.0055': 5, '0.0148': 1, '-0.0053': 1, '0.0265': 1, '0.0010': 22, '-0.0015': 5, '0.0137': 1, '-0.0137': 2, '-0.0023': 2, '0.0008': 10, '0.0055': 6, '-0.0025': 6, '-0.0125': 2, '0.0040': 14, '0.0260': 1, '0.0070': 8, '0.0210': 1, '-0.0070': 8, '0.0395': 1, '-0.0040':...

  • Iy uaIdii u CIOW iiIA CADIessions. (1) 1+2*3+ (4*5+6) 7 (2) 1+2*3+ ((4*5+6) 7) (1+2 3)+(4*5+6)...

    Iy uaIdii u CIOW iiIA CADIessions. (1) 1+2*3+ (4*5+6) 7 (2) 1+2*3+ ((4*5+6) 7) (1+2 3)+(4*5+6) 7 ((1)+(2+3)) + ( (4*5+6) *7)) (5) 1+2 3+ ((4*5+6) 7 (6) 1+2 3+ (4*5+6) *7) (7) 1++2 3+ ( (4*5+6) 7) (8) 1+2*3+ ((4*5+6) 7+) (9) 1+2*3+ ( (4 5+6) *7)+ (10) 1+2 3+(9 (4*5+6) 7) (11) 1+2*3+ ( (4*5+6) 7)9 (3) 5. What are the postfix expressions of (1) (4)? Do they have the same expression? If they do not, please explain...

  • 4. A= -2 4 -2 2-6-3 8 2 B= 1 -3 1 0 6 - 7...

    4. A= -2 4 -2 2-6-3 8 2 B= 1 -3 1 0 6 - 7 0 2 5 -5 0 0 0 -4 bases for the column space and null space of A.

  • 2 0 f(x) g(3) 9 4 2 2 1 2 6 0 4 3 7 4...

    2 0 f(x) g(3) 9 4 2 2 1 2 6 0 4 3 7 4 1 0 5 6 1 6 7 9 7 3 5 8 5 3 9 8 8 f(g(8)) = g(f(9)) = f(f(2)) = g(9(3)) = Question Help: Video Video Submit Question

  • please show all work 11) 1- 6/87 - 8 <-47 -4 -3 -2 -1 0 1...

    please show all work 11) 1- 6/87 - 8 <-47 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 8= و - 107 | 6 +2 (13 -1 0 1 2 3 4 5 6 7 8 9 10 11

  • 7, | 3 | 2 | 3 | 3 | 1 | 5 | 5 |...

    7, | 3 | 2 | 3 | 3 | 1 | 5 | 5 | 9 | 7 | 7|0|5|1|8-5 6-9-3-8-4-1-8 2. 2 | 2 | 2 | 2 | 2 | 2 | 3 | 3 | 3 | 3 | 3 | 3 | 3 | 3 | 3 | 3 | 4 2-2-2 9-3 3-5-7-8-8 1-7|2|6|9|1|3|5 7-7-8-8-8 1. 1 | 1 | 1 | 1 | 1 | 2 | 2 | 2 | 2 |...

  • (1 point) Let f be a permutation on the set {1, 2, 3, 4, 5, 6,...

    (1 point) Let f be a permutation on the set {1, 2, 3, 4, 5, 6, 7, 8, 9), defined as follows f= 1 2 3 4 5 6 7 8 9 1 2 5 8 3 9 4 6 7 (a) Write the permutation f7 as a product of disjoint cycles, separated by commas (e.g. (1, 2), (3,4,5),...). Do not include 1-cycles (e.g. (2) ) in your answer. (b) Determine the smallest value of k > O such that...

  • Let U = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10), A = (1,...

    Let U = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10), A = (1, 3, 5, 7, 9), 8 (2, 4, 6, 8, 10), and C (1, 2, 3, 4, 5, 10). List the elements of each set. (Enter your answers using roster notation. Enter EMPTY or for the empty set.) (a) 4 {2, 4, 6, 8, 10) (Đ) 1 0 0 {2,4, 10) X (1) cuc {}

  • 1. Find the Jordan canonical forms of the following matrices 0 0 -1 (c) 7 6-3 (b) 2 3 2 1 0 4 0 1 -3 -10-8-6-4 0 -3...

    1. Find the Jordan canonical forms of the following matrices 0 0 -1 (c) 7 6-3 (b) 2 3 2 1 0 4 0 1 -3 -10-8-6-4 0 -3 1 2 0-1 0 0 0 (d) 2 2 21-1 2 (e) 0-2-5-3 -2 0 6 85 4 0 -5 3-3 -2-3 4 1. Find the Jordan canonical forms of the following matrices 0 0 -1 (c) 7 6-3 (b) 2 3 2 1 0 4 0 1 -3 -10-8-6-4 0...

  • 7. (15 pts) For the matrix A= -3 1 2 3 6 -2 - 4 -9...

    7. (15 pts) For the matrix A= -3 1 2 3 6 -2 - 4 -9 -1 1-7 2 3 -1 5 8 - 4 4 9 0 a) Use your calculator to place the matrix in RREF. b) Find a basis for the Range(A). c) Find a basis for Nul(A).

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT