Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 28 Online
OpenStudy (anonymous):

Pset 5, problem 1. Anybody know how to use the dictionary? Each letter from a to z were given a value, how to use the value to calculate the score?

OpenStudy (anonymous):

Link please? I'm not following the course, but I'll be able to help. :)

OpenStudy (anonymous):

the value of any letter is called by SCRABBLE_LETTER_VALUES [l] where "l" is the letter.

OpenStudy (anonymous):

Ok. Dictionary is a structure that maps keys to values. Each key can have only one value associated with it (that value can be a list or some other structure though). In Python, if 'd' is a dictionary, then expression 'd[k]' yields a value associated with key 'k' if that key is present in 'd' - otherwise an exception is thrown. Symmetrically, an expression 'd[k] = v' assigns value 'v' to the key 'k'. In that exercise you're given a pre-populated dictionary that has all the letters as keys, and each of them is associated with a score. Is it clear now?

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!