Python coding please. Also if you could add comments that would be greatly appri
ID: 3851357 • Letter: P
Question
Python coding please. Also if you could add comments that would be greatly appriciated. I asked this earlier and got an okay answer but there were some errors. The print statement needs to be identical or else it won't work either. If anyone can help me out I would greatly appreciate it.
There are base python codes that are used for this. They are found in the link below:
http://www.cse.msu.edu/~cse231/Online/Projects/Project06/
Summer 2017 CSE 231 Programming Project #6 Edit on 6/1917 a skeleton file is has been available on Mirmir and is now available in the same directory as this document posted on 6/18) Edit on 6/2017 we provide a cannonical function in the skeleton file to order cards so your output can more easily match the Mimir tests for Test1 and Test2 Assignment overview This assignment focuses on the design, implementation and testing of a Python program which uses classes to solve the problem described below. Note: you are using a class we provide; y are not designing a class. It is worth 95 points (9.5% of course grade) and must be completed no later than 11:59 PM on Monday, June 2 Assignment Deliverable The deliverable for this assignment is the following file: proj06.py the source code for your Python program. Be sure to use the specified file name and to submit it for grading via the Mirmir system before the project deadline. Assignment Background The goal of this project is to gain practice with use of classes and creating functions. You will design and implement a Python program which plays simplified Texas Hold'em Poker. The program should deal two cards to two players (one card to each player, then a second card to each player, and then five community cards which players share to make their hands. A poker hand is the best five cards from the community cards plus the player's cards (i.e., best 5 out of 7 cards total). The goal of this assignment is to find the category ofeach player's hand and determine the winner. The rules of this game are relatively simple and you can find information about the game and about the poker hands in the links below. Kcep in mind that you will only find the category of the hands and all nine cards can be dealt at once (a real poker game deals cards in stages to allow for betting, but we aren't betting). http://en.wikipedia.org/wiki/Texas holdem http://en. wikipedia.org/wiki/Poker handsExplanation / Answer
import cards
import random
deck = cards.small_deck()
class Player(object):
def __init__(self, number):
self.number = number
self.points = 0
self.hand = []
def __str__(self):
return "Player %d" % self.number
players = [Player(num + 1) for num in xrange(6)] # create six numbered players
rounds = 6
hand_size = 4
for round_num in xrange(rounds):
random.shuffle(deck)
print "Hand %d deal:" % (round_num + 1)
for _ in xrange(hand_size):
for player in players:
player.hand.append(deck.pop())
for player in players:
player.hand.sort()
print "%s's hand: %s" % (player, cards.hand_string(player.hand))
print
print "Dropping pairs:"
for player in players:
new_hand, dropped_cards, pairs = cards.drop_pairs(player.hand)
deck.extend(player.hand) # realistically we can dump the hand now anyway.
player.hand = []
player.points += pairs
how_many = pairs
plural = "s"
if pairs == 0:
how_many = "no"
elif pairs == 1:
plural = ""
print "%s dropped %s pair%s" % (player, how_many, plural)
print
print "Score:"
for player in players:
print "%s: %d" % (player, player.points)
print
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.