Skip to content

Instantly share code, notes, and snippets.

View cjanis's full-sized avatar

Craig Janis cjanis

View GitHub Profile
@cjanis
cjanis / blackjack.py
Created May 8, 2018 03:24
A simple blackjack game built with Python
## initiate game
print(
'\n' * 100 +
'#' * 16 +
'\n\nSIMPLE BLACKJACK' +
'\nby Craig Janis\n' +
'\nOverview: You start with two cards\nand decide whether to "hit" (ask\nfor another card) or "stand" (end\nyour turn with the cards you\nalready have). The dealer starts\nwith one card visible and one\ncard face down, and after your\nturn, the dealer will have a\nchance to hit or stand. You win\nif you end the game with more\npoints the dealer, but fewer\nthan 21 points. If you go over 21\npoints, that\'s called a "bust".\nTies go to the Dealer.\n\n' +
'#' * 16
)
@cjanis
cjanis / tic-tac-toe.py
Created May 8, 2018 03:25
Command line tic tac toe game built in Python
b = ['O',' ',' ',' ',' ',' ',' ',' ',' ',' ']
def play(b,m=0):
# reset board if new game
if m == 0:
b = ['O',' ',' ',' ',' ',' ',' ',' ',' ',' ']
print('new game')
# update board
@cjanis
cjanis / loan-calculator.py
Created May 16, 2018 00:37
A loan calculator that allows for extra principal payments
# given principal and interest rate
# + periods = minimum payment amount and total cost
# + extra payment = periods, total cost, and savings over minimum
import math
def calculate(principal,rate_yearly,periods,extra=0):
# variables
rate_monthly = rate_yearly / 12 / 100