Open in TheBrain

Practice Lab 10.2

Practice Lab 10.2 — Full List-Driven Loop Worksheet

Name: Date:

Instructions

Complete all tasks in Bash; use vi and the instructor’s workflow. Record code, prediction, output, and explanation. Check each script’s location and permissions before executing.

  1. Create fruits looping through apples pears oranges mangoes; print a sentence per item. Save, set permissions as directed, verify, run.
  2. Create namelist looping over Ava Ben Chen; print one name each time. Save, set executable mode as required, verify and run.
  3. Create a loop over one two three four five with a message containing the current list value. Explain why numeric words do not automatically count arithmetically.
  4. Write a team loop producing required sentences for Mets, Yankees, Braves, Astros. Identify loop variable/list/body/keywords.
  5. Write a command loop to execute who, ls, and pwd; record outputs and explain system-dependent differences.
  6. Predict the iteration count for each loop from list size. Change one list by adding a value and predict/run again.
  7. Explain saving in vi, permission checking, and the . filename invocation specified by class; distinguish from Bash invocation if taught.

Reflection: How did changing a list affect loop behavior?