Skip to content

Instantly share code, notes, and snippets.

View TomColBee's full-sized avatar

Thomas Beeson TomColBee

View GitHub Profile
@TomColBee
TomColBee / TicTacToe.py
Last active July 9, 2018 07:10
Tic Tac Toe Game
# create a board
board = [" " for i in range(9)]
# print instructions
print("Hello, welcome to Tic Tac Toe!")
print()
print("To play, just input the number of the space you wish to have...")
row1 = "| 1 | 2 | 3 |"
@TomColBee
TomColBee / HangmanGame.py
Last active July 9, 2018 17:47
Beginner Project - Create hangman game
# Hangman game
# import packages
import random
import os
# define function to replace "?" with letters guessed
def progress(word, question_marks, letter):
progress = ""
for i in range(0,len(word)):
@TomColBee
TomColBee / FirstFactorial.py
Created July 15, 2018 06:52
Coderbyte Python Challenge: FirstFactorial
# Have the function FirstFactorial(num) take the num parameter being passed and return the factorial of it.
# E.g. if num = 4, return (4 * 3 * 2 * 1) = 10.
# For the test cases, the range will be between 1 and 18 and the input will always be an integer.
def FirstFactorial(num):
# Set var sum to be 1
sum = 1
# For x in the range 2 to num+1, let sum be equal to sum multiplied by x ------- range(start, stop, step)
@TomColBee
TomColBee / ReverseString.py
Last active July 15, 2018 06:56
Coderbyte Python Challenge - Reverse String
# Have the function FirstReverse(str) take the str parameter being passed and return the string in reversed order.
# For example: "Hello World and Coders" should return the string "sredoC dna dlroW olleH".
def FirstReverse(str):
str = str[::-1]
return str
print FirstReverse(raw_input())
@TomColBee
TomColBee / LetterChanges.py
Created July 15, 2018 07:01
Coderbyte Python Challenge: LetterChanges
# Have the function LetterChanges(str) take the str parameter being passed
# and modify it using the following algorithm.
# Replace every letter in the string with the letter following it in the alphabet
# (ie. c becomes d, z becomes a).
# Then capitalize every vowel in this new string (a, e, i, o, u) and
# finally return this modified string.
@TomColBee
TomColBee / HedgehogDodge.py
Last active July 18, 2018 18:43
PyGames Project: Hedgehog Dodge - Dodge the falling hedgehogs
# Hedgehog Dodge Game
# Game where the user moves the hedgehog left or right to dodge falling blocks
# Blocks fall quicker as the game progresses
import pygame, sys, os, time, random
from pygame.locals import *
pygame.init() # initialise pygame
FPS = 30 # set frames per second
fpsClock = pygame.time.Clock() # set fpsClock
@TomColBee
TomColBee / DiamondStarKata.py
Created August 8, 2018 18:43
Diamond Shaped Kata Stars
def diamond(n):
orig_n = int(n)
orig_n_2 = int(n)
# first line of star
spaces = int(n-1)
print(" " * spaces + "*")
# middle section
@TomColBee
TomColBee / DiamondLetterKata.py
Created August 8, 2018 18:44
Diamond Shaped Star Letters
def diamond_letters(n):
# convert string to upper case
n = n.upper()
# create letter string
letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
# find given letter n in the letters string and return index+1
n = letters.find(n) + 1
@TomColBee
TomColBee / Cinema.py
Created June 13, 2018 22:33
Python Bible: Cinema Project - While Loop - Dictionary - Conditional Statements - Input
# List films that we have at the cinema [age requirement, number of tickets available]
films = {
"Finding Dory": {"Age": 3, "Tickets Available": 5},
"Bourne": {"Age": 15, "Tickets Available": 10},
"Tarzan": {"Age": 12, "Tickets Available": 7},
"Ghost Busters": {"Age": 12, "Tickets Available": 2},
"High School Musical 3": {"Age": 5, "Tickets Available": 25},
"The Brother's Grimm": {"Age": 12, "Tickets Available": 3},
"Harry Potter": {"Age": 11, "Tickets Available": 1}
}
@TomColBee
TomColBee / IrisClassification.py
Created July 25, 2018 07:13
Machine Learning: Simple Classification using Iris dataset
# Machine learning example using iris dataset
# Classification problem.
# Uses a variety of different algorithms to predict class based on sepal/petal lengths and widths
# Python version 3.6
# Source: https://machinelearningmastery.com/machine-learning-in-python-step-by-step/
# Step 1: Check Python versions
# Step 2: Load libraries
# Step 3: Load dataset