Bird
Raised Fist0
Intro to Computingfundamentals~10 mins

Process management (running programs) in Intro to Computing - Interactive Code Practice

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to start a new process in Python using the subprocess module.

Intro to Computing
import subprocess
subprocess.[1](['echo', 'Hello World'])
Drag options to blanks, or click blank then click option'
Alaunch
Brun
Cexecute
Dstart
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'start' instead of 'run' causes an AttributeError.
Using 'execute' or 'launch' are not valid subprocess functions.
2fill in blank
medium

Complete the code to create a new process that runs a Python script asynchronously.

Intro to Computing
import subprocess
process = subprocess.[1](['python3', 'script.py'])
Drag options to blanks, or click blank then click option'
Aexecute
Brun
Ccall
DPopen
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'run' waits for the process to finish.
Using 'call' is similar to 'run' and waits.
3fill in blank
hard

Fix the error in the code that tries to terminate a running process.

Intro to Computing
import subprocess
proc = subprocess.Popen(['sleep', '10'])
proc.[1]()
Drag options to blanks, or click blank then click option'
Aterminate
Bend
Ckillall
Dstop
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'stop' or 'end' causes AttributeError.
Using 'killall' is not a method of Popen objects.
4fill in blank
hard

Fill both blanks to check if a process has finished and get its exit code.

Intro to Computing
import subprocess
proc = subprocess.Popen(['ls'])
if proc.[1]() is not None:
    exit_code = proc.[2]
Drag options to blanks, or click blank then click option'
Apoll
Bwait
Creturncode
Dexit
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'wait' in first blank blocks until process ends.
Using 'exit' is not a valid attribute or method.
5fill in blank
hard

Fill all three blanks to start a process, wait for it to finish, and capture its output.

Intro to Computing
import subprocess
result = subprocess.[1](['echo', 'Hello'], capture_output=[2], text=[3])
print(result.stdout)
Drag options to blanks, or click blank then click option'
Arun
BTrue
CFalse
DPopen
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Popen' does not capture output by default.
Setting capture_output or text to False returns bytes or no output.

Practice

(1/5)
1. What is a process in computing?
easy
A. A user account on the computer
B. A program that is currently running on a computer
C. A type of computer hardware
D. A file stored on the hard drive

Solution

  1. Step 1: Understand the term 'process'

    A process is an instance of a program that is executing or running on a computer.
  2. Step 2: Differentiate from other options

    Files, hardware, and user accounts are not running programs, so they are not processes.
  3. Final Answer:

    A program that is currently running on a computer -> Option B
  4. Quick Check:

    Process = Running program [OK]
Hint: Process means a running program, not a file or hardware [OK]
Common Mistakes:
  • Confusing process with a file
  • Thinking process is hardware
  • Mixing process with user account
2. Which of the following commands correctly starts a program named app.exe on a Windows system?
easy
A. start app.exe
B. run app.exe
C. execute app.exe
D. launch app.exe

Solution

  1. Step 1: Identify the correct Windows command

    On Windows, the command to start a program from the command line is start.
  2. Step 2: Check other options

    Commands like run, execute, and launch are not valid Windows commands to start programs.
  3. Final Answer:

    start app.exe -> Option A
  4. Quick Check:

    Windows uses 'start' to run programs [OK]
Hint: Windows command to run programs is 'start' [OK]
Common Mistakes:
  • Using 'run' instead of 'start'
  • Confusing with Linux commands
  • Assuming 'launch' is a command
3. Consider this flowchart for running a program:

What is the correct order of steps when a computer runs a program?
medium
A. Start -> Load program -> Execute program -> End
B. Execute program -> Load program -> Start -> End
C. Load program -> Start -> Execute program -> End
D. Start -> Execute program -> Load program -> End

Solution

  1. Step 1: Analyze the flowchart steps

    The flowchart shows the process begins with 'Start', then 'Load program', followed by 'Execute program', and finally 'End'.
  2. Step 2: Match the correct sequence

    Start -> Load program -> Execute program -> End matches the exact order shown in the flowchart.
  3. Final Answer:

    Start -> Load program -> Execute program -> End -> Option A
  4. Quick Check:

    Program runs: Start, Load, Execute, End [OK]
Hint: Follow flowchart arrows from start to end [OK]
Common Mistakes:
  • Mixing order of loading and executing
  • Starting execution before loading
  • Ignoring the start and end steps
4. A user tries to run a program but gets an error: 'Process not found'. What is the most likely cause?
medium
A. The user has too many programs open
B. The computer hardware is broken
C. The program file does not exist or path is wrong
D. The program is already running

Solution

  1. Step 1: Understand the error message

    'Process not found' means the system cannot locate the program to start it.
  2. Step 2: Identify the cause

    This usually happens if the program file is missing or the path to it is incorrect.
  3. Final Answer:

    The program file does not exist or path is wrong -> Option C
  4. Quick Check:

    Missing file or wrong path causes 'Process not found' [OK]
Hint: Check file existence and path if process not found error occurs [OK]
Common Mistakes:
  • Assuming hardware failure causes this error
  • Thinking too many programs cause 'process not found'
  • Believing program already running causes this error
5. You want to run two programs at the same time on your computer. Which process management feature allows this?
hard
A. Data encryption
B. File compression
C. Disk defragmentation
D. Multitasking

Solution

  1. Step 1: Understand running multiple programs

    Running two programs simultaneously requires the computer to manage multiple processes at once.
  2. Step 2: Identify the feature

    This feature is called multitasking, which allows the operating system to switch between processes quickly.
  3. Final Answer:

    Multitasking -> Option D
  4. Quick Check:

    Multitasking = Running multiple programs simultaneously [OK]
Hint: Multitasking lets you run many programs at once [OK]
Common Mistakes:
  • Confusing multitasking with file compression
  • Thinking disk defragmentation runs programs
  • Mixing data encryption with process management