Mega vs Uno

Are the programming codes of the Uno same as the codes of Mega? Is there a difference in the codes or commands?

Apart from the use of some pins, no.

Yes coding them is the same, pin assignments, and hardware is the biggest change.

You get more memory, pins, timers and serial ports on the Mega... The SPI port is not bound to
the same digital pins, but basically the library tries to hide any other differences.