Skip to main content
PSUT / IoTEngineering learning studio
WORKSPACE
Offline-first portalDr. Mohammad Alja’afreh
Embedded Systems StudioIoT Programming and ApplicationsExperimentsWorkspaces
ENGINEERING WORKSPACE
Home/WSL Laboratories/Lab 4 · Remote access & Python environments
IoTPSUT IoT Engineering StudioPrincess Sumaya University for Technology · Dr. Mohammad Alja’afreh
Pi foundations / R4
IoT Programming and Applications

Lab 4 · Remote access & Python environments

Ask Dr. Mohammad · R4 →

SSH into WSL from Windows exactly as into a Pi from a laptop. VNC is replaced by WSLg (Linux windows on the Windows desktop).

Design experiment & verify evidence →
R4 · Laboratory mentorAsk about the current experiment, its algorithms or Python notebook.
Ask Dr. MohammadAdaptive practice
Learning workflow · Core IoT & programmingR4 · Remote access & Python environments
Readiness checksRevision deckEngineering workspaceRecord evidence
R4 · Academic orientation

Scope and objectives

Scope of the experiment

Distinguish SSH reachability/authentication from virtual environment activation and interpreter selection.

The focus of this experiment is to distinguish remote login, interpreter and isolated Python dependencies. Students then trace SSH and virtual-environment activation and check which interpreter runs, and diagnose authentication or import failures without bypassing trust checks. The Concepts view explains the operation before the practical work; the Simulation view is used to examine reference and changed inputs, not to substitute for actual measurements.

Learning objectives

  • Distinguish remote login, interpreter and isolated Python dependencies.
  • Trace SSH and virtual-environment activation and check which interpreter runs.
  • Diagnose authentication or import failures without bypassing trust checks.
  • Identify the configured inputs (Local SSH listener; Fictional credentials accepted; Practice venv exists; Activate venv) and record the corresponding observed outputs with units where applicable.
  • Compare the reference calculation or decision with an independent implementation or authorized observation; state any discrepancy and the applicable model boundary.

Expected learning outcomes

On completion, students can distinguish remote login, interpreter and isolated Python dependencies, trace SSH and virtual-environment activation and check which interpreter runs, and diagnose authentication or import failures without bypassing trust checks.

Required deliverables

Submit the derivation or state trace for the named operation, the exact reference and changed configurations, the associated simulator or practical evidence, and a short validation statement addressing diagnose authentication or import failures without bypassing trust checks. Separate predicted values from observations.

Prerequisite knowledge and related learning

Review the following catalogue prerequisites before starting. After completion, continue to Lab 5 · Python shell & arithmetic.

Environment and experimental methodology

The named Linux/WSL or Python environment and its browser teaching representation; use the setup instructions and actual command output for validation.

Begin with a manual prediction, record the baseline, change one independent condition at a time, and compare the resulting trace or measurements with the original prediction. Record observations and uncertainty separately from reference values. Follow the experiment’s specific procedure, safety limits, and acceptance checks.

R4 / PREPARE

Before starting

Follow the setup guide and use the named terminal or editor. A browser model is not a real GPIO measurement or a running service.

Ubuntu WSL setup →
Before you run / verification gate

Confirm systemd and SSH service are active; use the Linux account password, not the Windows PIN. Accept the host key only after verifying it belongs to your local server. The practice venv is separate from the toolkit venv.

CONCEPTS / ACTIVE RECALL

Understand the experiment

Scientific architecture · SSH and Python environment selection

Remote shell and isolated Python — Client terminal; SSH server; Python venv; Connect SSH / 0>1; Authentication & host key / 1>0; Create/activate venv / 0>2; python --version / 2>0
Scientific concept map: Local terminal — SSH client; Remote endpoint — Host identity; Authentication — Approved account; Python environment — venv / activate; Runtime check — which python.

Scientific foundations and analytical reasoning

SSH authenticates a remote session; a virtual environment changes interpreter and package resolution independently of the SSH connection.

Before operating the equipment or executing the program, derive the expected outcome using the required theoretical work in Experiment. Use the diagram to identify the variables and system boundaries.

Scientific theory · Remote sessions and dependency isolation

SSH protects the transport and authenticates a remote host and user; checking the host key prevents silently trusting a substituted endpoint. A successful login says nothing about which Python environment is selected. A virtual environment provides its own interpreter resolution and package paths, usually through PATH changes when activated.

Worked example and engineering interpretation

Compare command -v python and python -m pip --version before and after activating .venv. A package installed in the host interpreter may not be available inside the virtual environment. Verify the remote hostname and interpreter separately; never paste private keys or passwords into logs.

Engineering principles · additional worked teaching example

SSH transport establishes a connection before user authentication; a virtual environment changes interpreter and import resolution, not the remote identity. If command -v python shows /home/student/practice/.venv/bin/python, activation selected that interpreter; check sys.executable and imports to verify.

From theory to experiment

Predict the reference result before operating the workbench; check the actual intermediate state, units and constraints. The existing simulation, implementation and procedure below are distinct sources of evidence.

How to investigate Lab 4 · Remote access & Python environments

Verify local SSH access and distinguish the practice environment from the toolkit venv.

Analytical investigation means collecting an observation, identifying the mechanism, using a calculation or state trace to explain it, and checking your conclusion against evidence. Controlled comparison means changing one independent variable, holding the remaining relevant conditions constant, and measuring a dependent variable against a baseline. Experimental validation means comparing a predicted result to a reproducible observation or assertion; agreement inside a model does not certify hardware. Evidence-based reasoning connects a specific observation to a theoretical rule and states uncertainty, not merely an opinion. Performance characterization records a named metric and its units across conditions; sensitivity analysis changes one parameter across several values. A threat assessment links an asset, threat, consequence and evidence to a mitigation.

Experiment-specific guided practice

Objective: Verify local SSH access and distinguish the practice environment from the toolkit venv.

  1. Start with the listener and credentials accepted. Inspect the SSH and interpreter paths independently.
  2. Disable listener and then restore it with authentication denied; compare failure phases.
  3. Deactivate the venv, then activate it with venv missing. Observe interpreter selection.
  4. Use the actual SSH and python3 -m venv instructions; verify which python and sys.executable rather than relying on the prompt.

Reference check:

Model boundary:

Independent task and submission evidence

2. Disable listener and then restore it with authentication denied; compare failure phases. Record the named input, prediction, actual output and one limitation; restore the original condition and repeat.

Before execution write the independent variable and its levels, dependent observation with units where applicable, baseline, controlled variables, measurement method and expected result. For a state machine use state/event/output rather than inventing a numeric metric. Record failures and repeat the baseline. A weak conclusion is “it works”; a supported conclusion names the changed setting, observed value/state, corresponding rule and one limitation.

TrialChanged settingFixed settingsPredicted resultActual observation / unitsEvidence / uncertainty
A: baselineReferenceRecordPredictRecordRecord
B: one changeRecordSame as APredictRecordRecord
A: repeatRestoreSame as APredictRecordRecord

Completion: submit the filled table, relevant simulator screenshot or terminal/notebook output, reasoning with units/assumptions, and one limitation. Preserve the independent assessment questions; this guide does not fill their answers.

Worked engineering reasoning and boundary conditions

Engineering reference configuration: Local SSH listener = true; Fictional credentials accepted = true; Practice venv exists = true; Activate venv = true. In the classroom model, SSH = Connected; Interpreter = venv/bin/python. Virtual environment selection is a separate local operation. A closed, deterministic browser model. The existing practical instructions and source files provide independent execution; browser results are not hardware measurements.

Use the diagram to follow the calculation or state progression. Keep the teaching configuration separate from the independent exercise values; compare observations with the actual model and implementation.

Concept animation · message sequence

Explore the teaching example independently of the simulator. Each step reveals an operation, data relationship or calculated state. The Simulation view has separate editable inputs.

Lab 4 · Remote access & Python environments: message sequenceClientSSH serviceShellTCP connectionConnectedvenv/bin/python

Step 1 of 3 · TCP connection

TCP connection

1. Client → SSH service
TCP connection

Teaching example only; inspect live calculations or real practical evidence separately.

Recall the concept before revealing its explanation.

0 / 3 revealed
R4 · 01 / 08What is SSH?Reveal explanation
Engineering explanation

An authenticated remote shell; localhost connects to the local WSL service through Windows forwarding.

R4 · 02 / 08Why a virtual environment?Reveal explanation
Engineering explanation

It isolates Python dependencies from the system interpreter and the course toolkit.

R4 · 03 / 08What must be verified before opening the local SSH session and its Python environment?Reveal explanation
Engineering explanation

Confirm systemd and SSH service are active; use the Linux account password, not the Windows PIN. Accept the host key only after verifying it belongs to your local server. The practice venv is separate from the toolkit venv.

R4 · 04 / 08How do you verify the active interpreter?Reveal explanation
Engineering reasoning

Run which python or inspect sys.executable in Python and compare the result with the intended virtual environment.

R4 · 05 / 08What does an SSH login establish?Reveal explanation
Engineering reasoning

An authenticated remote shell to the selected host. It does not establish the presence of GPIO hardware or a particular Python environment.

R4 · 06 / 08A Python module imports in one terminal but not another. Select every technically valid statement. A. Compare interpreter paths and active environments. B. Activate the intended virtual environment before testing. C. SSH encryption guarantees identical Python packages. D. A Windows PIN is necessarily the Linux account password.Reveal explanation
Applied scenario

Correct: A. Compare interpreter paths and active environments.; B. Activate the intended virtual environment before testing.

R4 · 07 / 08In Remote access & Python environments, which command or code executes Exit the SSH session?Reveal explanation
Implementation recall

exit

R4 · 08 / 08For Remote access & Python environments, which actual output or state confirms the prescribed practical run succeeded, and what does it not establish?Reveal explanation
Evidence & acceptance

Complete Setup first so openssh-server is installed. Inside Ubuntu start ssh and verify active. In PowerShell use the username printed by whoami and the Linux password (not the Windows PIN). If localhost forwarding fails, verify the distribution address and listener rather than reinstalling. Create the separate iot-env only after login. Exit the SSH session when finished.

Start here · Terminal skills

Linux & WSL Command Center

Learn navigation, file operations, Python execution, services and Windows WSL management. Includes an interactive practice terminal and Dr. Mohammad command explanations.

Open Command Center →
Execution boundary · Real on WSL. Browser simulation below is a teaching model, not execution of Python or firmware. The real commands run in VS Code/WSL; Wokwi is used for Arduino/ESP32 where indicated.
Shared research workbenches · network designer & advanced studies
Concurrent-device simulation & Monte Carlo research
Distributed digital twin · topology, protocol & battery research
Loading experiment-specific apparatus…
Previous model / additional reference tools
Simulation task

Verify local SSH access and distinguish the practice environment from the toolkit venv.

Explore the model using its own controls. Record a prediction before changing a condition. Compare the reference with a changed condition, then use the Experiment tab for the procedure, acceptance criteria and notebook. Model outputs and physical observations must remain separate.

Interactive engineering workbenchR4 · Existing model
01 / Explore

Interactive lab simulation

Browser model
R4 · Model-linked instrumentation

Visual observation lens

Back to controls ↑

Original virtual instrument; model signals and execution trace.

Loading instrument…

Awaiting model display.

Experimental instrumentation · A/B

Compare two model conditions

Capture a baseline, change one experimental condition, run the model if required and capture the comparison. Snapshots contain visible controls and display text, not physical sensor readings. Review before exporting.

Open simulation view
Baseline A
Not captured
Comparison B
Not captured

Capture a baseline to begin.

Evidence portfolio →
V19.0 · Contextual AI workspace

Ask your engineering assistants

R4 · current context

Ask Dr. Mohammad locally, or prepare an experiment-aware prompt for ChatGPT, Gemini or Claude. The external providers open in their own tabs; nothing is automatically submitted.

Dr. Mohammad · offline
Dr. Mohammad

Offline curriculum-grounded assistance.

Open local tutor
Lab 4 · Remote access & Python environments

Public course objective, displayed commands, source excerpts and procedure. Private assessment content is not collected.

Prepare a contextual AI prompt

0 characters

Common secret and email patterns are redacted on preparation; this is not a comprehensive privacy filter. Review the entire editable prompt, including student work and unpublished research, before sharing. The providers apply their own accounts, privacy settings and limits.

Prepare → review → copy & open your selected provider → paste and submit there.

Run & verify — acceptance checklist

Build verification: Static procedure reviewed; actual SSH/WSL pending.

Complete Setup first so openssh-server is installed. Inside Ubuntu start ssh and verify active. In PowerShell use the username printed by whoami and the Linux password (not the Windows PIN). If localhost forwarding fails, verify the distribution address and listener rather than reinstalling. Create the separate iot-env only after login. Exit the SSH session when finished.

Record the actual output, source (mock/model or physical), and any error. A missing tool, timeout or untested external service is not a pass.

Complete lab-by-lab verification report →Open automated verification center → Ask Engineering Copilot →

Independent theoretical exercises

Before the simulation or practical, solve both experiment-specific tasks. List the given inputs, show the intermediate calculation or state trace, identify the expected observation, and state a limitation. Show formulas and intermediate calculations where relevant, or draw the requested state/sequence diagram. These are independent classroom fixtures; where they differ from the reference configuration below, do not treat them as measured values. Compare your predictions with the corresponding experiment afterwards.

01 · Predict and derive using the given inputs

Draw the path from an SSH client to a localhost listener, then distinguish connection failure, authentication failure and an inactive venv.

02 · Compare or justify using evidence

If a system interpreter has 12 packages and a venv contains 4 different packages, explain why their import availability cannot be inferred by adding the counts. Identify the commands that verify the selected interpreter.

03 · Troubleshooting

Troubleshooting · Independent work

A localhost SSH connection succeeds and login works, but importing a package fails; sys.executable is /usr/bin/python3. Explain two distinct checks and why changing SSH credentials is not a remedy.

Work is saved locally when browser storage is available. Export it for submission; no remote upload or automatic grade is assigned.

Expanded independent theoretical exercise bank

Progress from calculation and interpretation to diagnosis and controlled engineering design. Complete the questions without opening the simulation first; show intermediate steps.

Intermediate · Explain a changed-input result

Independent theoretical exercise · R4-01

Use the reference configuration (Local SSH listener = true; Fictional credentials accepted = true; Practice venv exists = true; Activate venv = true), but change Fictional credentials accepted = false. The model reports SSH = Authentication rejected. Explain the governing rule and assumptions that make this output plausible; identify an independent verification method.

Intermediate · Interpret a state transition

Independent theoretical exercise · R4-02

The reference model reports SSH: Connected. Under Fictional credentials accepted = false it reports Authentication rejected. Explain which configured condition changed and what the two outputs establish, and what they do not establish.

Intermediate · Interpret a technical trace

Independent theoretical exercise · R4-03

For Practice venv exists = false, the model supplies this excerpt from Execution observations: Event / item · Observed result TCP listener · Yes Authentication · Connected Activate · No such venv sys.executable · /usr/bin/python3 Count rows whose Observed result value is exactly “Yes”, and identify the displayed row numbers. Explain what the count describes.

Advanced · Reverse reasoning

Independent theoretical exercise · R4-04

An observation is Interpreter = /usr/bin/python3. Candidate A uses Local SSH listener = true; Fictional credentials accepted = true; Practice venv exists = true; Activate venv = true. Candidate B changes the listed settings (Practice venv exists = false) and keeps the remaining settings fixed. Which is consistent with the observation? If both can explain it, say what additional evidence is required.

Advanced · Diagnose a reported mismatch

Independent theoretical exercise · R4-05

A student configures Local SSH listener = false while preserving all other reference settings, but copies the reference report of SSH = Connected. Evaluate whether the report is justified. Identify the first configuration/output check to perform.

Challenging · Design a controlled verification

Independent theoretical exercise · R4-06

Design a controlled comparison for Lab 4 · Remote access & Python environments using reference Local SSH listener = true; Fictional credentials accepted = true; Practice venv exists = true; Activate venv = true and test Fictional credentials accepted = false. Specify the changed setting(s), measured metric SSH, controls, repetitions, an acceptance check and what evidence can distinguish an actual implementation from the model.

Step-by-step experimental procedure

Distinguish SSH reachability/authentication from virtual environment activation and interpreter selection.

1 · Reference workbench configuration

Use the named reference workbench and its reference inputs. Additional live instruments may have different controls; use the matching instrument. Record virtual and practical results separately.

Local SSH listenerYes
Fictional credentials acceptedYes
Practice venv existsYes
Activate venvYes

2 · Perform the investigation in order

  1. Start with the listener and credentials accepted. Inspect the SSH and interpreter paths independently.
  2. Disable listener and then restore it with authentication denied; compare failure phases.
  3. Deactivate the venv, then activate it with venv missing. Observe interpreter selection.
  4. Use the actual SSH and python3 -m venv instructions; verify which python and sys.executable rather than relying on the prompt.

3 · Compare controlled trials

TrialIndependent changeExpected checkObservation
ReadyUse reference inputs aboveSSH: Connected; Interpreter: venv/bin/pythonRecord actual result
SSH unavailableLocal SSH listener = NoSSH: RefusedRecord actual result
System interpreterActivate venv = NoInterpreter: /usr/bin/python3Record actual result

4 · Analyze and report

A successful SSH session does not establish package isolation.

Required evidence: Record the named metrics and trace for the reference and changed cases, then attach the corresponding practical command output or device evidence if available.

Model boundary: A closed, deterministic browser model. The existing practical instructions and source files provide independent execution; browser results are not hardware measurements.

Controlled investigation · reproducible evidence

Method. Use the existing reference workbench configuration and the named controlled changes below. A controlled variable stays fixed while the independent variable is intentionally changed; the dependent variable is the resulting observed output. First predict each trial from the Concepts page. Run the baseline, then change only the specified setting and record the outcome. For deterministic traces one execution per case and a repeated verification are sufficient; for timing or stochastic measurements repeat at least five times, recording each run, median and range. Reset to the reference state between independent comparisons.

TrialIndependent changeDependent observation
ReadyUse reference inputs aboveRecord actual outcome and units
SSH unavailableLocal SSH listener = NoRecord actual outcome and units
System interpreterActivate venv = NoRecord actual outcome and units

Evidence: attach the completed comparison table, one trace or screenshot per condition, and actual practical terminal/hardware evidence where applicable. Explain any prediction mismatch and distinguish modeled behavior from measured results.

Loading laboratory-specific procedure…

Python / Google Colab notebook

Bounded notebook reference exercise; original device/service commands are reference-only. Validated locally in a fresh Jupyter kernel. Download, then upload to Google Colab.

Download NotebookOpen Google ColabAll Python notebooks

Independent implementation sequence

  1. Start SSH and identify your Linux account
  2. Connect from Windows
  3. Create an isolated practice venv
  4. Exit the SSH session
02 / Implement

Step-by-step instructions

Before you run / verification gate

Confirm systemd and SSH service are active; use the Linux account password, not the Windows PIN. Accept the host key only after verifying it belongs to your local server. The practice venv is separate from the toolkit venv.

Complete one-time setup first. Copy one command block at a time into the indicated environment. Do not copy prompt characters. Open new terminals where named; variables are terminal-specific. Ctrl+C stops a running foreground command.

01

Start SSH and identify your Linux account

Use a WSL terminal.

WSL · Bash
sudo systemctl start ssh
systemctl is-active ssh
whoami
hostname -I
✓ Expected: IP addresses assigned to the Linux environment are printed; actual addresses vary.
Expected result for each action (4)
  1. sudo systemctl start sshNormally no output on success. Run systemctl is-active for the named service and confirm active; inspect logs if it fails.
  2. systemctl is-active sshAn active line is expected for each required running service; inactive/failed requires investigation.
  3. whoamiYour Linux username.
  4. hostname -IIP addresses assigned to the Linux environment are printed; actual addresses vary.
Checkpoint active; record the username.
02

Connect from Windows

Use PowerShell, not the Ubuntu terminal. Enter the Linux username when asked. Accept the host fingerprint only after checking it against your local SSH server.

Windows PowerShell
$linuxUser = Read-Host "Linux username from whoami"
ssh "$linuxUser@localhost"
✓ Expected: The SSH login/host-verification prompt appears if the service is reachable; confirm the intended host before authenticating.
Expected result for each action (2)
  1. $linuxUser = Read-Host "Linux username from whoami"PowerShell prompts for the Linux username and stores the entered value.
  2. ssh "$linuxUser@localhost"The SSH login/host-verification prompt appears if the service is reachable; confirm the intended host before authenticating.
Checkpoint Login prompt. If Windows already runs SSH on port 22, use VS Code Remote WSL instead.
03

Create an isolated practice venv

Open a new WSL terminal; this is a separate practice environment, not the lab toolkit.

WSL · Bash
python3 -m venv ~/iot-env
source ~/iot-env/bin/activate
python -m pip install paho-mqtt
python -c "import paho.mqtt; print('paho-mqtt OK')"
deactivate
✓ Expected: (.venv) disappears.
Expected result for each action (5)
  1. python3 -m venv ~/iot-envA virtual environment directory with bin/activate is created, usually without output.
  2. source ~/iot-env/bin/activateThe virtual environment becomes active; the prompt normally includes its name. Verify the interpreter path.
  3. python -m pip install paho-mqttInstallation completes or reports requirements already satisfied; verify imports in the selected interpreter.
  4. python -c "import paho.mqtt; print('paho-mqtt OK')"The specified success message (paho-mqtt OK or MQTT library ready) is printed if the import succeeds.
  5. deactivate(.venv) disappears.
Checkpoint paho-mqtt OK. For other labs use ~/psut-wsl/activate.sh.
04

Exit the SSH session

In the SSH terminal type exit. If you need to stop WSL, close all running lab processes first.

SSH session
exit
✓ Expected: PowerShell prompt returns.
Checkpoint Return to PowerShell.

Experimental notebook

Record your own results. Values are not prefilled or independently verified.

03 / Inspect

Source code and method

Use the inline source or commands in the steps above. No separate source file is required for this foundational lab.

04 / Verify

Evidence of completion

Save the actual terminal output from the checkpoints above. For simulated inputs explicitly record browser model, fakepi, mock or Wokwi. Never present those data as physical measurements. If a checkpoint fails, see the troubleshooting guide.

Python / Google Colab laboratory

R4 · 9 notebook cells · 2 executable Python cells

Complete the theoretical investigation first. Run the cells in order, record actual outputs and compare against your prediction.

How to execute

  1. Download this notebook and open Google Colab. Select File → Upload notebook and choose the downloaded .ipynb.
  2. Read the Markdown instructions before each executable cell. Use a Python runtime, run cells from top to bottom, and resolve imports if necessary.
  3. Perform the baseline and controlled changes. Save the notebook with actual outputs and your written interpretation.

Execution scope: Default computational cells passed isolated local Python execution; physical equipment and live services require separate verification.

01Instructions · Markdown
# r4 · Lab 4 · Remote access & Python environments **PSUT IoT Engineering Studio — Dr. Mohammad Alja’afreh** ## Introduction Verify local SSH access and distinguish the practice environment from the toolkit venv. ## How to run 1. Download this notebook from the laboratory page. Open Google Colab → File → Upload notebook. 2. Select a Python CPU runtime. Run cells from top to bottom using Shift+Enter, or Runtime → Run all. 3. Read the printed observations and assertions. Change one parameter at a time and rerun the relevant cell. 4. Save your own outputs and compare them to the portal Experiment tab. **Execution boundary:** Bounded notebook reference exercise; original device/service commands are reference-only. Do not run the hardware or service commands in Colab. No real credentials are needed. The notebook is self-contained.
02Instructions · Markdown
## Experiment-specific preparation Verify local SSH access and distinguish the practice environment from the toolkit venv. **Reference procedure (use the matching simulator/WSL tool where named, not an unrelated service):** 1. Start with the listener and credentials accepted. Inspect the SSH and interpreter paths independently. 2. Disable listener and then restore it with authentication denied; compare failure phases. 3. Deactivate the venv, then activate it with venv missing. Observe interpreter selection. 4. Use the actual SSH and python3 -m venv instructions; verify which python and sys.executable rather than relying on the prompt. **Evidence:** **Boundary:**
03Instructions · Markdown
## 1. Objectives and reference condition - Reproduce the specific computational mechanism in this laboratory. - Inspect the output, compare the reference condition with a changed or rejected condition where implemented, and explain any discrepancy. - Distinguish actual local Python execution from mock, physical and external-service observations. ## 2. Environment check
04Python · executable cell
PYTHON · Code cell
# =====================================================================
# R4 | Code cell 01 | Lab 4 · Remote access & Python environments
# Purpose: 1. Objectives and reference condition - Reproduce the specific computational mechanism in this laboratory. - Inspect the output, compare the reference condition with a changed or rejected condition where implem
# Inputs: the explicit fixture/settings below and any preceding cell state.
# Output: inspect printed values, returned records or assertions; record evidence.
# =====================================================================
import sys
print("Python",sys.version.split()[0])
# Check the expected invariant so a mismatch fails visibly instead of appearing successful.
assert sys.version_info >= (3,10)
Ask Dr. Mohammad about this cell
05Instructions · Markdown
## 3. Implementation Read the comments and variable definitions before execution. Assertions must pass; inspect values, not just completion.
06Python · executable cell
PYTHON · Code cell
# =====================================================================
# R4 | Code cell 02 | Lab 4 · Remote access & Python environments
# Purpose: 3. Implementation Read the comments and variable definitions before execution. Assertions must pass; inspect values, not just completion.
# Inputs: the explicit fixture/settings below and any preceding cell state.
# Output: inspect printed values, returned records or assertions; record evidence.
# =====================================================================
import tempfile, venv, subprocess, sys
from pathlib import Path
# Limit resource lifetime to this block so files, sockets or temporary state are cleaned up.
with tempfile.TemporaryDirectory() as d:
    venv.EnvBuilder(with_pip=False).create(d)
    exe=Path(d)/('Scripts/python.exe' if sys.platform=='win32' else 'bin/python')
    result=subprocess.check_output([str(exe),'-c','import sys; print(sys.prefix != sys.base_prefix)'],text=True)
    assert result.strip()=='True'
    print('Isolated virtual environment:',result.strip())
Ask Dr. Mohammad about this cell
07Instructions · Markdown
## Original portal implementation (reference only) These are the actual laboratory snippets. They are retained for comparison; follow the portal setup for WSL, hardware or services. They are **not** executed by Run all. ```bash python3 -m venv ~/iot-env source ~/iot-env/bin/activate python -m pip install paho-mqtt python -c "import paho.mqtt; print('paho-mqtt OK')" deactivate ```
08Instructions · Markdown
## 4. Results and analysis Record the actual output and whether the assertions pass. Identify a parameter to vary, state your prediction, repeat the reference calculation, then explain the changed result. | Trial | Configuration | Observation | Interpretation | |---|---|---|---| | A | Reference | | | | B | One controlled change | | | | C | Reference repeat | | | **Limitations:** Bounded notebook reference exercise; original device/service commands are reference-only. Notebook success does not certify external equipment or services.
09Instructions · Markdown
## Guided reasoning and evidence A controlled comparison changes one independent input while keeping the other relevant inputs fixed; the dependent variable is the recorded output. Use this lab’s reference condition above. **Independent task:** 2. Disable listener and then restore it with authentication denied; compare failure phases. Record the named input, prediction, actual output and one limitation; restore the original condition and repeat. | Trial | Input/configuration | Prediction | Observation | Evidence / limitation | |---|---|---|---|---| | A | Reference | | | | | B | Changed input | | | | | A repeat | Reference | | | | A conclusion is supported only when it cites the recorded values or observed states and explains them with the experiment theory.