Skip to content

Instantly share code, notes, and snippets.

View TomColBee's full-sized avatar

Thomas Beeson TomColBee

View GitHub Profile
@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 / 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 / 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 / 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 / LongestWord.py
Created July 15, 2018 06:44
Coderbyte Python Challenge: LongestWord
# Have the function LongestWord(sen) take the sen parameter being passed and return the largest word in the string.
# If there are two or more words that are the same length, return the first word from the string with that length.
# Ignore punctuation and assume sen will not be empty.
def LongestWord(sen):
import re
length_greatest = 0
# Convert string to lowercase
sen = sen.lower()
# Only keep alphabet + numbers + white space
@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 / 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 / QuizTemplate.py
Created June 19, 2018 17:23
Project: Multiple Choice Quiz Template
# Multiple choice quiz sample code
# Complete the lists detailed below
# question_titles, questions_asked, poss_answers, answers_ page ref.
# Import random package and sys
import random
# Print welcome
print("Hello, welcome to the [Quiz Name Here]."
"\nBefore we start, let me ask a few questions...")
@TomColBee
TomColBee / GuessTheNumber.py
Created June 17, 2018 21:34
Guess The Number Project
# Program where the user has to guess the number in the given number of lives.
# User inputs the difficulty which determines the range the number is generated from.
# User also inputs the number of guesses they feel they need.
# import random package
import random
# Print welcome to the game
print("Hello, welcome to the number guessing game.")
@TomColBee
TomColBee / ConvertToPigLatin.py
Created June 17, 2018 17:08
Python Bible: Converting Sentence to Pig Latin - For loop - Lists - Joins - Sentence Splits
# Create pig latin based on string inputted
# Get sentence from user
sentence = input("Please type in a sentence to be converted into pig-latin: ").strip().lower()
# Split sentence into sentence
sentence = sentence.split()
# Loop through sentence and convert to pig-latin
new_sentence = []