Compsci 101, Spring 2012, Feb. 14 <3

By entering your name/net-id below you indicate you are in class on February 9 to answer these questions and that you have answered them. Your name should not appear unless you are in class when answering these questions.
Name_________________   net-id _______   Name_________________   net-id _______


Name_________________   net-id _______   Name_________________   net-id _______

These questions are based on the code for rolling dice and simulating poker hands in Cartester.py and DiceRolling.py

  1. What is the purpose of the line counts = [0]*13 in get_rank_counts of the Cardtester.py module?

    1. Initialize 13 counters, a list of 13 zeros

    2. Create a string of 13 zeros

    3. Create a list of 13 empty strings

  2. In the function get_deck what is the last card stored in the deck that is returned?

    1. king of clubs

    2. king of spades

    3. aces of clubs

    4. other

  3. Which explains the function get_hand the best?

    1. Take five cards from the top of the deck

    2. Shuffle the deck, take the first five cards

    3. Generate five random cards

  4. Which can replace the if statement in is_pair? (more than one may be possible)

    1. return ranks.count(2) == 1 and ranks.count(1) == 3

    2. return ranks.count(1) == 3 and ranks.count(2) == 1

    3. return ranks.count(2) == 1