Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying IPython Notebook Essentials
  • Table Of Contents Toc
IPython Notebook Essentials

IPython Notebook Essentials

By : Martins
3.7 (3)
close
close
IPython Notebook Essentials

IPython Notebook Essentials

3.7 (3)
By: Martins

Overview of this book

If you are a professional, student, or educator who wants to learn to use IPython Notebook as a tool for technical and scientific computing, visualization, and data analysis, this is the book for you. This book will prove valuable for anyone that needs to do computations in an agile environment.
Table of Contents (10 chapters)
close
close

Dictionaries

Python dictionaries are a data structure that contains key-item pairs. The keys must be immutable types, usually strings or tuples. Here is an example that shows how to construct a dictionary:

grades = {'Pete':87, 'Annie':92, 'Jodi':78}

To access an item, we provide the key as an index as follows:

print grades['Annie']

Dictionaries are mutable, so we can change the item values using them. If Jodi does extra work to improve her grade, we can change it as follows:

grades['Jodi'] += 10
print grades['Jodi']

To add an entry to a dictionary, just assign a value to a new key:

grades['Ivan']=94

However, attempting to access a nonexistent key yields an error.

An important point to realize is that dictionaries are not ordered. The following code is a standard idiom to iterate over a dictionary:

for key, item in grades.iteritems():
    print "{:s}'s grade in the test is {:d}".format(key, item)

The main point...

CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
IPython Notebook Essentials
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon