Bird
0
0

You want to include the variable $price followed by the literal "$10" in a string using double quotes. Which is the correct way to write it?

hard📝 Application Q8 of 15
PowerShell - String Operations
You want to include the variable $price followed by the literal "$10" in a string using double quotes. Which is the correct way to write it?
A"The price is $price$10"
B"The price is '$price$10'"
C"The price is ${price}$10"
D"The price is $price`$10"
Step-by-Step Solution
Solution:
  1. Step 1: Understand escaping dollar sign

    To print a literal $10 after variable, escape it with backtick (`$).
  2. Step 2: Analyze options

    "The price is $price`$10" escapes $ correctly; others either confuse variable end or use wrong quotes.
  3. Final Answer:

    "The price is $price`$10" -> Option D
  4. Quick Check:

    Escape $ with backtick to print literal $ [OK]
Quick Trick: Escape $ with backtick (`$) to print literal dollar sign [OK]
Common Mistakes:
  • Not escaping $ after variable
  • Using single quotes expecting interpolation
  • Misplacing braces around variables

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes