Answered step by step
Verified Expert Solution
Question
1 Approved Answer
# Badge: Haunted House Explorer # Initialize the total hours spent in the house total _ hours = 0 # Function to explore a room
# Badge: Haunted House Explorer
# Initialize the total hours spent in the house
totalhours
# Function to explore a room
def exploreroomroomname:
spookydescriptions
"Living Room": "You feel a cold breeze and hear faint whispers in the air.",
"Kitchen": "The old dishes rattle as if someone is cooking in the dark.",
"Bedroom": "The creaking sound of footsteps echoes through the room.",
# Display the spooky description for the selected room
printf
You enter the roomnamespookydescriptions.getroomname
# Main program loop
while True:
# Display options to the user
print
Choose an option:"
print Explore the Living Room"
print Explore the Kitchen"
print Explore the Bedroom"
print Leave the Haunted House"
# Get user input
choice inputEnter the number of your choice:
# Logic to earn the badge keeping track of total hours
if choice.isdigit:
choice intchoice
if choice :
totalhours
exploreroomLiving Room", "Kitchen", "Bedroom"choice
elif choice :
printfYou have spent a total of totalhours hours in the haunted house. Farewell!"
break
else:
printInvalid choice. Please enter a number between and
else:
printInvalid input. Please enter a number." explain how the hour tracker works keep the badge name make sure you included this in code and leave a comment explaining the program
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started