Solved by verified expert:I will upload the instructions for this program. you will modify the code file then go so that when it open the input file it will produce the output file. you don’t need to use the files with this program
code.pdf

input_file.pdf

produced_output.pdf

program_instruction.pdf

Unformatted Attachment Preview

2/8/2018
https://www.cs.montana.edu/paxton/classes/csci127/programs/program2/cribbage.py
# ————————————-# Do not change anything below this line
# ————————————-def process_hands(cribbage_input, cards_in_hand):
for hand in cribbage_input:
hand = hand.split()
hand_as_list = []
for i in range(cards_in_hand):
hand_as_list.append([int(hand[0]), hand[1]])
hand = hand[2:]
print_hand(hand_as_list)
evaluate_hand(hand_as_list)
# ————————————-def main():
cribbage_file= open(“cribbage.txt”, “r”)
process_hands(cribbage_file, 3)
cribbage_file.close()
# ————————————-main()
https://www.cs.montana.edu/paxton/classes/csci127/programs/program2/cribbage.py
1/1
2/8/2018
3
2
5
6
8
1
9
4
4
7
3
9
9
1
8
6
2
https://www.cs.montana.edu/paxton/classes/csci127/programs/program2/cribbage.txt
diamonds 3 spades 3 clubs
hearts 2 diamonds 4 hearts
hearts 6 diamonds 5 clubs
hearts 8 diamonds 8 hearts
hearts 9 diamonds 10 hearts
clubs 3 clubs 2 clubs
diamonds 8 hearts 10 spades
diamonds 5 spades 3 hearts
clubs 2 diamonds 3 spades
spades 6 spades 5 spades
clubs 5 clubs 7 clubs
clubs 6 clubs 1 clubs
clubs 1 clubs 6 clubs
clubs 9 clubs 6 clubs
diamonds 7 diamonds 8 hearts
clubs 7 hearts 8 spades
clubs 6 hearts 4 spades
https://www.cs.montana.edu/paxton/classes/csci127/programs/program2/cribbage.txt
1/1
2/8/2018
https://www.cs.montana.edu/paxton/classes/csci127/programs/program2/output.txt
Cribbage Hand
————Card 1: 3 of Diamonds
Card 2: 3 of Spades
Card 3: 3 of Clubs
Points scored: 6
Cribbage Hand
————Card 1: 2 of Hearts
Card 2: 2 of Diamonds
Card 3: 4 of Hearts
Points scored: 2
Cribbage Hand
————Card 1: 5 of Hearts
Card 2: 6 of Diamonds
Card 3: 5 of Clubs
Points scored: 2
Cribbage Hand
————Card 1: 6 of Hearts
Card 2: 8 of Diamonds
Card 3: 8 of Hearts
Points scored: 2
Cribbage Hand
————Card 1: 8 of Hearts
Card 2: 9 of Diamonds
Card 3: 10 of Hearts
Points scored: 3
Cribbage Hand
————Card 1: 1 of Clubs
Card 2: 3 of Clubs
Card 3: 2 of Clubs
Points scored: 3
Cribbage Hand
————Card 1: 9 of Diamonds
Card 2: 8 of Hearts
Card 3: 10 of Spades
Points scored: 3
Cribbage Hand
————Card 1: 4 of Diamonds
Card 2: 5 of Spades
Card 3: 3 of Hearts
Points scored: 3
Cribbage Hand
————Card 1: 4 of Clubs
Card 2: 2 of Diamonds
Card 3: 3 of Spades
Points scored: 3
Cribbage Hand
https://www.cs.montana.edu/paxton/classes/csci127/programs/program2/output.txt
1/2
2/8/2018
https://www.cs.montana.edu/paxton/classes/csci127/programs/program2/output.txt
————Card 1: 7 of Spades
Card 2: 6 of Spades
Card 3: 5 of Spades
Points scored: 3
Cribbage Hand
————Card 1: 3 of Clubs
Card 2: 5 of Clubs
Card 3: 7 of Clubs
Points scored: 2
Cribbage Hand
————Card 1: 9 of Clubs
Card 2: 6 of Clubs
Card 3: 1 of Clubs
Points scored: 2
Cribbage Hand
————Card 1: 9 of Clubs
Card 2: 1 of Clubs
Card 3: 6 of Clubs
Points scored: 2
Cribbage Hand
————Card 1: 1 of Clubs
Card 2: 9 of Clubs
Card 3: 6 of Clubs
Points scored: 2
Cribbage Hand
————Card 1: 8 of Diamonds
Card 2: 7 of Diamonds
Card 3: 8 of Hearts
Points scored: 6
Cribbage Hand
————Card 1: 6 of Clubs
Card 2: 7 of Hearts
Card 3: 8 of Spades
Points scored: 5
Cribbage Hand
————Card 1: 2 of Clubs
Card 2: 6 of Hearts
Card 3: 4 of Spades
Points scored: 0
https://www.cs.montana.edu/paxton/classes/csci127/programs/program2/output.txt
2/2
2/8/2018
CSCI 127, Program 2
Program 2: Three Card Cribbage
Logistics
Due Date: Friday, February 9th no later than 11:59 p.m.
Partner Information: You may complete this assignment individually or with exactly one partner. If you
work with a partner, you must both be enrolled in the same lab section or you will both lose 10 points.
Submission Instructions: Upload your solution, renamed to YourFirstName-YourLastNamePartnerFirstName-PartnerLastName-Program2.py to the BrightSpace Program 2 Dropbox. If you
work with a partner, only one person should submit the solution. To make the recording of grades easier,
write both names in the BrightSpace Dropbox comment box.
Deadline Reminder: Once the submission deadline passes, BrightSpace will no longer accept your Python
submission and you will no longer be able to earn credit. Thus, if you are not able to fully complete the
assignment, submit whatever you have before the deadline so that partial credit can be earned.
Learning Outcomes
To solve this problem, you need to understand the following new Python concept: lists.
Simplified Three Card Cribbage Scoring
A hand consists of three different cards. Each card contains a numeric value that ranges from 1 to 10 and a
suit where the possible values are “clubs”, “diamonds”, “hearts” or “spades”.
If all three cards contain the same numeric value, that is a called a three of a kind and is worth 6 points.
If two of the three cards contain the same numeric value (but the third card contains a different value), that
is called a pair and is worth 2 points.
If the three cards contain three consecutive numeric values (in any order), that is called a sequence and is
worth 3 points.
For each unique combination of cards that adds up to 15, that is called a fifteen and is worth 2 points for
each fifteen.
The value of a hand is the sum of anything that scores points. For example, a hand consisting of the 4 of
hearts, 6 of diamonds and 5 of hearts is worth 5 points (3 for the sequence, 2 for the fifteen).
Assignment
Download cribbage.py and modify it so that when it is run on this input file, it produces this output file.
Note: the input file (cribbage.txt) should be located in the same directory as the python program.
Input File Information
We will study files later this semester.
The input file contains an unknown number of cribbage hands. Each line contains a three card cribbage
hand in this format: Card 1 Value, Card 1 Suit, Card 2 Value, Card 2 Suit, Card 3 Value, Card 3 Suit.
All cribbage hands are valid.
Note: Your program might be tested on a different set of cribbage hands so it is important to make your
solution as general as possible.
Grading – 100 points
https://www.cs.montana.edu/paxton/classes/csci127/programs/program2/
1/2
2/8/2018
CSCI 127, Program 2
10 points – Every three of a kind is identified correctly. (All or nothing.)
15 points – Every pair is identified correctly. (5 points for each incorrect answer up to 15 points.)
15 points – Every sequence is identified correctly. (5 points for each incorrect answer up to 15 points.)
15 points – Every fifteen is identified correctly. (5 points for each incorrect answer up to 15 points.)
10 point – Every hand that scores in multiple ways (e.g. a hand that scores both a fifteen and three of a
kind) is scored correctly. (5 points for each incorrect answer up to 10 points.)
10 points – A separate function is used to determine each different type of scoring (e.g. three of a kind).
(3 points for each missing function up to 10 points.)
10 points – The format of your output matches the format of the sample output exactly. (2 points for each
type of difference up to 10 points.)
15 points – The Python solution is properly commented, easy to understand and does not contain
unnecessary code. (3 points for each type of improvement up to 15 points.)
https://www.cs.montana.edu/paxton/classes/csci127/programs/program2/
2/2

Purchase answer to see full
attachment