Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

python class has a builtin super simple way you can just shuffle a list, you can just call the shuffle method, you can put the

python class has a builtin super simple way you can just shuffle a list, you can just call the shuffle method, you can put the this into a method if you like but you don't really need to)

 

Example

 

import random

 

mylist = ["apple", "banana", "cherry"]

random.shuffle(mylist)

 

print(mylist)

 

Example

 

import random

 

mylist = [1,2,3,4]

random.shuffle(mylist)

 

print(mylist)



 

Make a program that takes bets on horse races. There will be four types of bets described below. The horse race result is generated by a function a function called ReadySetgo that simply scrambles the horses into random order as a "psuedo/simulated" horse race and that tells you the race results. I will provide you with the code for your ReadysetGo function as shown above you can just call shuffle to simulate the race. (shown above). You can put the code into a function or class if you want to but if you are a beginner you don't need to.

We assume four horses run in a race, and we assume the horses are named by numbers 1-4. Advanced students if you feel adventurous you can (but are not obligated to) give the horses more creative names and make the number of horses running in the race programmable rather than fixed to four.

Let's say the horses are initially in the order 1 2 3 4. If you call Readysetgo to randomly shuffle them (that's our pseudo-race) we might get a race result of 2 1 4 3 for example, which means: horse #2 came in first, horses #1 came in second, horse #4 came in third and horse # 3 came in fourth.

The user starts out with 200 dollars. Betting costs are as follows: An Exacta bet costs 10 dollars, and an Exactabox bet costing 5 dollars, a Trifecta bet costs 25 dollars, and a Trifectabox bet costs 20 dollars. Advanced students you can (but are not obligated to) make this bet cost programmable, ie some students allow the user to decide how much they want to bet on the race, and some even let the user borrow money and get more in debt if they keep on losing and run out their 200 dollars)

We need our program to allow the user to place any of the four types of bets. The user is given a USD (US dollars) cash balance of 200 dollars for betting. The menu options allow the user to place any of the four bets, run the race, see the result, see what their cash balance is, and exit the program. Advanced students if you wanted to, you could save a history of the bets they placed so they could also ask for their betting history.

There are two easy ways to implement the user interface for this, one is going to be with a simple text based menu, and one is going to be with a simple string/command-line based menu. A text menu is where you give the user a choice of options and tell them for example: enter 1 to place an exactabet, enter 2 to place an exactabox bet, etc. ie:

 

Welcome to Horse Betting!

Please select from the following options 1-6

Place an exact bet

Place an exactabox bet

Place a trifectabet

Please a trifectabox bet

See your USD balance

Exit

etc

They then choose the option they want and then you ask them what horses they pick as the winners, get their pick, run the race, see if they won, etc. A text based menu is going to be the better choice to implement if you are a beginner. A string based menu is a slightly different input style, where the input is more of a command-line driven sentence that gets parsed into components in the program to determine what they want, for example, if the user inputs the command line sentence

> exacta 1 2

the program will read that in, divide that up into the components and figure out that they are placing an exacta bet with horse 1 and 2 as the picks.

You can choose whatever way you want to create the interface.

EXACTA bets cost 10 dollars to place but you win 100 dollars if you guess the exact winning order of the top two horses.

An EXACTABOX bet costs 5 dollars to place but you win 25 if you guess the top two horses in any order.

TRIFECTA bets cost 25 dollars to place but you win 200 dollars if you guess the exact winning order of the top three horses.

An TRIFECTABOX bet costs 20 dollars to place but you win 150 if you guess the top three horses in any order.

OK here are some betting examples explained (as what it would look like in a string based menu interface)

Example Input:

EXACTA 1 3

EXACTA 1 3 means that we are betting that the winner and second place will be exactly in that order (ie; the bet is betting that horse #1 will come in first place, and horse #3 will come in second place)

EXACTABOX 1 4

EXACTABOX 1 4 means that we are betting that the winning two horses will be 1 and 4 in any order. So if the race comes in as 4 1 2 3, you still win the bet since horse number 1 and 4 are still in the top two places.

And also two more types of bet

TRIFECTA 1 3 2

TRIFECTA 1 3 2 means that we are betting that the winners will be exactly in that order (ie; the bet is saying that horse #1 will come in first place/win, horse #3 will come in second place/place, and that horse #2 will come into third place/show.

TRIFECTABOX 1 4 2

TRIFECTABOX 1 4 2 means that we are betting that the winning three horses will be 1, 4, and 2 in any order. So if the race comes in as 1 2 4 3, you still win the bet because horse number 1, 2, and 4 are in the top three places.


 

(40 points)

Get the input from the user.  program that will handle getting the EXACTA bet, and the EXACTABOX bet as input from the user. Be sure to also handle the trifecta and trifecta box bets too so its 25 points for the exacta and exactabox and another 25 points for the trifecta and trifecta box

As explained you can make a string based interface or you can make an intuitive text based interface menu to take in their bets (intuitive menu prompts user to choose 1 for exacta, 2 for exacta box, asks for the two horses, etc).

(10 points)

Cheat, and by this I mean, show the results of the race to the user before they make their bets, that way they can cheat and win if they want. Ie if they know the winning sequence was 1 3 2 4, they could make an exact bet of 1 3 and they should win the money. This is critical to cheat and show the winning sequence because it's going to make it ten thousand times easier to make sure your code actually works.

(25 points)

Use the function I give you called Readysetgo (or make your own if you are advanced) which will run a race with four horses and randomly generate for you the winning sequence (simulates a race). Take the users input, then run the race using this function, then figure out if they won or not.

(25 points)

(12.5 )Keep track of your money as USD and assume you start out with 200 dollars. When you make a bet, deduct the cost of the bet from your USD, and when you win a bet, add the win amount to your USD. Be able to print out your balance as a menu or command option.

(12.5) Put your logic into a loop so you can keep placing bets and running races and see your balance as you go. Implement a Exit string command (for string based menu) or add an Exit option in your intuitive menu to quit the program.

 Provide a Screenshot of the Source Code along with a typed version of the Source Code and provide a screenshot of the output along with a typed version of the output. Final  implementation of the user interface is  going to be with a simple text based menu.

Step by Step Solution

3.40 Rating (150 Votes )

There are 3 Steps involved in it

Step: 1

Heres an implementation of the program that allows the user to place bets on horse races using a simple textbased menu python import random class HorseRace def initself selfbalance 200 selfbets def pl... 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

Recommended Textbook for

Management And Organisational Behaviour

Authors: Laurie Mullins

7th Edition

0273688766, 978-0273688761

More Books

Students also viewed these Programming questions