i'm in project have make alterations on code see below.
quizgame 3 levels , 3 answer sets, , game function @ moment checks answers (from user input) if correct altogether , not iteratively , not prompt user try again , not give user chance so.
according review should make modifications, don't know how! so, when user inputs correct answer, code should replace blank correct answer , reprint level before asking answer next blank. game should check make sure - user answer correct. when isn't, game should loop , ask user try again. please me this.
## easy, medium, hard quiz , answers - inputs easy_quiz = '''you have chosen level easy. here text.fill in blanks.\n in python write programs need make comparsions between values\n can comparsions signs < > in math , equality comparsions\n ___ (not equal) , ___ (equal).\n these return boolean value (which can ___ or ___ )''' easy_answers = ['!=', '==', 'true', 'false'] medium_quiz = '''you have chosen level medium. here text.,\n fill in blanks!\n here definitons:\n call numbers without variable ___\n programming grounded in ___, important know how\n programming languages simple math.\n ___ (also known methods) take input , return output. \n ___ used map or associate things want store \n keys need them. can implement 1 using that.''' medium_answers = ['magic numbers', 'arithmetic', 'functions', 'false'] hard_quiz = '''you have chosen hard level. here text.,\nfill in blanks! python called ___ programming language. means there construct in python called class. usefule ___.\nin python, class can implement operations invoked ___(such arithmetic operations or ___ , slicing)''' hard_answers = ['object-oriented', 'modeling tool', 'special syntax', 'subscripting'] ## code (logic) ## behavior: return quiz , answers upon difficulty level, input: quizes , ## matching answers, output: appropriate quiz def get_quiz(level): if level == "easy": return easy_quiz if level == "medium": return medium_quiz if level == "hard": return hard_quiz ## return correct answer list def get_answers(level): if level == "easy": return easy_answers if level == "medium": return medium_answers if level == "hard": return hard_answers ## behavior: function evaluates answers, inputs are: user answers, right ## quiz answers, output: c def evaluate_answers(user_answers, quiz_answers): if user_answers == quiz_answers: return "correct. congratulations! have completed quiz!" else: return "incorrect. please try again." ##run game def game(): print "hello. quiz." ## ask game level. (user input) difficulty_level = raw_input ("choose difficulty level(easy, medium, hard):") ## load quiz depending on user input. quiz = get_quiz (difficulty_level) print quiz ## ask answers (user input) user_answers = [] in range(1,5): answer = raw_input("answer blank " + str(i) + ":") user_answers.append(answer) print user_answers quiz_answers = get_answers(difficulty_level) result = evaluate_answers(user_answers, quiz_answers) print result ## run game game()
Comments
Post a Comment