I was actually trying to write a simple program which reads the input from keyboard and mouse to Pygame python program. when I searched , found its easy and within a few lines of code in Python we can able to control the movements of an image object in python.
The function image.load can load the image to the screen.
image.get.rect() get the rectangle coordinates of the image position.
Event 'pg.key.get_pressed' reads the key press events and 'ÍF' clause checks which key has been given as inputs in the below program.
The same mouse click event also capturing inside the while loop which runs till the variable 'running' is true.
Based on the key inputs the rectangle image object position coordinates were changed to make movements to the image.
Raspberry Pi Pygame to control Image movements through External Keyboard or mouse