Question
python code for Family feud game is a game that asks the player questions and if their answer is close to or matches the list
python code for Family feud game is a game that asks the player questions and if their answer is close to or matches the list of answers we have from the survey they get the score mapped to that answer. The code should read out the questions to the player and if the answer matches any of the answers in the list, they get the score associated with it. The game will be running on pycharm and we used dictionaries and lists so that we could a sum of the scores and also print out the list of answers after the player is done answering the question or get the 3 strikes. 3 strikes resulting from giving wrong answers will stop you from answering that question and it will read you the next question and will give the player three chances to answer that question right. if he gets 3 strikes the program reads the next question until all the questions have been read out. The program should be able to give out the total score from answering all the questions.Below is some of the starting code
import random
f = open("C:\\path\\to\\questions.txt" , 'rU')
questions = []
answers = []
ansq = []
#most of this could be changed. I don't need that answers list I don't think
for line in f:
if ".." not in line: #if it's a question (i.e. without leader lines to the point amount, thus not an answer)
if line == " ":
pass
else:
questions.append(line)
else: #if it's not a question, then it's an answer (which is a wrong assumption I need to fix)
if line == " ":
pass
else:
answers.append(line) #so add it to the answers list instead
#if question matches line
#look for the answers below it until the next question
# while line not in questions
# print line
qtoask = random.choice(questions) #pick a random question from the questions list
f.seek(0) # go back to beginning of file
for line in f:
if line == qtoask: #rescan it; if the line matches the random question
line = f.next() #go to the next line
#ansq.append(line)
while ".." in line:#and find all the responses to that question (they all have dotted leader lines)
#This if condition will never be true if it's in this while block. Duh.
if line == " ": #if the line is a newline (Enter)
pass #skip it
else:
ansq.append(line) #otherwise, add it to the list of answers to the question
line = f.next() #go to the next line and do it again
print qtoask
for a in ansq: #Beautify. Just print the list of answers so it's easy to read
print a + " "
f.close()
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