Most viewed recipes tagged "dictionaries"http://code.activestate.com/recipes/tags/dictionaries/views/2017-01-17T20:05:10-08:00ActiveState Code RecipesFallout 3 "terminal hacking" minigame cracker (Python)
2008-12-20T11:18:35-08:00Bill Sharerhttp://code.activestate.com/recipes/users/4168512/http://code.activestate.com/recipes/576590-fallout-3-terminal-hacking-minigame-cracker/
<p style="color: grey">
Python
recipe 576590
by <a href="/recipes/users/4168512/">Bill Sharer</a>
(<a href="/recipes/tags/dictionaries/">dictionaries</a>, <a href="/recipes/tags/fallout_3_minigame/">fallout_3_minigame</a>, <a href="/recipes/tags/lists/">lists</a>, <a href="/recipes/tags/sets/">sets</a>, <a href="/recipes/tags/text/">text</a>).
</p>
<p>crackerhacker.py is a script I wrote as a Python learning exercise to help
solve Fallout 3's "terminal hacking" minigame. Many of you may already be
aware of this annoying mind challenge after playing the popular waste of
time from Bethesda Softworks on your favorite pc or console.</p>
<p>more details in the script</p>
Dot-style nested lookups over dictionary based data structures (Python)
2008-12-14T14:32:59-08:00David Mosshttp://code.activestate.com/recipes/users/4124829/http://code.activestate.com/recipes/576586-dot-style-nested-lookups-over-dictionary-based-dat/
<p style="color: grey">
Python
recipe 576586
by <a href="/recipes/users/4124829/">David Moss</a>
(<a href="/recipes/tags/access/">access</a>, <a href="/recipes/tags/attribute/">attribute</a>, <a href="/recipes/tags/dictionaries/">dictionaries</a>).
Revision 2.
</p>
<p>This recipe allows you to present dictionary based nested data stuctures in your Python code as objects with nested attributes.</p>
<p>It provides dot ('.') based attribute lookups, like this :-</p>
<pre class="prettyprint"><code>>>> x = d.foo.bar.baz
</code></pre>
<p>instead of the usual (and longer) Python dictionary syntax lookups :-</p>
<pre class="prettyprint"><code>>>> x = d['foo']['bar']['baz']
</code></pre>
<p>This recipe saves you <em>lot</em> of typing!</p>
<p>For simplicity and readability this particular version show a read only lookup class.</p>
Classifying letters as vowels or consonants and counting their frequencies (Python)
2017-01-17T20:05:10-08:00Vasudev Ramhttp://code.activestate.com/recipes/users/4173351/http://code.activestate.com/recipes/580749-classifying-letters-as-vowels-or-consonants-and-co/
<p style="color: grey">
Python
recipe 580749
by <a href="/recipes/users/4173351/">Vasudev Ram</a>
(<a href="/recipes/tags/assertions/">assertions</a>, <a href="/recipes/tags/comprehension/">comprehension</a>, <a href="/recipes/tags/dict/">dict</a>, <a href="/recipes/tags/dictionaries/">dictionaries</a>, <a href="/recipes/tags/dict_comp/">dict_comp</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/python2/">python2</a>, <a href="/recipes/tags/tuple/">tuple</a>, <a href="/recipes/tags/unpack/">unpack</a>).
</p>
<p>This recipe shows how to take a string as input and classify the characters in it as vowels, consonants or neither. The frequency of each vowel is calculated and the frequency of all the consonants in total is calculated. The program logic is fairly simple, and uses a dictionary comprehension and a dict; the more interesting thing about it, is that it illustrates 8 Python language features in under 35 lines of code.</p>
<p>More details and sample output here:</p>
<p><a href="https://jugad2.blogspot.in/2017/01/classifying-letters-and-counting-their.html" rel="nofollow">https://jugad2.blogspot.in/2017/01/classifying-letters-and-counting-their.html</a></p>