- :-

Topics Covered

  • Function Parameters
  • Lesson Links

    Check Your Understanding:
    1. 1. This is used pass information to a function every time the function is used:
    2. Paired punctuation
      Task main
      Parameter
    3. 2. True / False: Parameter variables must also be given a data type.
    4. True
      False
    Try It!
    Try it! 1

    Moving a Precise Distance

    Create a program that utilizes a function with a parameter that has the robot move an exact number of centimeters.

    The centimeters that the robot needs to move should be the parameter for the function.

    As a result, whatever distance you want the robot to move in centimeters should be used as the parameter value. Then, when the program is run, the robot should move that distance.



    Try it!
    Try it! 2

    Turning a Precise Distance

    Create a program that utilizes a function with a parameter that has the robot turn an exact number of degrees.

    The degrees that the robot needs to turn should be the parameter for the function.

    As a result, whatever the amount of degrees you want the robot to turn should be used as the parameter value. Then, when the program is run, the robot should turn that distance.



    Try it!
    Function Parameters - Mini Challenge

    Mini Challenge 1: Warehouse Challenge

    The robot must be able to navigate through the warehouse by counting lines.

    By using the lines as markers, the robot should be able to avoid the obstacles in the warehouse.

    The robot will first count a series of lines and store the value. The robot will next count another series of lines and also store those values.

    The first value that the robot has stored will tell the robot how many lines to travel after it makes its first 90 degree right turn. After it travels those lines, the robot should make another 90 degree right turn.

    To determine how many lines the robot should then travel forward, the robot should refer to the second value it stored.
    • Recreate the table below on any surface, and use books or similar object to serve as obstacles.

    Mini Challenge PDF[ Warehouse Challenge.pdf ]