Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

doesnt seems to work can any help be provided

0 views
Skip to first unread message

Arun Nair

unread,
Oct 26, 2006, 9:21:28 AM10/26/06
to
import string

class Card:

# Not sure if I need to set these first???
# suitList = ()
# rankList = ()

def __init__(self,suit,rank):
self.suit = suit
self.rank = rank

def __repr__(self):
return str(self)

def __str__(self):
return "%s of %s" %
(self.rankList[self.rank],self.suitList[self.suit])

def __cmp__(self,other):
if self.suit > other.suit:
return 1
if self.suit < other.suit:
return -1
if self.rank > other.rank:
return 1
if self.rank < other.rank:
return -1
else:
return 0

def getCard(cards):
# Break each card into suit and rank
rankList , suitList = string.split(cards," ")
return Card(rankList,suitList)

class Deck:
def __init__(self):
self.cards = []
for suit in range(4):
for rank in range(1,14):
self.cards.append(Card(suit,rank))

def main():
# Open the file with the cards in them
filename = raw_input('Enter the file name for the cards >>')
infile = open(filename,'r')

# Set the first card in the list
cards = getCard(infile.readline())

# Process the extra lines
for line in infile:
s = getCard(line)
infile.close()
a=Deck()
print a


main()

Bruno Desthuilliers

unread,
Oct 26, 2006, 9:44:51 AM10/26/06
to
Arun Nair wrote:

> import string

You don't need it. Use "some string".split() instead

> class Card:

class Card(object):

> # Not sure if I need to set these first???

Not only do you need to define them, but it would probably be a good
idea to populate them. And BTW, () is a tuple, not a list (but tuples
are perfectly ok for this use case).


> # suitList = ()
> # rankList = ()


(snip whole code listing)

Do you really expect us to run your code, fix the bugs and send it back?
Or are we supposed to guess what's "not working" ?

Please take a few minutes to read this:
http://catb.org/esr/faqs/smart-questions.html

with particular attention to the following point:
http://catb.org/esr/faqs/smart-questions.html#beprecise

HTH


--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'on...@xiludom.gro'.split('@')])"

Fredrik Lundh

unread,
Oct 26, 2006, 9:49:48 AM10/26/06
to pytho...@python.org
Bruno Desthuilliers wrote:

> Please take a few minutes to read this:
> http://catb.org/esr/faqs/smart-questions.html

or better, check if the the academic misconduct rules for the university you're
attending happens to say anything about "collusion".

</F>

Steve Holden

unread,
Oct 26, 2006, 10:03:39 AM10/26/06
to pytho...@python.org
Arun Nair wrote:
[stuff]

You will find people are willing to help, even sometimes with homework
questions, when questioners show some evidence that they are looking to
learn rather than simply to have their problems solved for them.

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

Grant Edwards

unread,
Oct 26, 2006, 10:19:32 AM10/26/06
to
On 2006-10-26, Arun Nair <nair...@gmail.com> wrote:
> import string
>
> class Card:

Could you please keep this homework assignment in a single
thread in order to make it easier to ignore for those of us who
don't want to work on this particular homework problem for you?

If not, then you're likely to get get killfiled by many people
(all your postings will get ignored).

--
Grant Edwards grante Yow! Why is everything
at made of Lycra Spandex?
visi.com

Ben Finney

unread,
Oct 26, 2006, 6:53:55 PM10/26/06
to pytho...@python.org
Bruno Desthuilliers <on...@xiludom.gro> writes:

> Arun Nair wrote:
> > [more homework assignments, not working]


> Do you really expect us to run your code, fix the bugs and send it
> back?

Yes, he apparently does. He's told us that it's homework, but that he
hasn't learned enough from his teacher.

Apparently that learning also didn't include the prohibitions against
colluding with others. Nevertheless, I'll bet they are still present.

> Please take a few minutes to read this:
> http://catb.org/esr/faqs/smart-questions.html
>
> with particular attention to the following point:
> http://catb.org/esr/faqs/smart-questions.html#beprecise

In this case, a better section is:

Grovelling is not a substitute for doing your homework
<URL:http://catb.org/esr/faqs/smart-questions.html#id273364>

--
\ "When I was a little kid we had a sand box. It was a quicksand |
`\ box. I was an only child... eventually." -- Steven Wright |
_o__) |
Ben Finney

Fredrik Lundh

unread,
Oct 27, 2006, 1:46:36 AM10/27/06
to pytho...@python.org
Ben Finney wrote:

> Apparently that learning also didn't include the prohibitions against
> colluding with others. Nevertheless, I'll bet they are still present.

http://www.csu.edu.au/acad_sec/manuals/gcontm.htm

Part G6

Collusion

A student colludes when he or she works without permission with
another person or persons to produce work which is then presented as
work completed independently by the student.

Collusion includes, but is not limited to:

- writing the whole or part of an assignment with another person;

- using the notes of another person to prepare an assignment;

- using for an assignment the resource materials of another person
that have been annotated or parts of the text highlighted or
underlined by that person;

- allowing another student, who has to submit an assignment on the
same topic, access to one's own assignment under conditions which
would give that other student an advantage in submitting his or her
assignment

</F>

0 new messages