Return to Video

Janete Perez explains Functions with Parameters

  • 0:00 - 0:02
    (Janet - Zynga Engineer)
    Anyone can be a programmer.
  • 0:02 - 0:04
    You just have to be a little bit adventurous,
  • 0:04 - 0:07
    be willing to learn, and have a great idea.
  • 0:07 - 0:10
    To explain functions and parameters,
  • 0:10 - 0:14
    I can use the example of when you order food for lunch.
  • 0:14 - 0:16
    So say you're ordering a sandwich and a drink.
  • 0:16 - 0:19
    Well, the parameters would be
  • 0:19 - 0:23
    what flavor of drink you want and what size sandwich do you want.
  • 0:23 - 0:25
    And so in this way,
  • 0:25 - 0:28
    functions in computers take parameters so that
  • 0:28 - 0:32
    you can specify how big a shape is
  • 0:32 - 0:35
    or what color the shape is.
  • 0:35 - 0:38
    What if we want to draw a bunch of triangles and have
  • 0:38 - 0:39
    their lengths be different sizes?
  • 0:39 - 0:43
    Now you can use our function block and input different numbers
  • 0:43 - 0:45
    so that we can draw different sized shapes.
  • 0:45 - 0:48
    If you click the star on the draw triangle function,
  • 0:48 - 0:51
    you can drag input name into input block;
  • 0:51 - 0:53
    and then if you write
  • 0:53 - 0:56
    length in the spot where it says X and press Enter.
  • 0:56 - 0:59
    You'll create a length input for your function.
  • 0:59 - 1:02
    Then click on the star again to close it out.
  • 1:02 - 1:06
    Now, you'll want to click on the variables category
  • 1:06 - 1:10
    and drag the length block into the move
    forward block of your function definition.
  • 1:10 - 1:15
    Drag away the old number block and now
    you have a function block
  • 1:15 - 1:18
    where you can input the length of the sides of your triangle.
  • 1:18 - 1:20
    This is called a function with parameters.
  • 1:20 - 1:24
    To use it, click on the functions category
  • 1:24 - 1:27
    and drag out your draw triangle with length function.
  • 1:27 - 1:30
    Now you can use the math block to input different numbers
  • 1:30 - 1:33
    to draw triangles of different sizes.
  • 1:33 - 1:35
    Give it a try in soon you'll be a coding ninja.
Title:
Janete Perez explains Functions with Parameters
Description:

more » « less
Video Language:
English
Duration:
01:38

English subtitles

Revisions