Return to Video

Class Child - Programming Foundations with Python

  • 0:00 - 0:02
    So before I run this program, let me share with
  • 0:02 - 0:05
    you my hypothesis of what will happen when I run this
  • 0:05 - 0:08
    piece of code. Now one of the first things we are
  • 0:08 - 0:11
    doing here in this program, is that we're creating an instance
  • 0:11 - 0:14
    of class child we called it miley_cyrus. As soon as that
  • 0:14 - 0:18
    line of code runs, the init method inside class child will
  • 0:18 - 0:22
    get called. The first line within the init method, is this
  • 0:22 - 0:25
    print statement. So my hypothesis is, that this print statement will
  • 0:25 - 0:29
    be printed out first in our output. After that
  • 0:29 - 0:32
    the constructor for the class parent is going to get
  • 0:32 - 0:34
    called. So the control will move from here up to
  • 0:34 - 0:38
    here. When the init method for class parent is called,
  • 0:38 - 0:41
    this statement is going to get executed. So my
  • 0:41 - 0:44
    hypothesis is that this print statement parent constructor called will
  • 0:44 - 0:47
    be the second thing that gets printed. Then the instance
  • 0:47 - 0:52
    variable's last name and eye color will be appropriately initialized.
  • 0:52 - 0:54
    Once the init method for class parent has successfully
  • 0:54 - 0:57
    run, the control will come back here. At that
  • 0:57 - 1:01
    point, the instance variable number_of_toys will successfully get initialized.
  • 1:01 - 1:04
    So at that point, the init method for class child
  • 1:04 - 1:06
    is done, which means that the instance miley_cyrus has
  • 1:06 - 1:11
    been created successfully. Then, the following two print statements which
  • 1:11 - 1:13
    are trying to print the last name and number
  • 1:13 - 1:16
    of toys for miley_cyrus will get executed in that order.
  • 1:16 - 1:21
    Alright, this time let me actually run this piece of code. And there's
  • 1:21 - 1:25
    my output. And it seems pretty close to what I thought it would
  • 1:25 - 1:28
    be. Now, I want you to pause the video here for a second,
  • 1:28 - 1:32
    and I want you to see if the output here matches your hypothesis.
Tytuł:
Class Child - Programming Foundations with Python
Opis:

more » « less
Video Language:
English
Team:
Udacity
Projekt:
UD036 - OOP
Duration:
01:33
Udacity Robot edited angielski subtitles for 07-07 Class Child
Udacity Robot edited angielski subtitles for 07-07 Class Child
Udacity Robot edited angielski subtitles for 07-07 Class Child
Cogi-Admin edited angielski subtitles for 07-07 Class Child

English subtitles

Revisions Compare revisions