def test_round(self): card_1 = Card("What is the capital of Alaska?", "Juneau", 'Geography') card_2 = Card("What is the square root of 169?", "13", 'STEM') card_3 = Card("What is the power house of the freaking cell?", "Mitochondria", 'STEM') cards = [card_1, card_2, card_3] deck = Deck(cards) round = Round(deck) assert round.deck == deck assert round.turns == [] assert round.current_card() == card_1 new_turn = round.take_turn('Juneau') assert isinstance(new_turn, Turn) assert new_turn.correct() == True assert round.turns == [new_turn] assert round.number_correct() == 1 assert round.current_card() == card_2 newer_turn = round.take_turn('12') assert len(round.turns) == 2 assert (round.total_turns()) == 2 assert newer_turn.correct() == False assert newer_turn.feedback() == 'Incorrect.' assert round.number_correct() == 1 assert round.number_correct_by_category('Geography') == 1 assert round.number_correct_by_category('STEM') == 0 assert round.percent_correct() == 50.0 assert round.percent_correct_by_category('Geography') == 100.0 assert round.percent_correct_by_category('STEM') == 0.0 assert round.current_card() == card_3
def test_current_card(self): card_1 = Card("What is the capital of Alaska?", "Juneau", "Geography") card_2 = Card( "The Viking spacecraft sent back to Earth photographs and reports about the surface of which planet?", "Mars", "STEM") card_3 = Card( "Describe in words the exact direction that is 697.5° clockwise from due north?", "North north west", "STEM") cards = [card_1, card_2, card_3] deck = Deck(cards) round = Round(deck) self.assertEqual(round.current_card(), card_1)
card_5 = Card('Two US States dont recognize daylight savings. Hawaii is one. What is the other?', 'arizona', 'Random Trivia') card_6 = Card('The ____ is the loudest animal on Earth.', 'sperm whale', 'Random Trivia') cards = [card_1, card_2, card_3, card_4, card_5, card_6] deck = Deck(cards) round = Round(deck) total_cards = len(cards) categories = deck.all_categories() intro = "Welcome to Flashcards! You are playing with %s cards" % total_cards print(intro) while len(cards) > 0: print('*-*-*-*-*-*-*-*-*-*-*-*-*-*-*') print('This is card number %s out of %s' % (total_cards - len(cards) + 1, total_cards)) print('Question: %s' % round.current_card().question) guess = input('>>').lower() guess = round.take_turn(guess) answer = guess.card.answer print("%s" % round.turns[-1].feedback()) if guess.correct() == False: print('The answer is %s' % answer) print("****** Game over! ******") print("Here is how you did overall:") print('You had %s guesses correct out of %s questions for an overall score of %s' % (round.number_correct(), total_cards, round.percent_correct()))