Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In Michael Dawson\'s textbook there is a question in ch. 4 project number 4: Wri

ID: 3536522 • Letter: I

Question

In Michael Dawson's textbook there is a question in ch. 4 project number 4:

Write a program that displays all the cards from a deck of playing cards using the same format as project 3. Again, use one tuple torepresent all of the possible card values and another tuple to represent the possible suits. The program should display:

Ac Ah As Ad

2c 2h 2s 2d

3c 3h 3s 3d

4c 3h 3s 3d

...and so on

Project 3 said write a program that prints out a string representation of a random card from a deck of playing cards . So if the program selects the jack of clubs it would print Jc. Use one tuple to rep. all of the card values and anot6her tuple for the suits.

I'm working with python 2.68 and we are only up to chapter four that deals with for loops, the random module, concatinating and other stuff you do with tuples so please don't use high level code and keep it simple.

Here's what ihave so far but who know if i'm on the right track:

import random
value = ('A','2','3','4','5','6','7','8','9','T','J','Q','K')
suit = ('c','d','h','s')
value = random.choice(value)
suit = random.choice(suit)
card = value + suit
for letter in card:
    print(card)

Explanation / Answer

import random value = ('A','2','3','4','5','6','7','8','9','T','J','Q','K') suit = ('c','d','h','s') for letter in value: for suit_letter in suit: print(letter + suit_letter + " "), print(" ") value = random.choice(value) suit = random.choice(suit) card = value + suit for letter in card: print(card)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote