Skip to content

Instantly share code, notes, and snippets.

View beaucarnes's full-sized avatar
💭
Follow me on Twitter: @beaucarnes

Beau Carnes beaucarnes

💭
Follow me on Twitter: @beaucarnes
View GitHub Profile
import random
def get_choices():
player_choice = input("Enter a choice (rock, paper, scissors): ")
options = ["rock", "paper", "scissors"]
computer_choice = random.choice(options)
choices = {"player": player_choice, "computer": computer_choice}
return choices
import random
class Card:
def __init__(self, suit, rank):
self.suit = suit
self.rank = rank
def __str__(self):
return f"{self.rank['rank']} of {self.suit}"
@beaucarnes
beaucarnes / polygon-calculator.py
Created July 26, 2021 13:32
polygon-calculator.py
class Rectangle:
def __init__(self, width, height):
self.width = width
self.height = height
def __repr__(self):
return f"Rectangle(width={self.width}, height={self.height})"
def set_width(self, num):
self.width = num
@beaucarnes
beaucarnes / arithemetic-arranger.py
Created July 26, 2021 13:30
arithemetic-arranger.py
def arithmetic_arranger(problems, solutions=False):
if len(problems) > 5:
return "Error: Too many problems."
line1 = ""
line2 = ""
line3 = ""
line4 = ""
for i, problem in enumerate(problems):
@beaucarnes
beaucarnes / python-blackjack-game.md
Created July 26, 2021 13:28
python-blackjack-game.md

It's time to make the final (and longest) class that runs the game. Create a class called game. Inside that class create a method called play. Inside that method create a variable called game_number and set it to zero.


class Game:
    def play(self):
        game_number = 0

@beaucarnes
beaucarnes / python-blackjack-hand.md
Last active August 10, 2023 19:24
python-blackjack-hand.md

350

Besides keeping track of the cards, Hand should also keep track of the value. Under self.cards, create self.value and set it to 0.


class Hand:
 def __init__(self):
@beaucarnes
beaucarnes / python_blackjack_instructions.md
Last active August 10, 2023 19:22
python_blackjack_instructions.md

TOTAL STEPS: 140

You are going to build a blackjack card game in Python.

Every card in blackjack has a suit, rank, and value. For example, the king of hearts has a rank of "king", a suit of "hearts", and a value of 10 (In blackjack, face cards are worth 10).


@beaucarnes
beaucarnes / keep_alive.py
Created December 10, 2020 15:42
Python Server for Discord Bot
from flask import Flask
from threading import Thread
app = Flask('')
@app.route('/')
def home():
return "Hello. I am alive!"
def run():
class Category:
def __init__(self, name):
self.name = name
self.ledger = []
def withdraw(self, amount, description = ""):
self.ledger.append({"amount": -amount, "description": description})
def deposit(self, amount, description = ""):
self.ledger.append({"amount": amount, "description": description})