In Checkpoint A, the game will not yet be playable as a two-player game. It will be playable by you in a type of "solitaire mode." Implement these functions from the template following the description (specification) in their docstring: show_top_card() get_top_card() add_card_to_discard() check_racko() find_and_replace() play_hand() The main function to drive the game has been provided. Missing input/output statements are part of play_hand() and left for you to implement, guided by the sample input/output. None of the other functions left to implement use input or print. The case / capitalization of user input should be ignored. On any invalid user input, the program should exit with a non-zero exit code. Hint: Use Python Tutor. as much as possible when testing gameplay. Zybooks requires you specify all your inputs in advance and it is less enjoyable to play that way. Sample input/output 1 When the inputs are: no yes 1 yes 5 yes 7 The expected behavior is (inputs are shown in-line) -------------------------------------------------- Deck: [8, 3, 2] Discard pile: [4] Your current rack is: [5, 1, 7, 6] The top discard card is 4 Do you want it? (yes or no): no The card from the deck is 2 Do you want it? (yes or no): yes Enter the number of the card you want to kick out: 1 Your new rack is: [5, 2, 7, 6] -------------------------------------------------- Deck: [8, 3] Discard pile: [4, 1] Your current rack is: [5, 2, 7, 6] The top discard card is 1 Do you want it? (yes or no): yes Enter the number of the card you want to kick out: 5 Your new rack is: [1, 2, 7, 6] -------------------------------------------------- Deck: [8, 3] Discard pile: [4, 5] Your current rack is: [1, 2, 7, 6] The top discard card is 5 Do you want it? (yes or no): yes Enter the number of the card you want to kick out: 7 Your new rack is: [1, 2, 5, 6] You got Racko-O! Sample input/output 2 When the inputs are: YeS 10 The expected behavior is (inputs are shown in-line) -------------------------------------------------- Deck: [8, 3, 2] Discard pile: [4] Your current rack is: [5, 1, 7, 6] The top discard card is 4 Do you want it? (yes or no): YeS Enter the number of the card you want to kick out: 10 Error: invalid card. Sample input/output 3 When the inputs are: NO Maybe The expected behavior is (inputs are shown in-line) -------------------------------------------------- Deck: [8, 3, 2] Discard pile: [4] Your current rack is: [5, 1, 7, 6] The top discard card is 4 Do you want it? (yes or no): NO The card from the deck is 2 Do you want it? (yes or no): Maybe Error: choice can be only yes or no.
In Checkpoint A, the game will not yet be playable as a two-player game. It will be playable by you in a type of "solitaire mode."
Implement these functions from the template following the description (specification) in their docstring:
- show_top_card()
- get_top_card()
- add_card_to_discard()
- check_racko()
- find_and_replace()
- play_hand()
The main function to drive the game has been provided.
- Missing input/output statements are part of play_hand() and left for you to implement, guided by the sample input/output.
- None of the other functions left to implement use input or print.
- The case / capitalization of user input should be ignored.
- On any invalid user input, the program should exit with a non-zero exit code.
Hint: Use Python Tutor. as much as possible when testing gameplay. Zybooks requires you specify all your inputs in advance and it is less enjoyable to play that way.
Sample input/output 1
When the inputs are:
no
yes
1
yes
5
yes
7
The expected behavior is (inputs are shown in-line)
--------------------------------------------------
Deck: [8, 3, 2]
Discard pile: [4]
Your current rack is: [5, 1, 7, 6]
The top discard card is 4
Do you want it? (yes or no): no
The card from the deck is 2
Do you want it? (yes or no): yes
Enter the number of the card you want to kick out: 1
Your new rack is: [5, 2, 7, 6]
--------------------------------------------------
Deck: [8, 3]
Discard pile: [4, 1]
Your current rack is: [5, 2, 7, 6]
The top discard card is 1
Do you want it? (yes or no): yes
Enter the number of the card you want to kick out: 5
Your new rack is: [1, 2, 7, 6]
--------------------------------------------------
Deck: [8, 3]
Discard pile: [4, 5]
Your current rack is: [1, 2, 7, 6]
The top discard card is 5
Do you want it? (yes or no): yes
Enter the number of the card you want to kick out: 7
Your new rack is: [1, 2, 5, 6]
You got Racko-O!
Sample input/output 2
When the inputs are:
YeS
10
The expected behavior is (inputs are shown in-line)
--------------------------------------------------
Deck: [8, 3, 2]
Discard pile: [4]
Your current rack is: [5, 1, 7, 6]
The top discard card is 4
Do you want it? (yes or no): YeS
Enter the number of the card you want to kick out: 10
Error: invalid card.
Sample input/output 3
When the inputs are:
NO
Maybe
The expected behavior is (inputs are shown in-line)
--------------------------------------------------
Deck: [8, 3, 2]
Discard pile: [4]
Your current rack is: [5, 1, 7, 6]
The top discard card is 4
Do you want it? (yes or no): NO
The card from the deck is 2
Do you want it? (yes or no): Maybe
Error: choice can be only yes or no.
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 3 images