i have to double an image using python,
So i think i can replace each pixel of the image with a square formed by 4 pixels
how do i can do that and assign to each pixel of the little square different colors?
Is that a homework ? Working with a new target image, as suggested in the comments, is the easiest.
But theoretically, assuming your original image is represented as some 2 dimension table of pixels, you could do it without creating a new image:
First double both dimensions of the original image (with the original image staying on "upper left" and occupying 1/4 of the new image, and filling the other 3/4 with blank or any value).
Then take the lower right pixel from the original image, and write 4 identical pixels in the lower right of the resized image.
Then take the original pixel directly at the the left of the previous original pixel, copy it on the 4 pixels directly at the left of the 4 previous new pixels. Repeat until you reach the left end of the line, then start the process again on the line above.
At some point you will overwrite pixels from the original image, but that doesn't matter since you will already have duplicated those in the new image.
That's pure theory, assuming you are not allowed to use external libraries such as Pillow.