anonymous
  • anonymous
Hello. I am trying to figure out how to uses lists and class methods together for object oriented programming. Can anyone explain how to do this? I know how to create a class: "class Card(object): def__init__(self, rank, suit): self.rank = rank self.suit = suit" And, a list: "rank = {'Ace':1, 'Two':2, 'Three':3, 'Four':4, 'Five':5, 'Six':6, 'Seven':7, 'Eight':8, 'Nine':9, 'Ten':10, 'Jack':11, 'Queen':12, 'King':13}" Now how do I do this in Python using this list in the above class method?
Computer Science
  • Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
SOLVED
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
jamiebookeater
  • jamiebookeater
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
anonymous
  • anonymous
o mg yes
rsmith6559
  • rsmith6559
First, that's not a list, it's a dictionary. Classes are blueprints for objects, they don't really exist in your program. You use classes to create objects (instances) of a class. The object is what you work with in your program. If I want a card object, I would: myCard = Card( "Ace", "Spade" ) This creates a Card object named myCard and runs the __init__() function to initialize myCard to be the ace of spades. To run methods of myCard, my code would be: print myCard.__str__() (You don't have any of your own methods in the post for me to use) This invokes the __str__() method on the myCard object.
anonymous
  • anonymous
I ended up working something out that involved a lot of elif statements and while it could be written better I'm still learning and this is just the best that I can do at this time. Thank you for the help! I was going to send you a private message but you have that turned off for some reason, but I do have another question that I would prefer to ask privately if you don't mind re-enabling your PM? Thanks!

Looking for something else?

Not the answer you are looking for? Search for more explanations.

More answers

rsmith6559
  • rsmith6559
It's on.

Looking for something else?

Not the answer you are looking for? Search for more explanations.