slove using python 3 when running the code it should give something like this ht
ID: 3601153 • Letter: S
Question
slove using python 3
when running the code it should give something like this https://www.youtube.com/watch?v=yLNJ98Avyrw&feature=youtu.be
the code given to me :
import random
def shuffle_deck(deck):
'''(list of str)->None
Shuffles the given list of strings representing the playing deck
'''
random.shuffle(deck)
def create_board(size):
'''int->list of str
Precondition: size is even positive integer between 2 and 52
Returns a rigorous deck (i.e. board) of a given size.
'''
board = [None]*size
letter='A'
for i in range(len(board)//2):
board[i]=letter
board[i+len(board)//2 ]=board[i]
letter=chr(ord(letter)+1)
return board
def print_board(a):
'''(list of str)->None
Prints the current board in a nicely formated way
'''
for i in range(len(a)):
print('{0:4}'.format(a[i]), end=' ')
print()
for i in range(len(a)):
print('{0:4}'.format(str(i+1)), end=' ')
def wait_for_player():
'''()->None
Pauses the program/game until the player presses enter
'''
input(" Press enter to continue. ")
print()
def print_revealed(discovered, p1, p2, original_board):
'''(list of str, int, int, list of str)->None
Prints the current board with the two new positions (p1 & p2) revealed from the original board
Preconditions: p1 & p2 must be integers ranging from 1 to the length of the board
'''
# YOUR CODE GOES HERE
#############################################################################
# FUNCTIONS FOR OPTION 1 (with the board being read from a given file) #
#############################################################################
def read_raw_board(file):
'''str->list of str
Returns a list of strings represeniting a deck of cards that was stored in a file.
The deck may not necessarifly be playable
'''
raw_board = open(file).read().splitlines()
for i in range(len(raw_board)):
raw_board[i]=raw_board[i].strip()
return raw_board
def clean_up_board(l):
'''list of str->list of str
The functions takes as input a list of strings representing a deck of cards.
It returns a new list containing the same cards as l except that
one of each cards that appears odd number of times in l is removed
and all the cards with a * on their face sides are removed
'''
print(" Removing one of each cards that appears odd number of times and removing all stars ... ")
playable_board=[]
# YOUR CODE GOES HERE
return playable_board
def is_rigorous(l):
'''list of str->True or None
Returns True if every element in the list appears exactlly 2 times or the list is empty.
Otherwise, it returns False.
Precondition: Every element in the list appears even number of times
'''
# YOUR CODE GOES HERE
####################################################################3
def play_game(board):
'''(list of str)->None
Plays a concentration game using the given board
Precondition: board a list representing a playable deck
'''
print("Ready to play ... ")
# this is the funciton that plays the game
# YOUR CODE GOES HERE
#main
# YOUR CODE TO GET A CHOICE 1 or CHOCE 2 from a player GOES HERE
# YOUR CODE FOR OPTION 1 GOES HERE
# In option 1 somewhere you need to and MUST have a call like this:
# board=create_board(size)
# YOUR CODE FOR OPTION 2 GOES HERE
# In option 2 somewhere you need to and MUST have the following 4 lines of code one after another
#
#print("You chose to load a deck of cards from a file")
#file=input("Enter the name of the file: ")
#file=file.strip()
#board=read_raw_board(file)
#board=clean_up_board(board)
Explanation / Answer
your Image was not visible completely Kindly provide us better quality image so that your question can be answered
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.