Page 94 - Modular v1.1 Pyhton
P. 94

On running the above program, you will get the following output:

















                      ACCESSING A DICTIONARY

                  To access the elements of a dictionary, you need the key defined in the key:value pairs. You can
                  also use the get( ) method for fetching the value of a particular key of a dictionary.
                  Syntax to access a dictionary:

                    <dictionary-name>[<key>]
                  Program 2: To access a dictionary.














                  On running the above program, you will get the following output:



















                      PYTHON METHODS

                  Python provides various built-in dictionary methods. The following table describes explanation
                  of these methods.

                                  Method                                       Explanation
                      pop(key)                           Removes an element whose key is given

                      popitem( )                         Removes an arbitrary element and returns its value
                      clear( )                           Removes all the elements



                   92     Touchpad MODULAR (Version 1.0)
   89   90   91   92   93   94   95   96   97   98   99