Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to print the Unity version.
Unity
Debug.Log("Unity version: " + Application.[1]);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'platform' instead of 'unityVersion' returns the platform name, not version.
Using 'dataPath' returns the data folder path, not version.
✗ Incorrect
The Application.unityVersion property returns the Unity version as a string.
2fill in blank
mediumComplete the code to create a new GameObject named "Player".
Unity
GameObject [1] = new GameObject("Player");
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Player' as variable name can confuse with class name.
Using 'newPlayer' is valid but less common.
✗ Incorrect
Variable names should start with a lowercase letter by convention. player is a good choice.
3fill in blank
hardFix the error in the code to add a Rigidbody component to a GameObject.
Unity
Rigidbody rb = gameObject.[1]<Rigidbody>(); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using GetComponent returns existing component, does not add new.
RemoveComponent is not a valid method.
✗ Incorrect
AddComponent<T>() adds a new component of type T to the GameObject.
4fill in blank
hardComplete the code to check if the player pressed the space key and print a message.
Unity
if (Input.[1](KeyCode.Space)) { Debug.Log("Space key pressed!"); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using GetKey returns true while key is held down, not just pressed once.
GetKeyUp detects key release, not press.
✗ Incorrect
Input.GetKeyDown(KeyCode.Space) returns true only on the frame the space key is pressed.
5fill in blank
hardFill all three blanks to create a dictionary of player scores with condition.
Unity
var highScores = new Dictionary<string, int> {
{"Alice", 90},
{"Bob", 75},
{"Charlie", 85}
}.Where(kv => kv.Value [1] [2]).ToDictionary(kv => kv.Key, kv => kv.Value [3] 5); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' filters scores below threshold, not above.
Using '-' instead of '+' decreases scores.
✗ Incorrect
This code filters scores greater than 80 and adds 5 to each score in the new dictionary.