YouTube

Got a YouTube account?

New: enable viewer-created translations and captions on your YouTube channel!

English subtitles

← Where Does Turtle Come From - Programming Foundations with Python

Get Embed Code
6 Languages

Showing Revision 5 created 05/25/2016 by Udacity Robot.

  1. Thank you for finishing your assignments. I will
  2. be providing feedback on the discussion forums periodically.
  3. Okay, so I now want to talk about how
  4. Python knows about this thing called the turtle.
  5. Well, inside the Python Standard Library, there is this file called
  6. turtle. Turtle with a lowercase t, and inside that
  7. file is something new. And that something new is called a class.
  8. A class Turtle with an upper case T. Now,
  9. this is a little different than what we have
  10. seen thus far. What we have done thus far
  11. is some sort of file, like web browser, dot some
  12. sort of function, like open. But we haven't seen
  13. this thing called a class. Which begs the question, what
  14. is a class? For now you can think of
  15. a class as a neatly packaged box, that puts things
  16. together really well. And it allows us to
  17. write code like turtle.Turtle, with these strange looking
  18. brackets. As if we were calling a function. In fact, when we do it on this piece
  19. of code, we are in fact calling a
  20. function, a function called init which is defined inside
  21. the class Turtle. Init stands for initialize, and
  22. what it does is it creates space in memory
  23. for a new instance or a new object of the class Turtle. This instance we called
  24. brad. Brad can now access all of the rest of the methods that are inside
  25. class Turtle. Like forward, and right. Forward makes
  26. brad turn forward, and right makes brad turn
  27. to the right. Don't take my word for
  28. it, lets look for them in the documentation.