more skeleton program Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

How does the program handle invalid user input, and what happens to the game state when the user enters an invalid expression?

A

If the input is invalid, CheckIfUserInputValid() returns False, and the program deducts a point from the score.
- targetlist and numbers allowed remain unchanged

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How does the program manage the Targets list throughout the game, and what is the significance of updating and removing targets from the list?

A
  • The Targets list represents the goals the player needs to achieve. Each time a target is hit, it is removed by setting it to -1
  • Updating the target list allows new targets to be added, while previously hit targets are marked as completed
  • This ensures that the player has new targets to reach as they progress through the game
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the role of the NumbersAllowed list, and how is it updated throughout the game? What happens if a user tries to use a number not in the allowed list?

A
  • NumbersAllowed list represents the numbers that the user can use to form valid expressions.
  • Whenever a user uses a number from this list in a valid expression, that number is removed from NumbersAllowed for the next round.
  • If a user tries to use a number that is not in NumbersAllowed, the program will reject the input
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Explain the process that occurs when the game is over. How is the final score displayed, and what condition causes the game to end?

A
  • The game ends when all the targets are completed, which is indicated by the first target being set to -1.
  • When this condition is met, GameOver is set to True, and the game loop terminates. The final score is then displayed using the DisplayScore() function.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly