How do you create a a python program that implements the following functions  get_top_card(card_stack) - returns the top card from any stack of cards (the return type is integer) and removes it from the card_stack . Used at the start of gameplay for dealing cards. This same function will also be used during each player’s turn to remove the top card from either the discard pile or from the deck. For example: get_top_card(lst) will return 53 and update the list (shown under section "Actual Program") to be lst = [3, 17, 11, 30, 33, 38, 49, 46, 25] add_card_to_discard(card, discard) - add the card (represented as just an integer) to the top of the discard pile (which is a list). This function does not return anything. For example: add_card_to_discard(77, lst) will update the list (shown under section "Actual Program") to be lst = [3, 17, 11, 30, 33, 38, 49, 46, 25, 53, 77] find_and_replace(new_card, card_to_be_replaced, hand, discard) - find the card_to_be_replaced (represented by an integer) in the hand and replace it with new_card. The replaced card then gets put on top of the discard pile. This function does not return anything. For example: find_and_replace(25, 50, [18, 50, 35], [28, 3]) will update the hand and discard piles to be hand = [18, 25, 35] discard = [28, 3, 50] main() - a function that puts it all together. Wherever possible, this function should call the above functions. The basic structure and the starting values of the deck and hand are pr

Operations Research : Applications and Algorithms
4th Edition
ISBN:9780534380588
Author:Wayne L. Winston
Publisher:Wayne L. Winston
Chapter13: Decision Making Under Uncertainty
Section13.4: Decision Trees
Problem 16P
icon
Related questions
Question

How do you create a a python program that implements the following functions 

    • get_top_card(card_stack) - returns the top card from any stack of cards (the return type is integer) and removes it from the card_stack . Used at the start of gameplay for dealing cards. This same function will also be used during each player’s turn to remove the top card from either the discard pile or from the deck.

      For example: get_top_card(lst) will return 53 and update the list (shown under section "Actual Program") to be

      lst = [3, 17, 11, 30, 33, 38, 49, 46, 25]
    • add_card_to_discard(card, discard) - add the card (represented as just an integer) to the top of the discard pile (which is a list). This function does not return anything.

      For example: add_card_to_discard(77, lst) will update the list (shown under section "Actual Program") to be

      lst = [3, 17, 11, 30, 33, 38, 49, 46, 25, 53, 77]
    • find_and_replace(new_card, card_to_be_replaced, hand, discard) - find the card_to_be_replaced (represented by an integer) in the hand and replace it with new_card. The replaced card then gets put on top of the discard pile. This function does not return anything.

      For example: find_and_replace(25, 50, [18, 50, 35], [28, 3]) will update the hand and discard piles to be

      hand = [18, 25, 35]
      discard = [28, 3, 50]
    • main() - a function that puts it all together. Wherever possible, this function should call the above functions. The basic structure and the starting values of the deck and hand are provided below:
deck:
[8, 3, 2]
discard pile:
[4]
Your current hand:
[5, 1, 7, 6]
Do you want this discard card: 4
Enter yes or no: yes
Enter the number of the card you want to kick out: 1
Your new hand is:
[5, 4, 7, 6]
deck:
[8, 3, 2]
discard pile:
[1)
Your current hand:
[5, 4, 7, 6]
Do you want this discard card: 1
Enter yes or no: no
The card you get from the deck is 2
Do you want to keep this card? Enter yes or no: yes
Enter the number of the card you want to kick out: 5
Your new hand is:
[2, 4, 7, 6]
deck:
[8, 3]
discard pile:
[1, 5)
Your current hand:
[2, 4, 7, 6]
Do you want this discard card: 5
Enter yes or no: no
The card you get from the deck is 3
Do you want to keep this card? Enter yes or no: no
Your new hand is:
[2, 4, 7, 6]
deck:
[8]
discard pile:
[1, 5, 3)
Your current hand:
[2, 4, 7, 6]
Do you want this discard card: 3
Enter yes or no: no
The card you get from the deck is 8
Do you want to keep this card? Enter yes or no: yes
Enter the number of the card you want to kick out: 6
Your new hand is:
[2, 4, 7, 8]
WOAH! Deck is empty. Exiting
Transcribed Image Text:deck: [8, 3, 2] discard pile: [4] Your current hand: [5, 1, 7, 6] Do you want this discard card: 4 Enter yes or no: yes Enter the number of the card you want to kick out: 1 Your new hand is: [5, 4, 7, 6] deck: [8, 3, 2] discard pile: [1) Your current hand: [5, 4, 7, 6] Do you want this discard card: 1 Enter yes or no: no The card you get from the deck is 2 Do you want to keep this card? Enter yes or no: yes Enter the number of the card you want to kick out: 5 Your new hand is: [2, 4, 7, 6] deck: [8, 3] discard pile: [1, 5) Your current hand: [2, 4, 7, 6] Do you want this discard card: 5 Enter yes or no: no The card you get from the deck is 3 Do you want to keep this card? Enter yes or no: no Your new hand is: [2, 4, 7, 6] deck: [8] discard pile: [1, 5, 3) Your current hand: [2, 4, 7, 6] Do you want this discard card: 3 Enter yes or no: no The card you get from the deck is 8 Do you want to keep this card? Enter yes or no: yes Enter the number of the card you want to kick out: 6 Your new hand is: [2, 4, 7, 8] WOAH! Deck is empty. Exiting
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Stack
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Operations Research : Applications and Algorithms
Operations Research : Applications and Algorithms
Computer Science
ISBN:
9780534380588
Author:
Wayne L. Winston
Publisher:
Brooks Cole
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,