Python - Why Python?: Similar but Different - Jupyter Notebook, VS Code
Head First Python: A Learner’s Guide to the Fundamentals of Python Programming, A Brain-Friendly Guide、 Paul Barry(著)、 O’Reilly Mediaの Chapter1.(Why Python?: Similar but Different)、EXERCISE(24/95)の解答を求めてみる。
import random
suits = ["Clubs", "Spades", "Hearts", "Diamonds"]
faces = ["Jack", "Queen", "King", "Ace"]
numbered = [2, 3, 4, 5, 6, 7, 8, 9, 10]
suits
['Clubs', 'Spades', 'Hearts', 'Diamonds']
def draw():
the_suit = random.choice(suits)
the_card = random.choice(faces + numbered)
return the_card, 'of', the_suit
draw()
(9, 'of', 'Clubs')