logo Use CA10RAM to get 10%* Discount.
Order Nowlogo
(5/5)

The purpose of this assignment is to get more practice with boolean logic and branching. See the “assignment basics” file for more detailed information about getting assistance.

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

The purpose of this assignment is to get more practice with boolean logic and branching.

See the “assignment basics” file for more detailed information about getting assistance, running the test file, grading, commenting, and many other extremely important things. Each assignment is governed by the rules in that document.

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 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 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 visualizerto watch what the code does, which lines run, which branches are

  • From built-in functions, you are allowed to call abs(), int(), float(), str()

  • You are not allowed to import

  • 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 return a value based on the specification of the tasksGrading Rubric

Submitted correctly: Code is well commented:

Tester calculations correct:

TOTAL:

2

8

90

100

 

# see assignment basics file for file requirements! # see assignment basics file for how to comment! # see assignment basics file for how to test!

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

 

 

 

 

 

 

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 (i.e. be the lowest card when considering a sequence for straight).

2          3          4          5          6          7          8          9         10        11         12            13

15        16        17        18        19        20        21        22        23        24         25            26

28        29        30        31        32        33        34        35        36        37         38            39

41        42        43        44        45        46        47        48        49        50         51            52

 

 

Clubs

 

 

 

Diamonds

 

 

 

Hearts

 

 

 

Spades

 

 

1

 

14

 

27

 

40

 

 

Table 2

Assumptions

You may assume that:

  • The types of the values that are sent to the functions are the proper ones (card1is an integer not a float, ), you don’t have to validate them.

  • The functions are going to be called with usable values (e.g. card1is not negative, etc.), you don’t have to validate

  • All function parameters are guaranteed to be unique, you don’t have to validate them

Functions

The signature of each function is provided below, do not make any changes to them otherwise the tester will not work properly. Keep in mind that you must not write a main body for your program. You should only implement these functions; it is the tester that will be calling and testing each one of them. The following are the functions you must implement:

straight_flush(card1, card2, card3)

Description: The function checks whether the three cards make up a straight flush hand, and only that.

Parameters: card1 (int), card2 (int), card3 (int) are the three cards represented with the mapping provided in Table 2.

Return value: True or False

Examples:

straight_flush(2, 1, 3)     →   True

three_of_a_kind(card1, card2, card3)

Description: The function checks whether the three cards make up a three of a kind hand, and only that.

Parameters: card1 (int), card2 (int), card3 (int) are the three cards represented with the mapping provided in Table 2.

Return value: True or False

Examples:

three_of_a_kind(14, 27, 1)      →   True

straight(card1, card2, card3)

Description: The function checks whether the three cards make up a straight hand, and only that.

parameters: card1 (int), card2 (int), card3 (int) are the three cards represented with the mapping provided in Table 2.

Return value: True or False

Examples:

straight(34, 33, 35)    →   False       # straight flush

flush(card1, card2, card3)

Description: The function checks whether the three cards make up a flush hand, and only that.

Parameters: card1 (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(card1, card2, card3)

Description: The function checks whether the three cards make up a pair hand, and only that.

Parameters: card1 (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(card1, card2, card3)

Description: The function checks whether the three cards make up a high card hand, and only that.

Parameters: card1 (int), card2 (int), card3 (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(card1, card2, card3)

Description: Given three card numbers it returns a boolean depending on whether the cards form a sequence or not

same_suit(card1, card2, card3)

Description: Given three card numbers it returns a boolean depending on whether the cards have the same suit or not

(5/5)
Attachments:

Related Questions

. Introgramming & Unix Fall 2018, CRN 44882, Oakland University Homework Assignment 6 - Using Arrays and Functions in C

DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma

. The standard path finding involves finding the (shortest) path from an origin to a destination, typically on a map. This is an

Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t

. Develop a program to emulate a purchase transaction at a retail store. This program will have two classes, a LineItem class and a Transaction class. The LineItem class will represent an individual

Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th

. SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

. Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Um e HaniScience

529 Answers

Hire Me
expert
Muhammad Ali HaiderFinance

615 Answers

Hire Me
expert
Husnain SaeedComputer science

877 Answers

Hire Me
expert
Atharva PatilComputer science

634 Answers

Hire Me