Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to print the variable name using string interpolation.
C Sharp (C#)
string name = "Alice"; Console.WriteLine($"Hello, [1]!");
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Putting the variable name in quotes, which prints the word instead of the value.
Using incorrect casing for the variable name.
✗ Incorrect
Using string interpolation, you place the variable name inside curly braces within the string prefixed by $. So, {name} inserts the value of the variable.
2fill in blank
mediumComplete the code to include the variable age in the output string using string interpolation.
C Sharp (C#)
int age = 30; Console.WriteLine($"You are [1] years old.");
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes around the variable name, which prints the text instead of the value.
Using incorrect capitalization.
✗ Incorrect
Inside the interpolated string, use {age} to insert the integer variable's value directly.
3fill in blank
hardFix the error in the string interpolation to correctly print the full name.
C Sharp (C#)
string firstName = "John"; string lastName = "Doe"; Console.WriteLine($"Full name: [1] {{lastName}}");
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Putting the variable name in quotes inside the interpolation.
Using incorrect capitalization of the variable.
✗ Incorrect
Inside the interpolated string, use {firstName} to insert the variable's value. Quotes would print the text literally.
4fill in blank
hardFill both blanks to create a greeting with the person's name and age using string interpolation.
C Sharp (C#)
string name = "Emma"; int age = 25; Console.WriteLine($"Hello, [1]! You are [2] years old.");
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes around variable names inside the interpolation.
Mixing up the variables or using incorrect casing.
✗ Incorrect
Use {name} and {age} inside the interpolated string to insert the variable values directly.
5fill in blank
hardFill all three blanks to print a formatted message with name, age, and city using string interpolation.
C Sharp (C#)
string name = "Liam"; int age = 40; string city = "Paris"; Console.WriteLine($"Name: [1], Age: [2], City: [3]");
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes around variable names, which prints the text instead of values.
Incorrect capitalization of variable names.
✗ Incorrect
Inside the interpolated string, use {name}, {age}, and {city} to insert the variable values directly without quotes.