wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Text Adventure Game Functions Quiz - Part 1

Total questions: 40

Worksheet time: 20mins

Name
Class
Date
1.

What happens when you try to move in a direction where CurrentPlace.Direction is equal to 0?

a)

The CurrentLocation is updated to CurrentPlace.Direction

b)

A message "The door is closed." is printed

c)

A message "You are not able to go in that direction." is printed

d)

The function DisplayContentsOfContainerItem is called

2.

What does the function DisplayContentsOfContainerItem do if an item's location matches the ContainerID?

a)

It prints the name of the item without a comma.

b)

It prints "The door is open."

c)

It prints the name of the item with a comma if it's not the first item.

d)

It changes the value of Moved to False.

3.

What will the function Examine(Items, Characters, ItemToExamine, CurrentLocation) return if ItemToExamine is "inventory"?

a)

The description of the item to examine

b)

The current location of the character

c)

The inventory list

d)

An error message

4.

What does the function GetPositionOfCommand(CommandList, Command) do?

a)

It returns the position of the command in the command list

b)

It prints the command

c)

It deletes the command from the command list

d)

It executes the command

5.

What will happen if the Examine function is called with an ItemToExamine that is neither "inventory" nor an item in the current location?

a)

It will return the inventory list

b)

It will print the item's description

c)

It will return the description of a character

d)

It will print "You cannot find to look at."

6.

What does the function 'ChangeLocationOfItem' do?

a)

It changes the name of an item in the Items list.

b)

It changes the location of an item in the Items list.

c)

It changes the status of an item in the Items list.

d)

It generates a random number.

7.

What is the purpose of the 'getRandomNumber' function?

a)

It changes the status of an item.

b)

It rolls a dice to get a number between 1 and 6.

c)

It returns a random number between the LowerLimitValue and UpperLimitValue.

d)

It changes the location of an item.

8.

What is the return value of the function 'ChangeStatusOfDoor' when the current location is the same as the location of the 'IndexOfOtherSideItemToLockUnlock'?

a)

The new status of the door.

b)

The new location of the door.

c)

The current location of the door.

d)

True or False depending on whether the door's status was changed.

9.

What will the 'rollDice' function do if the user inputs non-numeric values for Lower and Upper?

a)

It will return a random number without any validation.

b)

It will prompt the user to enter the minimum and maximum again until valid numbers are provided.

c)

It will change the status of an item.

d)

It will exit the program.

10.

What is the purpose of the ChangeStatusOfItem function in the provided code snippet?

a)

To update the game score

b)

To change the status of an item from "locked" to "close" or vice versa

c)

To print messages to the console

d)

To stop the game

11.

What happens when the UseItem function is called with an item that is not in the INVENTORY or at the CurrentLocation and marked as "usable"?

a)

The item's status is changed to "locked"

b)

The item's status is changed to "close"

c)

A message is printed saying the item can't be used in this location

d)

The game is stopped

12.

What does the GetPositionOfCommand function likely return?

a)

The index of the item to use

b)

The current location of the player

c)

The position of a command within an item's command list

d)

The status of an item

13.

What is the expected behavior when the SubCommand "roll" is executed within the UseItem function?

a)

The game is stopped

b)

The status of an item is changed

c)

A message is printed with the result of a dice roll

d)

The inventory is updated

14.

What is the purpose of the GetIndexOfItem function in the provided code snippet?

a)

To determine the current location of an item

b)

To extract the result for a command

c)

To find the index of an item in the Items list

d)

To check if an item is in the inventory

15.

What happens if the 'read' command is not in the Items[IndexofItem].Commands list?

a)

The function will return the position of the command

b)

The item will be added to the inventory

c)

An error message "You can't read + ItemToRead + ." will be printed

d)

The function will execute the 'say' subcommand

16.

What condition must be met for the CanGet variable to be set to True in the GetItem function?

a)

The item must be located at the MINIMUM_ID_FOR_ITEM

b)

The item must not be in the inventory and must have the 'get' command

c)

The item must be in the current location and not in the inventory

d)

The item must have the 'win' subcommand

17.

What does the function CheckIfDiceGamePossible return if both players are in the same room and the other character has a die?

a)

(True, IndexOfPlayerDie, IndexOfOtherCharacter, IndexOfOtherCharacterDie)

b)

(False, IndexOfPlayerDie, IndexOfOtherCharacter, IndexOfOtherCharacterDie)

c)

(True, -1, -1, -1)

d)

(False, -1, -1, -1)

18.

What is the purpose of the function TakeItemFromOtherCharacter?

a)

To print the items that the player has in their inventory

b)

To check if a dice game is possible between characters

c)

To allow a player to take an item from another character's inventory

d)

To move an item from the player's inventory to another character

19.

What happens when the 'gettable' status of an item is True in the function CheckForDiceGamePossible?

a)

The item's location is changed to INVENTORY and a message is printed

b)

The game is won by the player

c)

The item is removed from the game

d)

Nothing, the status is not checked in this function

20.

What is the purpose of the function TakeRandomItemFromPlayer in the provided code snippet?

a)

To add an item to the player's inventory

b)

To remove a random item from the player's inventory and give it to another character

c)

To check if a dice game is possible

d)

To print the items in the player's inventory

21.

What happens if the condition if DiceGamePossible: evaluates to False in the PlayDiceGame function?

a)

The function returns the items list

b)

The function prints "You can't play a dice game."

c)

The function takes an item from the other character

d)

The function rolls a die for the player

22.

What does the RollDie function return based on its usage in the PlayDiceGame function?

a)

The position of the command in the items list

b)

The score of the dice roll

c)

The name of the item taken from the player

d)

The ID of the other character

23.

What is the outcome if PlayerScore > OtherCharacterScore after both players have rolled their dice in the PlayDiceGame function?

a)

The player loses an item

b)

The player wins and takes an item from the other character

c)

The game ends in a draw

d)

The other character wins and takes an item from the player

24.

What will the function DisplayInventory(Items) print if an item's location is INVENTORY?

a)

The item's name

b)

You can't move ItemToMove.

c)

You can't find ItemToMove.

d)

On the floor there is: Thing.Name

25.

What happens when the MoveItem function is called with an item that has a location different from CurrentLocation?

a)

It prints "You can't move " + ItemToMove + "."

b)

It prints the item's name

c)

It adds the item to the inventory

d)

It prints "You can't find " + ItemToMove + "."

26.

What does the function DisplayGettableItemsInLocation do if there are no gettable items in the current location?

a)

It prints the names of all items in the location

b)

You are currently carrying the following items:

c)

It prints nothing

d)

On the floor there is:

27.

What condition must be met for an item to be included in the list created by the function DisplayGettableItemsInLocation?

a)

The item's location must be INVENTORY

b)

The item must have "gettable" in its status and be in the current location

c)

The item must have "say" in its commands

d)

The item must have more than 4 commands

28.

What is the purpose of the DisplayOpenCloseMessage function in the provided code snippet?

a)

To start or stop the game

b)

To move the character to a different location

c)

To display a message based on the result of an open or close action

d)

To read an item's description

29.

What will happen if the 'Command' variable is set to "get" within the PlayGame function?

a)

The game will stop

b)

An item will be used

c)

The character will move to a different location

d)

An item will be retrieved

30.

Which command will result in the character's movement within the PlayGame function?

a)

"use"

b)

"go"

c)

"read"

d)

"examine"

31.

If the ResultOfOpenClose variable is -1, what message will be displayed by the DisplayOpenCloseMessage function?

a)

"You have opened it."

b)

"You have closed it."

c)

"You can't do that, it is locked."

d)

"You can't open that."

32.

What is the purpose of the 'LoadGame' function in the provided code snippet?

a)

To save the current state of the game

b)

To load the saved state of the game from a file

c)

To start a new game

d)

To update the game's graphics

33.

Which Python module is used for serializing and deserializing objects in the given code?

a)

json

b)

csv

c)

pickle

d)

xml

34.

What happens if an exception occurs during the execution of the 'LoadGame' function?

a)

The game will restart

b)

The function will return False

c)

The exception will be printed to the console

d)

The function will silently ignore the exception

35.

What is the expected type of the 'Filename' parameter in the 'LoadGame' function?

a)

Integer

b)

List

c)

String

d)

Dictionary

36.

Based on the code, what is the correct order of loading the game components in the 'LoadGame' function?

a)

Characters, Items, Places

b)

Places, Items, Characters

c)

Items, Characters, Places

d)

Characters, Places, Items

37.

What is the correct file extension appended to the filename in the input prompt within the Main() function?

a)

.txt

b)

.exe

c)

.gme

d)

.py

38.

What will be printed if the game fails to load?

a)

Game loaded successfully.

b)

Unable to load game.

c)

Error in game loading.

d)

Game not found.

39.

Which function is called within the Main() function to start the game after it is successfully loaded?

a)

StartGame

b)

PlayGame

c)

RunGame

d)

InitGame

40.

What is the purpose of the if __name__ == "__main__": statement?

a)

To define a new function

b)

To import a module

c)

To check if the script is being run as the main program

d)

To declare a class