Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Conventions Used in This Book

Here is a typical Code sample.

Example 1. Typical Python Example

combo = { } 
1

for i in range(1,7):
    for j in range(1,7):
        roll= i+j
        combo.setdefault( roll, 0 ) 
2

        combo[roll] += 1
for n in range(2,13):
    print "%d %.2f%%" % ( n, combo[n]/36.0 ) 
3

1

This creates a Python dictionary, a map from key to value. If we initialize it with something like the following: combo = dict( [ (n,0) for n in range(2,13) ] ), we don't need the setdefault function call below.

2

This assures that the rolled number exists in the dictionary with a default frequency count of 0.

3

Print each member of the resulting dictionary. Something more obscure like [ (n,combo[n]/36.0) for n in range(2,13)] is certainly possible.

The output from the above program will be shown as follows:

2 0.03%
3 0.06%
4 0.08%
5 0.11%
6 0.14%
7 0.17%
8 0.14%
9 0.11%
10 0.08%
11 0.06%
12 0.03%

Tool completed successfully

We will use the following type styles for references to a specific Class, method function, attribute, which includes both class variables or instance variables.

Tip

There will be design tips, and warnings, in the material for each exercise. These reflect considerations and lessons learned that aren't typically clear to starting OO designers.


 
 
  Published under the terms of the Open Publication License Design by Interspire