games · MIT License
Overview
A simple game of blackjack against the dealer: hit or stand to get closer to 21 without going over, with a running tally of wins, losses, and pushes.
- Owner-tested on a TI calculator
- Version 1.0.0
- 1616 bytes
- Uses random
Tried it? Did this program work on your calculator?
Before you run it
- TI-84 Plus CE Python · No calculator OS or Python App version has been verified.
- TI Connect CE .py transfer to the Python App; the owner's transfer details were not recorded
- Every card is drawn at random from an endless deck, so any card can come up at any time.
- There is no betting; the game keeps a count of wins, losses, and pushes while it runs.
- Only 1 (hit) and 2 (stand) are accepted on your turn; anything else asks again.
Play it here first
Play a full round right here before you download. The screen below runs the same steps as the calculator game: type your answer in the box under it and press Enter, just as you would on the calculator. Each round picks a new secret, and nothing you type is saved.
TI-84 Plus CE Python · screen preview
How to play
How to play Blackjack
About the game
You and the dealer each get two cards. The goal is to finish closer to 21 than the dealer without going over. Going over 21 is a bust, and a bust loses straight away.
Number cards count their number, J, Q, and K count 10, and an Ace counts 11, or 1 if 11 would put the hand over 21. There is no betting: the game just keeps a tally of wins, losses, and pushes (ties).
Controls
1- hit: take another card
2- stand: keep your total and let the dealer play
enter- confirm your choice
Y- deal another hand; any other answer ends the game
How to play
- Press enter at the opening screen. You see both of your cards and one of the dealer's; the other shows as ?.
- Type 1 to hit or 2 to stand. You can keep hitting until you stand, reach 21, or bust.
- When you stand, the dealer turns over the hidden card and keeps drawing until reaching 17 or more.
- The higher total wins. If the dealer busts, you win. Equal totals are a push.
- If your first two cards make 21, you skip your turn and the dealer plays out the hand. If the dealer's first two cards make 21, the hand ends straight away.
Tips
- You cannot bust by hitting on 11 or less, because no single card can take that total past 21.
- The dealer must stand on any 17, including a soft 17 such as A 6. As long as you have not busted, the dealer keeps drawing until reaching at least 17.
- When the dealer shows a 7 or higher, a total under 17 is often not enough; many players hit until they reach 17.
- Cards are drawn at random from an endless deck, so counting cards does not help.
Good to know
- The win, loss, and push totals start over each time you run the program.
- A two-card 21 wins like any other higher total; it is not paid extra.
- To stop the game at any time, press the [on] key. The Python App returns to the shell.
Exact reviewed bytes
Source code
# DuckieDai(TM) Blackjack# TI-84 Plus CE Pythonfrom random import randintdef clear():print('\n'*7)def card():n=randint(1,13)if n==1:return 11,'A'if n==11:return 10,'J'if n==12:return 10,'Q'if n==13:return 10,'K'return n,str(n)def score(hand):t=sum(hand)a=hand.count(11)while t>21 and a:t-=10a-=1return tdef draw(hand,names):v,s=card()hand.append(v)names.append(s)def show(who,names,hand):print(who+':',' '.join(names))print('Total:',score(hand))def intro():print('DUCKIEDAI(TM)')print('BLACKJACK')print(' __')print(' ___(o )> quack!')print(' \\ <_. )')print(" `---'")print('by DuckieDai')print('hiddenwordscanner.com')input('Press Enter ')clear()intro()w=l=p=0while 1:h=[];hn=[];d=[];dn=[]for i in range(2):draw(h,hn)draw(d,dn)clear()print('BLACKJACK')print('Dealer:',dn[0],'?')show('You',hn,h)ps=score(h);ds=score(d)if ps==21 or ds==21:passelse:while ps<21:c=input('1 Hit 2 Stand? ')if c=='2':breakif c!='1':continuedraw(h,hn)clear()print('Dealer:',dn[0],'?')show('You',hn,h)ps=score(h)if ps<=21 and ds!=21:while score(d)<17:draw(d,dn)clear()show('Dealer',dn,d)show('You',hn,h)ps=score(h);ds=score(d)if ps>21:print('BUST! You lose.')l+=1elif ds>21 or ps>ds:print('YOU WIN! QUACK!')w+=1elif ds>ps:print('Dealer wins.')l+=1else:print('PUSH! Tie game.')p+=1print('Wins:',w,'Losses:',l)print('Pushes:',p)if input('Again? Y/N ').upper()!='Y':breakclear()print('DuckieDai(TM) done!')print('hiddenwordscanner.com')
- Filename
BLACKJ.py- Size
- 1616 bytes
- SHA-256
c6b24899cafcca1499718761c019468c94a2bba8cfdbc5b3a31163ca055672a1
Usage
Inputs
- 1 to hit or 2 to stand
- Y to deal another hand, anything else to stop
Outputs
- Your cards and total, with one dealer card showing
- Both final hands and totals, then BUST, YOU WIN, Dealer wins, or PUSH
- Running totals of wins, losses, and pushes
Units: Card points; no units.
Assumptions and limitations
Assumptions
- Every card is drawn at random from an endless deck, so any card can come up at any time.
- There is no betting; the game keeps a count of wins, losses, and pushes while it runs.
Constraints
- Only 1 (hit) and 2 (stand) are accepted on your turn; anything else asks again.
- The dealer draws until reaching 17 or more and then stands, including on a soft 17.
Known failures
- A two-card 21 is not paid extra; it wins like any other higher total, and two 21s tie.
- The win, loss, and push totals reset when the program is started again.
Compatibility and review
- Review status
- Owner-tested on a TI calculator
- Tested on
- Owner reports personally playing this game on a TI-84 Plus CE Python calculator; the test date, OS version, and Python App version were not recorded
- What happened
- Owner reported pass on the calculator. The file is published exactly as provided; this exact file has not yet been rerun on a calculator.
- Dependencies
- random
- Suggested calculator name
BLACKJ— you can give it another valid, unique name when you transfer it- Desktop test cases
- Not available for this interactive-only source
This exact source auto-launches an interactive calculator session, so compatibility evidence comes from the recorded physical-device review rather than an importable desktop fixture.
Transfer and launch
Download the .py file, send it to your calculator with TI Connect CE as BLACKJ or another name, then open the Python App and start a game. Press [on] to stop at any time. This release has no verified calculator OS or Python App version; treat transfer and execution as unverified until independently tested.
Full installation and troubleshooting guide. Check your teacher's or exam's rules before using any program.
Version history
- 1.0.0 — current version, published . Download this reviewed version
Related learning
Enjoying a DuckieDai game? Every game and program here is free. If you would like to say thanks, you can leave a tip on Cash App ($duckiedai214) or read what tips pay for.
Independent compatibility resource: Hidden Word Scanner is independent and is not affiliated with or endorsed by Texas Instruments. TI product names describe compatibility only.
Action-count privacy: Successful downloads, preview starts, and preview completions increment same-origin aggregate counters, and so does a Yes or No answer about whether the program worked. Your browser notes that you answered; that note is never sent to the site. No entered values, source text, IP address, account, cookie, device identifier, or fingerprint is stored with these counts.