Learning Targets
- Nest if statements inside loops
- Use variables to change robot behavior
- Trace multi-step automation logic
Using decision logic inside repeated automation cycles.
Nest if statements inside loops Use variables to change robot behavior Trace multi-step automation logic
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.
Suggested work block: 45–60 minutes. Physical builds and projects may span several classes; follow your teacher’s schedule.
Real automation often combines repetition and decision-making. A loop can process multiple parts while an if statement chooses a different route for each part.
When one structure is placed inside another, indentation shows which commands belong together.
Trace one loop cycle at a time. Record the variable values before deciding which branch executes.
Read every line and predict what the program would do before opening the practice check.
for part_number in range(4):
destination = part_number % 2
if destination == 0:
arm.move_to(250, 80, 120)
else:
arm.move_to(250, 160, 120)Rule: If you missed more than one question, reread Learn It and trace the example again before continuing.
Which pallet is selected for each of the four parts?
Do first: Write your answer in your engineering notebook.
Parts 0 and 2 go to the first pallet; parts 1 and 3 go to the second pallet.
Find and correct every error before opening the answer.
for part_number in range(4):
if part_number < 2:
arm.move_to(250, 80, 120)
else
arm.move_to(250, 160, 120)Indent the first movement under the if, and add a colon after else.
Change the logic so the first three parts go to Pallet 1 and the fourth goes to Pallet 2.
Evidence: Paste the revised code into your engineering notebook.
Create a loop that processes six parts and alternates their destination between two pallet locations.
Edit the code, predict the output, then click Run Code. No physical Workcell is connected.
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.
Without looking back at Learn It, answer these in your notebook:
A strong response names the Python idea accurately, connects it to a specific Workcell action or decision, and identifies a realistic syntax or logic error from this lesson.
Move on only when you can check every statement. If one is still uncertain, revisit the worked example or redo Fix It before continuing.
Use the official VEX API only as a programming reference to verify method names and parameters. The examples use the configured arm name arm. No physical Workcell is required.
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.