Open in TheBrain

Practice Lab 10.14

Practice Lab 10.14 — Complete Loop Design Worksheet

Name: Date:

Instructions

Use Bash in the lab environment. Write each script in vi and verify before execution. Record expected output, actual output, and reasoning. Do not just type and run.

  1. Create a fruits loop with four list values, printing a descriptive sentence per iteration; save, check mode, execute.
  2. Create a namelist loop over three different names; print each value; verify and run.
  3. Use a word list one through five in a loop. Explain why this does not itself maintain a numeric counter.
  4. Write the exact baseball-team output loop and label the syntax.
  5. Write a loop that executes who, ls, pwd; record outputs, state which vary.
  6. Build a custom list with five items, including a repeated item; predict body executions and output; run and compare.
  7. Reorder that list; explain which result changes and which stays the same. Remove one item and retest.
  8. Fill in a full explanation of how the loop variable, list, body, do, and done work. Include saving, permission checking, and invocation.

Reflection: What distinguishes “repeat for each value” from “count upward”?