A community for students.

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

anonymous

  • 5 years ago

how can I create a deck of 52 cards when a single card is represented by a tuple ('H','A') with suits=['H','C','S','D'] and facevalue=['2','3','4','5','6','7','8','9','10','J','Q','K','A']? I tried to zip suits and facevalue but it didn't work

  • This Question is Closed
  1. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    what output do you want? I am only on lecture 5 so i can really only give you a list of tuples, that is easy enough. if you want individually named variables with a tuple each, your out of luck on this end the attached file contains a very simple program to create this list, bound to a variable z hope this helps you

    1 Attachment
  2. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    That's the output I want >>> makedeck() [('H', '2'), ('H', '3'), ('H', '4'), ('H', '5'), ('H', '6'), ('H', '7'), ('H', '8'), ('H', '9'), ('H', '10'), ('H', 'J'), ('H', 'Q'), ('H', 'K'), ('H', 'A'), ('C', '2'), ('C', '3'), ('C', '4'), ('C', '5'), ('C', '6'), ('C', '7'), ('C', '8'), ('C', '9'), ('C', '10'), ('C', 'J'), ('C', 'Q'), ('C', 'K'), ('C', 'A'), ('S', '2'), ('S', '3'), ('S', '4'), ('S', '5'), ('S', '6'), ('S', '7'), ('S', '8'), ('S', '9'), ('S', '10'), ('S', 'J'), ('S', 'Q'), ('S', 'K'), ('S', 'A'), ('D', '2'), ('D', '3'), ('D', '4'), ('D', '5'), ('D', '6'), ('D', '7'), ('D', '8'), ('D', '9'), ('D', '10'), ('D', 'J'), ('D', 'Q'), ('D', 'K'), ('D', 'A')]

  3. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Nessman thanks I am gonna look on test.py now

  4. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Can I get confirmation if what i produced was what you were looking for? I'd appreciate having my first fan (as shameless as it sounds)

  5. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    lol @ Nessman yes it did work thanks and I will be your fan after you answer more thing for me

  6. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    if its within my power

  7. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    ok Nessman how would u write a function function deal() which takes three arguments, a deck of cards, number of cards to deal and number of players and returns a tuple where the first part of the tuple is a list and the second part of the tuple is the list of cards which have not been dealt. The first part of the tuple gives a list of lists, where each list represents the hand of each player. Therefore it shows the cards that have been dealt to each player, for example if 4 cards were dealt to two players the lists looks like this example shown below, where the red list is hands of the first player and the blue list is the hands of the second player. ([ [('H', '2'), ('C', '6'), ('H', '10'), ('D', 'A')], [('D', '4'), ('H', '8'), ('H', 'Q'), ('C', '3')] ], [remaining deck])

  8. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    what fun, I'll get to work on it, but I'm not sure what I can do but I'll keep you posted, got a deadline?

  9. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    yeah friday thanx in advance

  10. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    You planning on going to vegas? haha and Nessman do you want to do it or does it matter because i think I can do this but I don't wanna swoop on your thing.

  11. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    for sure gonna hit vegas big time just like 21 lol, here's two for u onyx

  12. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    a function split that takes a list as an input and splits it into two. The first list is the first half of the given integer list and the second is second half of the integer list (if the list length is odd then the second half of the pair should be longer

  13. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    it should output >>>split([1,2,3,4,5,6,7]) ([1,2,3], [4,5,6,7])

  14. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    here's the next one:a recursive function interleave, which takes a pair of two integer lists as input and returns a list which contains all the items of the input lists, but in alternating order

  15. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    which outputs >>>interleave ([1,2,3], [4,5,6,7]) [1,4,2,5,3,6,7]

  16. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Ok I can do those really quick just one question what is this for?

  17. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    I am tryna implement a gofish game using python

  18. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    O ok

  19. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    here's your first one it splits it in half I have to go to bed otherwise i'd do other one I might do it in morning. lis=list(raw_input('Please enter a list:')) x=len(lis)/2 lis1=lis[:x] lis2=lis[x:] print lis1,lis2

  20. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    I'm fine if you want to do the dealing part onyx, I'll keep working on it regardless as its a fun exercise.

  21. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    ok Onyx have a great night

  22. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    O my fault I didn't think about the fact that your implementing this into a bigger program do you want me to rewrite it as a function.

  23. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    let me see how it works 1st but i get what u saying

  24. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    it worked well

  25. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    ok cool i'll do he other one tomorrow

  26. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Okay I got something to generate the hands, I need to create a function that then puts them in a pile and shows the remaining cards

  27. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    ok this is the second part of that function deal(), after this there is one function called gofish() which is a void

  28. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    here's the second part askForcard() which takes a card and a hand and return a tuple where first part of the tuple is a Boolean value if the cardvalue is found in the hand. For example, if we are asking our opponent for a ‘J’ and the opponents hand is [('H', 'A'), ('D', 'J')] we are retuned tuple where first part is a boolean value indicating if the card is present and second part returns the position of the card in the opponents hand, if the card is not there just return 0 for position

  29. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Whenever you have time u can look at my cesar cipher it's not 100% but it's good

  30. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Okay I got lost, but its late so maybe the last two posts will make sense in the morning, I haven't tested anything past a few test cases but i did finish a deal out function like you requested

  31. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    hit the post before i hit the attach button, deal pumps out what you want, hand gives you an single hand, and i included the deck program as a function all my pieces are functions, i can comment it if you want, but you'll have to wait until morning i feel like my sentences make less sense as the night progresses

    1 Attachment
  32. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    and i just realized that wasn't the latest version and still has a few test lines, sorry about that, just change the print statements at the end to how ever you want your output its also a list not a tuple, which can easily be fixed if you change the square brackets to parens [ ]->() on the [hands, remaining] so something that looks like return (hands, remaining)

  33. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    ok thanx again I will run the codes in tha morning my eyes are as heavy as lead right now have a great one 2marrow night same time, remember to look at tha cipher

  34. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Hey reckk does it really have to be recursive because if not I think I'd be done by now. haha I never completely understood recursive functions so it takes me a while to write them.

  35. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    wow it posted on wrong page that was wierd.

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

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.