0
0
Unityframework~10 mins

Debug.Log for debugging in Unity - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to print "Hello World" in the Unity console.

Unity
Debug.[1]("Hello World");
Drag options to blanks, or click blank then click option'
ALog
BShow
CWrite
DPrint
Attempts:
3 left
💡 Hint
Common Mistakes
Using Debug.Print instead of Debug.Log
Trying to use Console.WriteLine which is not used in Unity
2fill in blank
medium

Complete the code to print the value of the variable score using Debug.Log.

Unity
int score = 10;
Debug.[1]($"Score is {score}");
Drag options to blanks, or click blank then click option'
AWrite
BPrint
CLog
DShow
Attempts:
3 left
💡 Hint
Common Mistakes
Using Debug.Print or Debug.Write which do not exist in Unity
Forgetting the $ before the string for interpolation
3fill in blank
hard

Fix the error in the code to correctly print the player's name.

Unity
string playerName = "Alex";
Debug.[1](playerName);
Drag options to blanks, or click blank then click option'
APrintln
BLog
CWriteLine
DShow
Attempts:
3 left
💡 Hint
Common Mistakes
Using Println or WriteLine which are not Unity methods
Trying to use Debug.Show which does not exist
4fill in blank
hard

Fill both blanks to print the player's score only if it is greater than 50.

Unity
int score = 75;
if (score [1] 50)
{
    Debug.[2]($"High score: {score}");
}
Drag options to blanks, or click blank then click option'
A>
B<
CLog
DPrint
Attempts:
3 left
💡 Hint
Common Mistakes
Using < instead of > in the condition
Using Debug.Print which is not a Unity method
5fill in blank
hard

Fill all three blanks to create a dictionary of player names and scores, then print only those with scores above 80.

Unity
var playerScores = new Dictionary<string, int> {
    {"Alice", 90},
    {"Bob", 70},
    {"Charlie", 85}
};

foreach (var [1] in playerScores)
{
    if ([2].Value [3] 80)
    {
        Debug.Log($"[2].Key scored [2].Value");
    }
}
Drag options to blanks, or click blank then click option'
Aplayer
C>
Dscore
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names inconsistently
Using < or = instead of > in the condition