Working on Tuples, Set and Dictionaries

imaginor-labs 15 June 19
Technology Comments

This is the continuation of series of blog post on getting started to data science using python . So today will explore the building blocks of python with special emphasis on tuple, set and dictionary .

Tuple is pretty much similar to list without the mutable function that is it cannot be modified .

Few varied example of list :

imag1

You can specify tuple with parentheses or nothing but with out the square bracket .

Dictionaries:

Another very important data structure in python which associates values with keys and you can extract the value corresponding to a given key .

imag2
imag3

Again you can make use simple tab to know the function available in the dictionary with .tab after the name of the dictionary.

imag4

Lets look at some of the function :

imag5
imag6

Get is used to retrieve value

imag7
imag8
imag9
imag10
imag11

** Important note :
Dictionary keys must be immutable; in particular, you cannot use lists as keys. If you need a multipart key, you should use a tuple or figure out a way to turn the key into a string.

Set :
Set is another data structure in not so frequent in use as list and dictionary which is a collection of distinct elements .

imag12

** Important note :
The in operator in set is very fast in executing operation . Find distinct item from a collection .

imag13

Ok by this we have covered the most in set , tuple and dictionaries next in the series will explore conditional statement and function .
Happy learning and sharing !!

Comments:

Add a Comment:



Recent Posts: