Dictionary is a collection class in c# like Arraylist and list.The difference between list and dictionary is that in the case of list the items are accessed using integer index while in the case of dictionary items are accessed using a key which need not be an integer. In .NET Dicionary is a generic class which […]
Archives for April 2018
Dictionary in Python
Dictionary in Python like list is a collection of objects.Unlike lists ,items in dictionary are accessed by key.Similar to lists ,items can be added or removed from dictionary.While the items in a list are sorted in a specific order ,the items in a dictionary are not sorted.The size of dictionary is not fixed ,items can […]
Inheritance in Python
Declaring a class We define a class in Python using the class keyword.To define a class called Main we use the following: class Main: def __init__(self): self.tempVar= 1 def SetValue(self,value): self.EmpId=value def GetValue(self): print(“EmpId=%s”%(self.EmpId)) There are few important points to be noted in the above code: 1.Class is defined using the class keyword.Here the name […]
Accessing elements in a multidimensional list in python
list is a data type in Python which consists of a group of elements.The elements are declared in a pair of square brackets.For example to declare a simple list you can use the following: nums=[1,2,3,4] you can even mix elements of different types in a list as: listObj=[1,5,”a”,”b”] The items in the list can be […]
The with statement in Python
with statement was introduced in Python 2.5 and is quite useful when you want to work with a resource and then want to dispose/close it when you are done. The with statement is used for writing blocks of code when we want to call methods as defined by context.It allows to write block of code […]