ADM Python P.10

Workcell Python Skills Challenge

Integrating variables, decisions, loops, and functions in one automation program.

Your lesson guide

Objective

Plan before coding Combine core Python structures Debug and explain a Workcell program

Materials

For the online work: a browser and your engineering notebook. Follow the activity’s materials list for any physical build, and get teacher approval before using equipment.

Plan your time

Suggested work block: 45–60 minutes. Physical builds and projects may span several classes; follow your teacher’s schedule.

Learning Targets

  • Plan before coding
  • Combine core Python structures
  • Debug and explain a Workcell program

How to Use This Page

  1. Read the short lesson.
  2. Attempt every Practice Check before revealing the answer.
  3. Complete Predict It and Fix It without running the robot.
  4. Complete Modify It and Program It in VEXcode.
  5. Use the Mastery Check before moving to the next lesson.
Learn It

Python Idea + Workcell Connection

This challenge combines the core skills from P.1–P.9. Do not start by typing. First identify the variables, repeated actions, routing decisions, and functions your program needs.

Build and check one section at a time. Trace the code in the browser editor and use comments to separate setup, pickup, routing, placement, and counter updates.

A strong solution is not the longest solution. It is readable, reusable, and easy to change.

Worked Example

Trace This Code

Read every line before opening the practice check.

pickup_zone = 2
destination = 1
parts_completed = 0

while parts_completed < 3:
    if pickup_zone == 1:
        pickup_x = 100
    elif pickup_zone == 2:
        pickup_x = 160
    else:
        pickup_x = 220

    # Add pickup and pallet movement here

    parts_completed += 1
Practice Check A

Check Your Understanding

  1. How many production cycles are planned?

    Check Answer

    3 cycles

  2. What pickup_x is selected for pickup_zone 2?

    Check Answer

    160

  3. Which line prevents the while loop from running forever?

    Check Answer

    parts_completed += 1

Rule: If you missed more than one question, reread Learn It and trace the example again before continuing.

1 · Predict It

Trace Before Running

Trace the variable values for one complete cycle before adding any robot movement.

Do first: Write your answer in your engineering notebook.

Reveal Self-Check

The first cycle begins with pickup_zone = 2, so pickup_x = 160. destination remains 1. At the end of the cycle, parts_completed becomes 1.

2 · Fix It

Debug the Program

Find and correct every error before opening the answer.

# Challenge debugging checklist:
# 1. Check variable names.
# 2. Check colons.
# 3. Check indentation.
# 4. Check that counters update.
# 5. Check that every destination has a valid route.
Reveal Debugging Check

Use the checklist on every section before testing. A program can be syntactically correct and still have unsafe or incorrect robot logic.

3 · Modify It

Change Working Code

Complete the missing pickup and pallet movement using variables instead of repeating coordinates.

Success Check

  • Your code runs without a syntax error.
  • The change affects only the intended Workcell behavior.
  • You can explain what changed and why.

Evidence: Paste the revised code into your engineering notebook.

4 · Program It

Build It Yourself

Final challenge: program a three-cycle pick-and-pallet routine. The pickup zone and destination must be controlled by variables, routing must use if/elif/else, repeated work must use a loop, and at least one repeated robot action must be placed in a function.

Before You Finish

  • Trace the code once by hand.
  • Check variable names, colons, parentheses, and indentation.
  • Verify that the coordinates and logic match the written scenario.
  • Add useful comments.
Interactive Practice

Python Practice Lab

Edit the code, predict the output, then click Run Code. No physical Workcell is connected.

Browser Python

P.10 Practice

Ready
Output / Errors
Predict what the code will do, then click Run Code.

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

Practice Check B

Explain Your Code

Without looking back at Learn It, answer these in your notebook:

  1. What Python structure or idea did you use?
  2. What physical Workcell behavior did it control?
  3. What mistake would cause the code to behave incorrectly?
What a Strong Response Includes

A strong response names the Python idea accurately, connects it to a specific robot action or decision, and identifies a realistic syntax or logic error from this lesson.

Mastery Gate

Ready for the Next Lesson?

  • □ I can plan a Workcell program before coding.
  • □ I can combine variables, decisions, loops, and functions.
  • □ I can debug syntax and logic independently.
  • □ I can explain why my robot code is safe and flexible.

Move on only when you can check every statement. If one is still uncertain, revisit the worked example or redo Fix It before continuing.

Command Reference

VEX Workcell Python API

Use the official VEX API to verify method names and parameters. The examples use the configured arm name arm; use the device name configured in your own VEXcode project.

Open EXP Workcell Arm API

Build your lesson report

Checkpoint: is your evidence ready?
  • Check calculations, units, labels, and measurements against the activity requirements.
  • Record what actually happened, including unexpected results.
  • Explain what you changed and why; attach required drawings, photos, CAD, or code in your classroom assignment.

Submit the evidence specified in the activity and your classroom assignment. The report below collects your notes, calculations, observations, and reflections; attach any required drawings, photos, CAD, or code separately.

A PDF download is not a submission. Review it, then upload it and any required attachments through your classroom assignment system.