I have noticed that a color can be assigned, by their rgb values in Blender using Python. But it is not possible to directly assign a hex color code to it.
Also, there were some hex to rgb function which I found and used, but still it does not give the correct rgb values because Blender uses 'Gamma Corrected' color values.
Hence, I have found out a proper way to convert hex color code to RGB Color Value.