Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

python question using thonny the last picture is the code that was provided thats all the info i have please try to answer my question

python question using thonny image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
the last picture is the code that was provided
thats all the info i have
please try to answer my question
thank you image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
COMP 208 Winter 2020 Assignment_2_rev3.pdf (page 10 of 12) Q Sear Question 4 (20 points) You have just started your new job as a puzzle engineer at Sierra Studios. Your first task is to create a simple escape the room' type game in the Python programming language. An escape the room' game is defined as follows. When the program runs, a description of a room with no exits will be given to the user (listing objects and people in the room). The user will then be given a chance to type in a command to interact with the objects and/or people in some way (e.g., 'examine the table' or 'talk to Bob'). Interacting in this manner will give responses containing hints as to how to escape the room. For example, after examining the table and talking with Bob, the user might discover they have to flip the lightswitch in order for a secret door to open. Then, if the user enters 'flip the lightswitch', they will win and the game will be over. Your 'escape room' implementation must contain at least the following elements: A function escape room that returns True only when the player has escaped the room suc- cessfully. (E.g., in the above example, True would be returned if the user enters the phrase 'flip the lightswitch'.) The function should start by printing a description of the room, including the objects you can examine and people you can talk to. Commands should be stored in a dictionary, with each key being a command and each value being the message to print when that command is entered. Inside a loop, the user should be asked to enter a command, and then the corresponding message in the dictionary should be printed. If the command is not present in the dictionary, "Invalid command." should be printed. The command should be turned into lowercase, so if the user uses capitals in an otherwise valid command, the command will still work. Two special commands, not stored in the dictionary, should also be available for the user. One is the command 'commands', which should display to the user all commands present in the dictionary. The other command will be the special command that lets the user escape the room (e.g., 'flip the lightswitch' in the example above). This command should print a message Ow Help * 46% D Sat 7:46 COMP_208_Winter_2020 Assignment_2_rev3.pdf (page 10 of 12) Inside a loop, the user should be asked to enter a command, and then the corresponding message in the dictionary should be printed. If the command is not present in the dictionary, "Invalid command." should be printed. The command should be turned into lowercase, so if the user uses capitals in an otherwise valid command, the command will still work. Two special commands, not stored in the dictionary, should also be available for the user. One is the command 'commands', which should display to the user all commands present in the dictionary. The other command will be the special command that lets the user escape the room (e.g., 'flip the lightswitch' in the example above). This command should print a message like "You have found the secret door!' and then return True. Try to make this command easy to guess, or allow multiple ways for the user to express it (e.g., 'enter 0 in keypad' might also be expressed as 'press 0' or 'enter O' or 'press key 0'). There should be at least one object in the room for the user to examine, and when the user types 'examine [object]', a hint should be given about how to escape the room. This object should be listed in the description. Note that it does not have to be an object, but at minimum something that can be examined (e.g., texture of the walls of the room, rug on the floor, etc). There should be at least one named person in the room for the user to talk to, and when the user types 'talk to (person]', a hint should be given about how to escape the room. This person should be listed in the description. Note that it does not have to be a person, but minimally something that can give and/or receive input (e.g., computer, intercom, keypad, ete). At the top of your code file, give your escape room a name by defining the ROOM NAME variable, 10 ols Window Help 8 46%D) Sat 7:46 PM COMP 208 Winter 2020_Assignment 2.fev3.pdf (page 11 of 12) Q Search and write your name in the AUTHOR variable. (These will have no use for your code, but we will use them in grading.) Any submission meeting these requirements will get full marks, but you are encouraged to go beyond them, either in terms of creativity of descriptions, complexity of puzzles, or technical sophistication. The most impressive submissions (as judged by our TAs) will be shown in class and/or stitched together into a combined work. Filename You must write this program in a file called dungeon.py. Some code is already provided to you. Examples (as executed in Thonny) EXAMPLE 1: >>> Kun dungeon py You find yourself in a dark room. A candle lies on a small table in front of - you, providing a small amount of light. You cannot see any door or exit. However, there is what seems to be a keypad on one of the walls. > EXAMINE CANDLE The candle is tall and thin. You decide to pick it up to examine the rest of - the room more closely. You think you can make out half of a mathematical - equation on the walls: e to the power i times pi... > examine keypad It is a standard keypad, with digits from 0-9. Looking closely, you think you - can make out half of a mathematical equation scratched into the wall above it: + 1... > smash keypad Window Help 46% Sat 7:- COMP_208_Winter_2020_Assignment_2_rev3.pdf (page 11 of 12) EXAMPLE 1: >>> %Run dungeon.py You find yourself in a dark room. A candle lies on a small table in front of - you, providing a small amount of light. You cannot see any door or exit. - However, there is what seems to be a keypad on one of the walls. > EXAMINE CANDLE The candle is tall and thin. You decide to pick it up to examine the rest of - the room more closely. You think you can make out half of a mathematical equation on the walls: e to the power i times pi. > examine keypad It is a standard keypad, with digits from 0-9. Looking closely, you think you - can make out half of a mathematical equation scratched into the wall above - it: + 1... > smash keypad Invalid command. > Commands Commands are: examine candle, examine keypad > enter 0 in keypad A secret door opens! s Window Help * 46% D Sat 7:47 COMP_208 Winter_2020 Assignment_2_rev3.pdf (page 12 of 12) OS EXAMPLE 2: >>> %Run dungeon.py You have walked deep into a cave, looking for treasure, when suddenly you - wander down a dead-end and hear the tumble of rocks from behind you. You are trapped! In front of you, the rock face is smooth and glistening with moisture. Moss of many different hues grows on the surface. There is an - eerie silence, punctuated only by the drops of water from the ceiling into - a small pond next to you. What do you do? > commands examine moss examine pond > examine moss You examine the moss closely. Most of the moss are hues of green, but there is one very small area where it is bright purple. You suddenly realize this - purple moss is displayed in the shape of a key hole. Perhaps it you had a - key, you could use it here. > examine pond You kneel down and peer into the pond. In the reflection of the water, you see - yourself with a key in your hand. Your reflection then smiles and puts the - key in your pocket. Startled, you stand up and feel inside your pocket -- - there is a key there! If only you know where to use it. > put key in keyhole A secret door opens in the rock wall! Edit View Run Device Tools Help Thonny - /Users/albertouaknine/Down DBH dungeon.py encryption.py parentheses.py sequence.py 1 # Author: [your name here) 2 # McGill ID: [your ID here) 3 # Assignment 1, Question 4 5 6 AUTHOR = "your name here" ROOM. NAME = "name of your escape room def escape_room(): print("Room description here.") commands = { #insert key-value pairs here while True: cmd=input(" ") # turn command to lowercase #print appropriate message =check it and is one of the retum True if usen has ente 1. correct answer 26 Calling the function so that it runs when we run the file. 27 escape_room Shell Python 3.7.5. (bundled) e s will be for your code, but de w e will he is wing) w itho then, either interesovi o u t p top bond t ion Question 4 (20 points) You have just wanted your new jobs pusleger Sie Studios. Your first to create a imple cape the type in the Python As pethe game is defined follows. When the program adeription of with me will be given to th ing s the The be a chance to type in t h e line the table b ateracting it will give those tha t with the dever they have to flip the child is one to the work Y . The Your pero impatimi . A further wally in the above emple, True w t te health e d the E EMPEL pe i rosto The find wat by ting a drotherming the You find yourself in dark roo yer will . Te Wo r e wat ek af the wall . Cand se won a dit with big wees dete The w a ll the clay with To this the the what otthal " mad e pri The and it Twi t hdraw for the the day. The thrilled the he re werd allow for t . The other t he bele Nath . There w ere Any them File You Question 4 (20 points) You have just started your new job as a p le engineer at Sierra Stwos. Your first task is to create a simple ape the room type game in the Python programming lang Anwespe the room'ume is defined as follows. When the programu , a description of room with no exits will be given to the listing objects and people in the room). These will then be given a chance to type in a command to interact with the objects and/or people in some way ( e mine the table or talk to Bob') Interacting in this manner will give responses containing hints as to how to escape the room. For example, after examining the table and talking with Bob the war might discover they have to flip the lightwitch in order for a secret door to open. The if the c enters flip the lightwitch', they will win and the game will be over Your escape room implementation must contain at the following elemente: A function escape room that returns True only when the player has escaped the room c ally. ( E in the above example, True would be returned if the ser enters the phrase flip the lightwitch.) The function should start by printing a description of the room, including the objects you can emine and people you can talk to. Commands should be stored in a dictionary, with each by being a command and each value being the message to print when the command is entered Inside a loop, the should be used to enter a command, and then the corresponding m e in the dictionary should be printed. If the command is not present in the dictionary valid command should be printed. The command should be turned into lower of the capitals in an otherwise valid command, the command will still work. . Two special commande, not stored in the dictionary, should also be available for the war One is the command 'comandal which should display to the all command present in the dictionary. The other command will be the special command that let the recipe the room ( e p the lights within the example above. This command should print a me like You have found the were door and then return Tree. Try to make this commande to o r allow multiple way for the user to expet enter in krypadlihts be exp o enter' or pres key 0) There should be at least one object in the room for the user to examine and when the types examine object. his should be about how to escape the cen. This object should be listed in the descriptio. Note that it does not have to be an object but something that can be examined texture of the wall of the room, roon the floor ete) There should be at least one named person in the room for the war to talk to, and when ther types talk to person i t should be in how to cape the room. The person sturult be sated in the description. Note that it does not have to be person, but en nally thing that tive and reputoputere a . At the top of your code file your name by die the ROOM E rable Q Search Question 4 (20 points) You have just started your new job as a puzzle engineer at Sierra Studios. Your first task is to create a simple 'escape the room' type game in the Python programming language. An 'escape the room' game is defined as follows. When the program runs, a description of a room with no exits will be given to the user (listing objects and people in the room). The user will then be given a chance to type in a command to interact with the objects and/or people in some way (e.g., "examine the table' or 'talk to Bob'). Interacting in this manner will give responses containing hints as to how to escape the room. For example, after examining the table and talking with Bob, the user might discover they have to flip the lightswitch in order for a secret door to open. Then, if the user enters 'flip the lightswitch', they will win and the game will be over. Your 'escape room' implementation must contain at least the following elements: A function escape room that returns True only when the player has escaped the room suc cessfully. (E.g., in the above example, True would be returned if the user enters the phrase 'flip the lightswitch'.) The function should start by printing a description of the room, including the objects you can examine and people you can talk to. Commands should be stored in a dictionary, with each key being a command and each value being the message to print when that command is entered. Inside a loop, the user should be asked to enter a command, and then the corresponding message in the dictionary should be printed. If the command is not present in the dictionary, "Invalid command." should be printed. The command should be turned into lowercase, so if the user uses capitals in an otherwise valid command, the command will still work. Two special commands, not stored in the dictionary, should also be available for the user. One is the command 'commands', which should display to the user all commands present in the dictionary. The other command will be the special command that lets the user escape the room (e.g., 'flip the lightswitch' in the example above). This command should print a message like 'You have found the secret door!' and then return True. Try to make this command easy to guess, or allow multiple ways for the user to express it (e.g., 'enter 0 in keypad' might also eva.pur page 10 of 12) Q Search being the message to print when that command is entered. Inside a loop, the user should be asked to enter a command, and then the corresponding message in the dictionary should be printed. If the command is not present in the dictionary, "Invalid command." should be printed. The command should be turned into lowercase, so if the user uses capitals in an otherwise valid command, the command will still work. . Two special commands, not stored in the dictionary, should also be available for the user. One is the command 'commands', which should display to the user all commands present in the dictionary. The other command will be the special command that lets the user escape the room (e.g., 'flip the lightswitch' in the example above). This command should print a message like 'You have found the secret door!' and then return True. Try to make this command easy to guess, or allow multiple ways for the user to express it (e.g., 'enter 0 in keypad' might also be expressed as 'press O' or 'enter O' or 'press key 0'). There should be at least one object in the room for the user to examine, and when the user types 'examine (object)', a hint should be given about how to escape the room. This object should be listed in the description. Note that it does not have to be an object, but at minimum something that can be examined (e.g., texture of the walls of the room, rug on the floor, etc). There should be at least one named person in the room for the user to talk to, and when the user types 'talk to (person)', a hint should be given about how to escape the room. This person should be listed in the description. Note that it does not have to be a person, but minimally something that can give and/or receive input (e.g., computer, intercom, keypad, etc). At the top of your code file, give your escape room a name by defining the ROOM NAME variable, COMP_208_Winter_2020 Assignment_2_rev3.pdf (page 11 of 12) ZO Q Search and write your name in the AUTHOR variable. (These will have no use for your code, but we will use them in grading.) Any submission meeting these requirements will get full marks, but you are encouraged to go beyond them, either in terms of creativity of descriptions, complexity of puzzles, or technical sophistication. The most impressive submissions (as judged by our TAs) will be shown in class and/or stitched together into a combined work. Filename You must write this program in a file called dungeon.py. Some code is already provided to you. Examples (as executed in Thonny) EXAMPLE 1: >>> %Run dungeon.py You find yourself in a dark room. A candle lies on a small table in front of - you, providing a small amount of light. You cannot see any door or exit. However, there is what seems to be a keypad on one of the walls. > EXAMINE CANDLE The candle is tall and thin. You decide to pick it up to examine the rest of - the room more closely. You think you can make out half of a mathematical - equation on the walls: e to the power i times pi... > examine keypad It is a standard keypad, with digits from 0-9. Looking closely, you think you - can make out half of a mathematical equation scratched into the wall above - it: + 1... > smash keypad Invalid command. > Commands Commands are: examine candle, examine keypad Examples (as executed in Thonny) EXAMPLE 1: >>> %Run dungeon.py You find yourself in a dark room. A candle lies on a small table in front of - you, providing a small amount of light. You cannot see any door or exit. - However, there is what seems to be a keypad on one of the walls. > EXAMINE CANDLE The candle is tall and thin. You decide to pick it up to examine the rest of - the room more closely. You think you can make out half of a mathematical equation on the walls: e to the power i times pi... > examine keypad It is a standard keypad, with digits from 0-9. Looking closely, you think you - can make out half of a mathematical equation scratched into the wall above - it: + 1... > smash keypad Invalid command. > Commands Commands are: examine candle, examine keypad > enter 0 in keypad A secret door opens ! Q Search EXAMPLE 2: >>> %Run dungeon.py You have walked deep into a cave, looking for treasure, when suddenly you wander down a dead-end and hear the tumble of rocks from behind you. You are trapped! In front of you, the rock face is smooth and glistening with moisture. Moss of many different hues grows on the surface. There is an - eerie silence, punctuated only by the drops of water from the ceiling into - a small pond next to you. What do you do? > commands examine moss examine pond > examine moss You examine the moss closely. Most of the moss are hues of green, but there is - one very small area where it is bright purple. You suddenly realize this - purple moss is displayed in the shape of a key hole. Perhaps if you had a - key, you could use it here. > examine pond You kneel down and peer into the pond. In the reflection of the water, you see - yourself with a key in your hand. Your reflection then smiles and puts the - key in your pocket. Startled, you stand up and feel inside your pocket -- - there is a key there! If only you knew where to use it. > put key in keyhole A secret door opens in the rock wall! DBH # os dungeon.py encryption.py parentheses.py sequence.py * # Author: [your name here] # McGill ID: [your ID here] 3 # Assignment 1, Question 4 AUTHOR = "your name here" ROOM_NAME = "name of your escape room here" def escape_room(): print("Room description here.") commands = { # insert key-value pairs here while True: cmd = input(" ") # turn command to lowercase # print appropriate message #check if command is one of the 2 special commands # return True if user has entered correct answer 26 # Calling the function so that it runs when we run the filer 27 escape_room()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Fred R. McFadden, Jeffrey Slater, Mary B. Prescott

5th Edition

0805360549, 978-0805360547

More Books

Students also viewed these Databases questions