# [Tutor] question

Roelof Wobben rwobben at hotmail.com
Tue Sep 28 21:15:00 CEST 2010

```

From: rwobben at hotmail.com
To: davea at ieee.org
Subject: RE: [Tutor] question
Date: Tue, 28 Sep 2010 19:14:29 +0000

> Date: Tue, 28 Sep 2010 10:49:28 -0400
> From: davea at ieee.org
> To: rwobben at hotmail.com; tutor at python.org
> Subject: Re: [Tutor] question
>
> On 9/28/2010 10:22 AM, Roelof Wobben wrote:
> >
> >
> >
> >> Date: Tue, 28 Sep 2010 10:02:27 -0400
> >> From: davea at ieee.org
> >> To: rwobben at hotmail.com
> >> CC: tutor at python.org
> >> Subject: Re: [Tutor] question
> >>
> >>
> >>
> >> On 2:59 PM, Roelof Wobben wrote:
> >>> Hello,
> >>>
> >>>
> >>> http://openbookproject.net/thinkcs/python/english2e/ch16.html
> >>>
> >>> But I don't get it why aces are now lower then deuces in the cmp function.
> >>>
> >>>
> >>> Roelof
> >>>
> >>>
> >> Why would you be surprised that aces are lower than deuces? If aces are
> >> represented by 1, and deuces by 2, then 1 is less than 2.
> >>
> >> Notice that because self.suit is compared first, an ace of spades is
> >> higher than a deuce of hearts. It's only within the same suit that an
> >> ace is "less than" a deuce.
> >>
> >> DaveA
> >>
> >>
> >>
> >>
> >
> > Hello Dave,
> >
> >
> >
> > In some games in the Netherlands Aces can have a value of 11 or 1 .
> >
> > So if Aces are 11 then Deuces is lesser then Aces.
> >
> >
> >
> > Can I say that the position of the list is a representation of the value.
> >
> >
> >
> > Roelof
> >
> >
> >
> The class attribute was assigned as follows:
>
> ranks = ["narf", "Ace", "2", "3", "4", "5", "6", "7",
> "8", "9", "10", "Jack", "Queen", "King"]
>
>
> So "Ace" is at position 1. And if you want an Ace, you'd have to supply a 1 to the constructor.
>
> I would certainly agree that in many games this wouldn't be the desired case. Some games specify aces higher than kings, some have no ordering among face cards, some let the player choose.
>
> If the Card class needed to cover all cases, then one might need to make the __cmp__() method parameterizable, so that at different times, the cards might sort differently.
>
> But this is one implementation of the Card class, and hopefully it's self-consistent in the course.
>
>
>
> DaveA
>
>
>
> >
>

Oke,

Thanks.
Then now figuring out how to solve this problem :

Modify __cmp__ so that Aces are ranked higher than Kings

So aces with value 1 must be higher then Kings with 11

I think I have to make another rule in the rank part like this

If self.rank = Aces and self.rank = Kings then return -1 or 1

Tomorrrow I will investigate this.

Roelof

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100928/52048641/attachment.html>
```