I have an excel file with x and y. how can I use this excel file in qgis' python console as point vector layer to make polygon with all the points in the file.(it is important for me to use python)
PyQGIS supports delimited files including CSV. For example in the QGIS Python Console you could do the following:
uri = "file:///C:/data/points.csv?type=csv&xField=x&yField=y&spatialIndex=no&subsetIndex=no&watchFile=no" vlayer = QgsVectorLayer(uri, 'My Points', "delimitedtext")
Just replace the xField and yField variables with the x,y column names in your CSV.