For the first question, each def defines a method, also called function when defined outside of a class.
We can define as many methods as we want.
It is good advice to create small methods that do only one thing. This way, code is cleaner and easier to maintain.
For the second question, at the end of the picture in the question we have:
What “mr1.do_square()” does is call the method called do_square. By looking at the definition of the do_square method, we can see that at this point the methods move_straight and turn are called.
For the first question, I was not completely covered. I probably did not understand my question to you.
I want to understand what these two def are used for in our program. That is, what is def purpose.
For the second part, I do not see anywhere called, except do_square.