Open in TheBrain

Practice Lab 10.16

Practice Lab 10.16 — Expanded for Loop Practice

Name: Date:

Instructions

Use Bash and vi in a practice directory. Every task is part of a complete Lab 10 review. Trace list values before running, then record code, mode, output, and explanation.

  1. Create fruits to loop over apples pears oranges mangoes, printing each value in a sentence. Save, inspect, set the assigned permissions, run.
  2. Create namelist over three names and print one per pass. Verify filename and mode, then run.
  3. Loop over one two three four five; explain why this iterates through words rather than numerically updating a counter.
  4. Write the four-team sentence loop from the source lab and mark the loop variable/list/keywords.
  5. Write a command loop to run who, ls, and pwd; explain variable command execution and note output variation.
  6. Add a fifth fruit and a repeated name to custom lists. Predict and record iteration count/order; explain how duplicates behave.
  7. Explain how the list, loop variable, and body interact; summarize saving and executing scripts.

Reflection: How do changes in list content affect the loop without changing the loop body?