''' A) Make a function that makes a list from a string of card symbols. In that function, make a string that has a symbol of every card in a deck and assign it to a list variable. Example: cardString = “AC AD AH AS KC KD KH KS……….” Use the split (string) function to make a list of the separated card string. B) Finish the card shuffling program started in class. Make sure that it has a programmer input that allows for decks of cards from 1 to 5. Also make sure to organize the code using functions, including a proper main() function as learned in HW2A. The output should be a List of shuffled card name strings. It should appear to be completely random—random has a shuffle function for lists (so when the TAs run it twice, the results should be different) C) Similarly, create a program that models 5 Die roll, like in the game Yahtzee. The 5 should be random six sided die. The output should be a list with 5 integers representing the 5 dies’ results from the roll. ''' # A) cardString = "AS AH AC AD 1S 1H 1C 1D 2S 2H 2C 2D 3S 3H 3C 3D 4S 4H 4C 4D 5S 5H 5C 5D 6S 6H 6C 6D 7S 7H 7C 7D 8S 8H 8C 8D 9S 9H 9C 9D 10S 10H 10C 10D JS JH JC JD QS QH QC QD KS KH KC KD" def listFromString(string): string.split(" ") return string listFromString(cardString) print(cardString) # B) def cardShuffle(): pass # C) def dieRoll(): pass
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question