• Q & A – Python Dictionary

    Q & A – Python Dictionary

    (1) What Is A Python Dictionary? How Does It Work? Python Dictionary objects are data types that are enclosed in curly braces ‘{}’ and have key and value pairs and each pair is separated by a comma. The dictionary is mapped. Meaning since it has key and value pair, a meaningful key can save a lot of trouble for coders, like using an address key to save all the addresses, an id key for all id’s and so on. Moreover, as of Python >3.6, dictionaries also preserve the order. Example-1 student = {‘Name’:’Subrat’, ‘Subject’:’Math’, ‘Mark’:88} print(student) {‘Name’: ‘Subrat’, ‘Subject’: ‘Math’,

    Read More

  • Q & A – Python Set

    Q & A – Python Set

    (1) What Is A Set Data Structure? A Set is an unordered collection data type that is iterable, mutable and has no duplicate elements.  Set is represented by { } (values enclosed in curly braces) The major advantage of using a set, as opposed to a list, is that it has a highly optimized method for checking whether a specific element is contained in the set.  This is based on a data structure known as a hash table. Since sets are unordered, we cannot access items using indexes as we do in lists. Example-1 st = {1,4,2,5,1,3,3,4} print(st) {1, 2, 3, 4,

    Read More