So for my autonomous robot car i want to use less money so I bought an atmega 328p and I just don’t know what to do with it. Can’t I just replace the atmega in my arduino uno r3 and program it?
We really can't provide much help without more details of what you're trying to accomplish.
Can't I just replace the atmega in my arduino uno r3 and program it?
The ATmega328P comes from the factory without the configuration fuses set appropriately for the Uno board. Also it doesn't have the bootloader that allows you to upload over the Uno's USB cable. The Arduino makes it easy to set the fuses and install the bootloader in one step (Tools > Burn Bootloader) but you need to connect an ISP programmer to the target ATmega328P to do this process. If you don't own a dedicated ISP programmer you can use a spare Arduino board as an "Arduino as ISP" for this purpose.
Note that the fuse configuration of the Uno expects a 16 MHz crystal to be attached and also might not be well suited for powering the ATmega328P from a battery. You can get many other configuration options for your ATmega328P by installing MiniCore:
This Arduino to Breadboard tutorial should help get you started.
Nick Gammon also has some useful tutorials
I use all my standalone Atmega 328s with the internal 8MHz clock.