0
0
LLDsystem_design~10 mins

Game state management in LLD - Interactive Code Practice

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

Complete the code to initialize the game state with a default score.

LLD
game_state = {"score": [1]
Drag options to blanks, or click blank then click option'
A0
B"zero"
CNone
D-1
Attempts:
3 left
💡 Hint
Common Mistakes
Using a string instead of a number for score.
Setting score to None or negative value.
2fill in blank
medium

Complete the code to update the player's position in the game state.

LLD
game_state["player_position"] = ([1], 5)
Drag options to blanks, or click blank then click option'
A"x"
B10
Cx
Dplayer
Attempts:
3 left
💡 Hint
Common Mistakes
Using a string instead of a number.
Using a variable name that is undefined.
3fill in blank
hard

Fix the error in the code that resets the game state.

LLD
def reset_game():
    game_state = [1]
Drag options to blanks, or click blank then click option'
A[]
BNone
C{}
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using None or list instead of dictionary.
Using zero which is not a dictionary.
4fill in blank
hard

Fill both blanks to correctly check if the game is over and update the state.

LLD
if game_state.get("lives", 0) [1] 0:
    game_state["status"] = [2]
Drag options to blanks, or click blank then click option'
A==
B"over"
C>
D"playing"
Attempts:
3 left
💡 Hint
Common Mistakes
Using > instead of == to check lives.
Setting status to "playing" when game is over.
5fill in blank
hard

Fill all three blanks to update the score only if the game is active and the points are positive.

LLD
if game_state.get("status") == [1] and points [2] 0:
    game_state["score"] [3] points
Drag options to blanks, or click blank then click option'
A"playing"
B>
C+=
D==
Attempts:
3 left
💡 Hint
Common Mistakes
Using == instead of += to update score.
Checking for status "over" instead of "playing".