Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I want this to be done in python. Think carefully about the order you will check different properties. You might want to write some pseudocode

I want this to be done in python.

Think carefully about the order you will check different properties. You might want to write some pseudocode or perhaps draw a flowchart if this works better for you. Think first, then implement. Be careful what kinds of selection statements you use, and be sure to test your code with many examples. For instance, multiple if statements will not necessarily behave the same as a chain of if-elif-elif. When a specific test case isn't working, plug your code into the visualizer to watch what the code does, which lines run, which branches are taken. From built-in functions, you are allowed to call abs(), int(), float(), str() only. You are not allowed to import anything. You are not allowed to use loops, lists, sets, dictionaries and any feature that hasnt been covered in class yet.

image text in transcribedimage text in transcribedimage text in transcribed

Background Selection statements (if/elif/else combinations) allow us to write code that can execute different statements based on the current values seen in a particular run of the program. We will use this to write a program that performs calculations and selectively reports on different properties of the calculated values Guidelines Think carefully about the order you will check different properties. You might want to write some pseudocode or perhaps draw a flowchart if this works better for you. Think first, then implement Be careful what kinds of selection statements you use, and be sure to test your code with many examples. For instance, multiple if statements will not necessarily behave the same as a chain of if-elif-elif When a specific test case isn't working, plug your code into the visualizer to watch what the code does, which lines run, which branches are taken From built-in functions, you are allowed to call abs(), int(), float().str() only. You are not allowed to import anything. You are not allowed to use loops, lists, sets, dictionaries and any feature that hasn't been covered in class yet Don't forget to review the assignment basics file Insert comments in the lines you deem necessary Testing In this assignment testing will be done the same way as in the previous one. There will be no user Input or print statements. You're given a number of tasks and for each of them you must implement one Python function. The tester will be calling your functions with certain arguments and will be examining the return values to decide the correctness of your code. Your functions should not ask for user input and should not print anything, just retum a value based on the specification of the tasks Grading Rubric Submitted correctly Code is well commented: Tester calculations correct: 2 # see assignment basics file for file requirements! 8 # see assignment basics file for how to comment! 90 # see assignment basics file for how to test! TOTAL: 100 Note: If your code does not run and crashes due to errors, it will receive zero points. Turning in running code is essential. Scenario You're working for a software company and your manager asks you to implement a series of functions that another team will use to build a Three Card Poker game application. Three Card Poker is similar to the traditional poker but it's played with 3 instead of 5 cards, which makes it simpler as it has fewer hands to consider. For more details about the game read this article: https://en.wikipedia.org/wiki/Three_Card Poker Three Card Poker has the following six hands in descending order: Rank Description Example Straight flush Three suited cards in sequence Three of a kind Three cards of same rank Straight Three cards in sequence Flush Three suited cards Pair Two cards of same rank TE High card None of the above Table 1 Your task is to implement for each of these hands one function that takes three parameters (numbers that represent the three cards) and returns a boolean value, True or False, depending on whether the three cards make up the respective hand or not. We will use the Table 2 mapping to represent the standard 52 card deck with integers. Ace will always rank low (.e. be the lowest card when considering a sequence for straight). Ace 2 3 4 5 6 7 8 9 10 Jack Queen King Clubs 10 11 12 Diamonds 16 17 18 18 19 24 27 28 29 30 31 32 36 37 38 42 43 44 45 46 47 48 49 50 51 52 Table 2 flush(card, card2, card) Description: The function checks whether the three cards make up a flush hand, and only that. Parameters: cardi (int), card2 (int), card3 (int) are the three cards represented with the mapping provided in Table 2. Return value: True or False Examples: flush(41, 40, 42) False # straight flush pair (cardi, card2, cards) Description: The function checks whether the three cards make up a pair hand, and only that. Parameters: cardi (int), card2 (int), card3 (int) are the three cards represented with the mapping provided in Table 2. Return value: True or False Examples pair (33, 46, 20) False # three of a kind high_card (cardi, card2, card3) Description: The function checks whether the three cards make up a high card hand, and only that. Parameters: cardi (int), card2 (int), cards (int) are the three cards represented with the mapping provided in Table 2. Return value: True or False Examples: high_card(41, 5, 21) True Helper functions - OPTIONAL If you want to avoid repeating some computations again and again, you're allowed to create your own helper functions. This is optional, you don't need that to make your code run correctly. Some functions that you might find useful to implement are the following: suit(card) Description: Given a card number it returns the suit of the card as a string value (card) Description: Given a card number it returns the face value of the card as an int sequence (cardi, card2, card3) Description: Given three card numbers it returns a boolean depending on whether the cards form a sequence or not same_suit(cardi, card2, card3) Description: Given three card numbers it returns a boolean depending on whether the cards have the same suit or not Background Selection statements (if/elif/else combinations) allow us to write code that can execute different statements based on the current values seen in a particular run of the program. We will use this to write a program that performs calculations and selectively reports on different properties of the calculated values Guidelines Think carefully about the order you will check different properties. You might want to write some pseudocode or perhaps draw a flowchart if this works better for you. Think first, then implement Be careful what kinds of selection statements you use, and be sure to test your code with many examples. For instance, multiple if statements will not necessarily behave the same as a chain of if-elif-elif When a specific test case isn't working, plug your code into the visualizer to watch what the code does, which lines run, which branches are taken From built-in functions, you are allowed to call abs(), int(), float().str() only. You are not allowed to import anything. You are not allowed to use loops, lists, sets, dictionaries and any feature that hasn't been covered in class yet Don't forget to review the assignment basics file Insert comments in the lines you deem necessary Testing In this assignment testing will be done the same way as in the previous one. There will be no user Input or print statements. You're given a number of tasks and for each of them you must implement one Python function. The tester will be calling your functions with certain arguments and will be examining the return values to decide the correctness of your code. Your functions should not ask for user input and should not print anything, just retum a value based on the specification of the tasks Grading Rubric Submitted correctly Code is well commented: Tester calculations correct: 2 # see assignment basics file for file requirements! 8 # see assignment basics file for how to comment! 90 # see assignment basics file for how to test! TOTAL: 100 Note: If your code does not run and crashes due to errors, it will receive zero points. Turning in running code is essential. Scenario You're working for a software company and your manager asks you to implement a series of functions that another team will use to build a Three Card Poker game application. Three Card Poker is similar to the traditional poker but it's played with 3 instead of 5 cards, which makes it simpler as it has fewer hands to consider. For more details about the game read this article: https://en.wikipedia.org/wiki/Three_Card Poker Three Card Poker has the following six hands in descending order: Rank Description Example Straight flush Three suited cards in sequence Three of a kind Three cards of same rank Straight Three cards in sequence Flush Three suited cards Pair Two cards of same rank TE High card None of the above Table 1 Your task is to implement for each of these hands one function that takes three parameters (numbers that represent the three cards) and returns a boolean value, True or False, depending on whether the three cards make up the respective hand or not. We will use the Table 2 mapping to represent the standard 52 card deck with integers. Ace will always rank low (.e. be the lowest card when considering a sequence for straight). Ace 2 3 4 5 6 7 8 9 10 Jack Queen King Clubs 10 11 12 Diamonds 16 17 18 18 19 24 27 28 29 30 31 32 36 37 38 42 43 44 45 46 47 48 49 50 51 52 Table 2 flush(card, card2, card) Description: The function checks whether the three cards make up a flush hand, and only that. Parameters: cardi (int), card2 (int), card3 (int) are the three cards represented with the mapping provided in Table 2. Return value: True or False Examples: flush(41, 40, 42) False # straight flush pair (cardi, card2, cards) Description: The function checks whether the three cards make up a pair hand, and only that. Parameters: cardi (int), card2 (int), card3 (int) are the three cards represented with the mapping provided in Table 2. Return value: True or False Examples pair (33, 46, 20) False # three of a kind high_card (cardi, card2, card3) Description: The function checks whether the three cards make up a high card hand, and only that. Parameters: cardi (int), card2 (int), cards (int) are the three cards represented with the mapping provided in Table 2. Return value: True or False Examples: high_card(41, 5, 21) True Helper functions - OPTIONAL If you want to avoid repeating some computations again and again, you're allowed to create your own helper functions. This is optional, you don't need that to make your code run correctly. Some functions that you might find useful to implement are the following: suit(card) Description: Given a card number it returns the suit of the card as a string value (card) Description: Given a card number it returns the face value of the card as an int sequence (cardi, card2, card3) Description: Given three card numbers it returns a boolean depending on whether the cards form a sequence or not same_suit(cardi, card2, card3) Description: Given three card numbers it returns a boolean depending on whether the cards have the same suit or not

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions