Challenge - 5 Problems
Variable Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
What is the output of this PowerShell script?
Look at the script below. What will be printed when it runs?
PowerShell
$name = "Alice"
Write-Output $nameAttempts:
2 left
💡 Hint
Variables hold values. When you output a variable, you see its stored value.
✗ Incorrect
The variable $name stores the string "Alice". Write-Output prints the value stored in $name, which is "Alice".
🧠 Conceptual
intermediate2:00remaining
Why do variables store data in scripts?
Choose the best reason why variables are used to store data in scripts.
Attempts:
2 left
💡 Hint
Think about how you remember things to use later.
✗ Incorrect
Variables hold data so the script can use or change it later. This helps the script remember information.
🔧 Debug
advanced2:00remaining
What does this script output?
This script tries to print a variable before assigning it. What will it show?
PowerShell
Write-Output $username
$username = "Bob"Attempts:
2 left
💡 Hint
Undefined variables output nothing in PowerShell.
✗ Incorrect
The script tries to output $username before it is assigned. PowerShell treats undefined variables as null, producing empty output.
🚀 Application
advanced2:00remaining
What is the value of $count after running this script?
Look at the script. What number will $count hold at the end?
PowerShell
$count = 0 $count = $count + 1 $count = $count + 2
Attempts:
2 left
💡 Hint
Add each number step by step to the starting value.
✗ Incorrect
Starting at 0, adding 1 makes 1, then adding 2 makes 3. So $count ends as 3.
📝 Syntax
expert2:00remaining
Which option correctly stores and outputs a string variable?
Choose the script that correctly stores the word "Hello" in a variable and prints it.
Attempts:
2 left
💡 Hint
Strings must be inside quotes in PowerShell.
✗ Incorrect
Option C correctly assigns the string "Hello" with quotes and outputs it. Others have syntax errors or missing quotes.