$20
Black Jack In this assignment, you'll be implementing a watered down version of Black Jack (a simple card game) for 2 people to play. The functions you need to write are described below. Each function description shows several examples of calling the function. For each example, code executed is shown in blue, output is in green, user input is in turquoise, return values are in rust. Your function should work properly with the arguments/input used in those examples and any other acceptable values (each function description gives the accepted type of value for each parameter and/or input). Create a new file called "blackjack.py". In the file, write the following functions: 1) (10 pts) Write a function called ask_user that takes 3 parameters. The first parameter is a prompt to print to the user. The second parameter is one possible response that the user can give. The third parameter is another possible response that the user can give. This function should: a. Using the given prompt, ask the user for input. b. Check to see if what the user typed in matches one of the two options provided by the second and third parameters. c. If the user typed in something other than the two options, give the user the prompt again. Keep doing this until the user enters a valid response. d. Once the user has entered one of the valid responses, return the user's response. Here are some examples of calling the function: ask_user('Heads or tails? ', 'heads', 'tails') Heads or tails? heads heads ask_user('Are you in college? ', 'yes', 'no') Are you in college? what? Are you in college? nope Are you in college? are you silly? Are you in college? no no 2) (10 pts) Write a function called print_card that takes 2 parameters. The first parameter is someone's name. The second parameter is a number between 1 and 13 (inclusive). The function should print "______ draws a _____" with the first blank replaced by the user's name that was passed into the function, and the second blank replaced by the value given to the function. However, if the value is a 1, 11, 12, 13, print Ace, Jack, Queen, King respectively instead of printing the number. Here are some examples of calling the function: print_card('Alex', 4) Alex draws a 4 3 print_card('Sam', 12) Sam draws a Queen 3) (10 pts) Write a function called get_ace_value that takes no parameters. This function should ask the user if they want to use a 1 or 11 as their Ace value. It should continually ask the user until they type 1 or 11 (Hint: You may have a function that could help with this). It should then return the users response as an int. Here are some examples of calling the function: get_ace_value() Should the Ace be 1 or 11? 1 1 get_ace_value() Should the Ace be 1 or 11? 6 Should the Ace be 1 or 11? 11 11 4) (10 pts) Write a function called deal_card that takes a single parameter representing the user's name. This function should: a. Pick a random number between 1 and 13 (inclusive). You can use the randrange function from the random module to do this. This number represents a card’s value b. Print out what the user drew (hint: you may have a function that prints out card values). c. Return the point-value of the card defined as follows: If the card is a Jack, Queen, or King, the point-value is 10. If the card is an Ace, ask the user if the value should be 1 or 11 (hint: you may have a function that does this). If the card is any other number then the number itself is the point-value. Here are some examples of calling the function: deal_card('Tracey') Tracey draws a 2 2 deal_card('Jamie') Jamie draws a King 10 deal_card('Jesse') Jesse draws an Ace Should the Ace be 1 or 11? 1 1 4 5) (10 pts) Write a function called adjust_for_bust that takes a single integer parameter. If the given number is greater than 21, print "Bust!" and return -1. Otherwise return the number that was passed in. Here are some examples of calling the function: adjust_for_bust(18) 18 adjust_for_bust(33) Bust! -1 6) (10 pts) Write a function called hit_or_stay that takes a single parameter representing the value of a player's card hand. a. If the given value is less than 21, ask the user if he or she would like to hit or stay. b. If the user types something else, repeatedly ask the user the same question until the user types either ‘hit’ or ‘stay’. c. Return True if the user chose hit. Otherwise return False. Here are some examples of calling the function: hit_or_stay(24) False hit_or_stay(7) Hit or stay? yes Hit or stay? hit True 7) (15 pts) Write a function called play_turn that takes a single parameter representing a user's name. The function will: a. Print out that it's the current players turn b. Deal the player a card c. Print out the player's total score d. Ask the player if they want to hit. If they do, deal another card e. Do not deal cards to the player if the player busts f. Return the total value of all the cards the player drew unless the player busted. g. If the player busted, return -1 Here is an example of calling the function: 5 play_turn('Taylor') ==========[ Current player: Taylor ]========== Taylor draws a 10 Total: 10 Hit or stay? hit Taylor draws a 9 Total: 19 Hit or stay? stay 19 ==========[ Current player: Taylor ]========== Taylor draws a 10 Total: 10 Hit or stay? hit Taylor draws a 10 Total: 10 Hit or stay? hit Taylor draws a 10 Bust! -1 8) (10 pts) Write a function called determine_winner that takes the 4 parameters name1, name2, score1 and score2. If player one and player two have the same score, the function prints out that they tie. Otherwise it prints out who won. Here are some examples of calling the function: determine_winner('Alex', 'Sam', -1, 4) Sam wins! determine_winner('Pat', 'Elliot', 20, 20) Pat and Elliot tie! 9) (15 pts) In main: a. Ask each player for their name b. Greet them c. Let the first player play a turn d. Let the second player play a turn e. Determine who won f. Ask the users if they want to play again g. Play again if they say yes Here is an example game: 6 Player 1 name: Alex Player 2 name: Sam Welcome to BlackJack Alex and Sam ==========[ Current player: Alex ]=========== Alex draws a 9 Total: 9 Hit or stay? hit Alex draws a 3 Total: 12 Hit or stay? hit Alex draws a 6 Total: 18 Hit or stay? stay ==========[ Current player: Sam ]=========== Sam draws a 7 Total: 7 Hit or stay? hit Sam draws a 9 Total: 16 Hit or stay? hit Sam draws a King Total: 26 Bust! Alex wins! Would you like to play again? no And another example game: 7 Player 1 name: Jesse Player 2 name: Jamie Welcome to BlackJack Jesse and Jamie ==========[ Current player: Jesse ]=========== Jesse draws a 10 Total: 10 Hit or stay? ye Hit or stay? s Hit or stay? hit Jesse draws a 9 Total: 19 Hit or stay? stay ==========[ Current player: Jamie ]=========== Jamie draws an Ace Should the Ace be 1 or 11? 11 Total: 11 Hit or stay? hit Jamie draws a 9 Total: 20 Hit or stay? stay Jamie wins! Would you like to play again? yes ==========[ Current player: Jesse ]=========== Jesse draws a 5 Total: 5 Hit or stay? stay ==========[ Current player: Jamie ]=========== Jamie draws a King Total: 10 Hit or stay? stay Jamie wins! Would you like to play again? no 10) Ensure that all of your functions and the file have been properly documented. 11) Verify that your program works, then upload your file to the D2L dropbox.