is this a function or not???

Answer: It is a function
Why? Because it is impossible to draw a vertical line through more than one point on the red graph. Any vertical line will only pass through exactly one point on the red graph.
Put another way: any input x leads to exactly one and only one output y. If it was possible to have some input lead to multiple outputs, then it would be possible to draw a vertical line through more than one point on the red graph. The graph is said to "pass the vertical line test" proving it is a function.
note the closed circle at (0,2) and the open hole 2 units above that. If the open hole was filled in, then this is where the graph would fail the vertical line test; however, the open hole helps this piecewise graph be a function.