ADM Python Practice • Practice 4

Reusable Pick-and-Place Functions

Turn repetitive simulated movement sequences into reusable functions.

Practice Assignment

What You Need to Do

  1. Create a function named pick_part(x, y, z).
  2. Create a function named place_part(x, y, z).
  3. Each function must use a safe travel height before moving down.
  4. The pick function must turn the magnet ON; the place function must turn it OFF.
  5. Call the functions to move two simulated parts between different coordinates.
  6. Do not duplicate the full movement sequence outside the functions.
Browser Python Lab

Build and Test Your Program

Modify the starter code until all required behaviors work. No physical Workcell is needed.

Interactive Python Practice

Reusable Pick-and-Place Functions

Ready
Editable Python Code
Output & Errors
Predict what will happen, then click Run Code.

Tip: Press Ctrl+Enter (Cmd+Enter on Mac) to run. The mock arm prints simulated Workcell actions instead of controlling hardware.

Success Criteria

Check Your Work

  • Both functions accept X, Y, and Z parameters.
  • The magnet turns on only during pickup and off during placement.
  • Both functions return to the defined safe height.
  • The main program is shorter and clearer because repeated movement logic is inside functions.
Submission

What to Turn In

  • Your final Python code copied into the assignment submission.
  • A screenshot of the final output showing that the program ran successfully.
  • One debugging note: identify one problem you encountered and explain how you fixed it.