Open in TheBrain

Practice Lab 11 Hub

Practice Lab 11 — Provisional Hub and Learning Analysis

Status: Provisional. This hub is based on the Lab 11 worksheet. Instructor-solution review is pending; exact expected interpretations and any corrections to the prompt should be confirmed when the solution is available.

Source lab

Based on the instructor worksheet in Operating Systems Management, Lab, 11. The source lab is linked as a child of this hub. This hub summarizes the prompt and likely learning goals; it is not a completed solution or answer key.

Overview

Lab 11 builds on shell variables and Lab 10’s loop concepts by introducing while and until loops, user-controlled repetition, numeric counters, command substitution, and loop design. Learners trace supplied scripts, compare two loop forms, use a date-derived value in a guessing loop, and write scripts for counting by twos, counting down, and repeatedly multiplying by three.

The progression moves from understanding when a loop continues, to updating a value so the loop eventually terminates, to designing the initialization, condition, update, and output order for a desired sequence. Correct spacing, quoting, integer comparisons, and update placement matter. The source asks learners to type code in vi rather than paste it, specifically to avoid quote-character problems.

What this lab appears to teach

A while loop repeats its body while its test condition is true; an until loop repeats while its test condition is false and stops when the condition becomes true. Both require a condition that can eventually change, usually because a variable is updated inside the loop. A missing or incorrect update can create an infinite loop.

The first example uses user input as the condition-changing value; another uses a numeric variable incremented each iteration. The later exercises extend this reasoning to other sequences: counting by a fixed step, decrementing to a boundary, and multiplying through a sequence until a target is reached or passed. These tasks require deliberate decisions about the starting value, comparison operator, update expression, output placement, and termination boundary.

Observable learning objectives

Based on the prompt, learners should be able to:

Concepts and skills, in sequence

1. User-controlled repetition

The first example initializes a control variable, tests it against a sentinel value, displays a message, reads a replacement value, and repeats or exits based on that new value. This introduces a sentinel-controlled loop: user input controls termination. The learner should track the value before and after each read and understand that the condition is checked again at the top of the next iteration.

2. Counter-controlled while loop

The next example initializes a numeric counter, tests whether it has reached a boundary, increments it, and displays it. Learners explain each line and observe how the variable update guarantees eventual termination. The order of the increment and output affects whether the starting value appears in the output; make this a prediction question rather than an assumed detail.

3. Compare while and until

The paired counter examples use different loop forms to reach a stopping point. The conceptual comparison is the condition polarity: while continues while its condition is true, whereas until continues until its condition becomes true. The bodies may otherwise perform similar work. Confirm the instructor’s expected explanation and notation when the solution is available.

4. Date-driven guessing loop

A date-formatting command supplies an abbreviated weekday, captured into a variable using command substitution. The script prompts for a guess, reads input, and repeats the prompt while the guess differs from the stored day. This combines command substitution, variable comparison, user input, and loop control. The correct response depends on the actual date and the format used, so expected output is time-dependent. The worksheet’s weekday prompt gives abbreviations; spelling/case and locale behavior should be made explicit in a finalized practice version.

5. Output order and loop tracing

A short example displays the counter and then increments it. Learners explain the observed sequence and how ordering statements changes what appears. This is a direct way to teach trace tables: record the counter value at the condition check, at output, and after the update for each iteration.

6. Design a step-counting loop

The learner writes a script that advances from a stated start toward an endpoint by twos. The design needs a start value, a condition that permits the desired values, a consistent update by the step size, and output in the intended position. Verify whether the endpoint is included and ensure the update cannot skip past a condition that would otherwise be required for termination.

7. Design a countdown loop

The learner writes a sequence from 100 down to 0. This reverses the direction of the update and requires a boundary condition that includes the intended final value. Explicitly plan whether output occurs before or after decrementing and how the loop stops at zero.

8. Repeated multiplication loop

The final exercise repeatedly multiplies a value by three toward 243. Learners must choose a suitable initial value, update rule, comparison, and output location. The phrase “count to 243 multiplying by 3” should be clarified in the practice design: does the sequence begin at 1 or another value, and should it stop exactly at or include 243? The prompt’s likely intent is a geometric sequence, but exact expected setup should be confirmed.

Prerequisites and dependencies

Likely trouble spots and questions to verify

How learning should be demonstrated

Evidence should include prediction, trace, execution, and explanation:

Practice-design recommendation (not exercises yet)

Build practice from traceable, small loops. Start with a hand-trace table for the user-controlled loop, then a short counter loop and an equivalent until version. For custom sequences, ask learners to fill in start value, condition, update, output position, and expected final value before writing code. Run small ranges first, and include a clear recovery instruction for stopping an unintended infinite loop in the designated terminal.

Use ASCII quotes and hyphens in code examples, and specify the shell. Make the date-guessing exercise explicitly locale-aware or use an instructor-provided expected value. Clarify whether endpoints are inclusive in all sequence tasks, especially repeated multiplication. Leave room for code, expected output, actual output, a trace/explanation, and a reflection.

Pending solution review

Scope status

This hub is a prompt-based first draft. No new practice exercises or answer key have been created. Revise the pending points after the instructor solution is available.