Here using the turtle and random library we make a game in which the caterpillar moves slowly firstly but as soon as it starts eating leaf the speed goes increasing and if it goes outside the frame then game ends.
List out the libraries imported: turtle ,random
Workflow: Here firstly the speed of caterpillar is normal as it starts to eat leaf the speed increases and level of game becomes difficult . For the leaf we are using random library so evertime its position changes only after the caterpillar had touched it. Here we can change the size of caterpillar and its starting speed all that can be changed in script before running it. For caterpillar if it goes outside the window we call game over function and game stops and result will be displayed.
Here as we run the script the scrren will show enter space to start game then game starts as caterpillar goes on eating its speed increases and it ends when it goes outside frame.
Neel Shah