Skip to content

Instantly share code, notes, and snippets.

import time #used for the timing of the code
def fibRecurse(n): #this will calculate the nth Fibonacci number recursively
if n<=1: #This will get the 1st Fibonacci number of 0
return n
else:
return fibRecurse(n-1) + fibRecurse(n-2)
@coffeechug
coffeechug / Hangman Game Coffee
Last active April 18, 2020 20:35
My hangman game for my CS coursework
import random
import os
#creating list and making them all uppercase and splitting the words
wordlist = "Thor Fury Hulk Stark Thanos Ragnarok Odin Daredevil Wolverine Punisher ".upper().split()
random.shuffle(wordlist) #getting a random list. need more words to truly scramble
#images for the status of game
HANGMANPICS = ['''
@coffeechug
coffeechug / CaesarCipher(Module 5)
Created April 10, 2020 13:56
Assignment to complete for CS Endorsement program
import unittest #python module that handles unit testing
def main():
""" The main method for this program
This program will ask the user for an encryption key, if they want to
encrypt or decrypt, and what message they want to encrypt or decrypt.
Then the program will output output the message after it has been
translated
"""
@coffeechug
coffeechug / Guess The Number
Created March 27, 2020 13:33
Guess The Number
import random #adding this library
play_game = True #helps to kick out of the game later when we change to false
another_game=str(input("Do you want to play a game, type yes or no ")) #gives player a choice to play again or not
if another_game == "no":
play_game = False
else:
play_game = True
while play_game: #setting the stage with variables and initial input from user
@coffeechug
coffeechug / Blackjack
Last active March 18, 2020 11:44
Blackjack Game
import random
play_game = True
playerScore=0
dealerScore=0
cards = [
'2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A',
'2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A',
'2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A',
'2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A',
@coffeechug
coffeechug / gist:a20e2a6bc3bbf9cb0f8f55a27891cb5e
Created March 17, 2020 01:17
Guess the number game with option to quit
import random #adding this library
play_game = True #helps to kick out of the game later when we change to false
while play_game: #setting the stage with variables and initial input from user
n = random.randint(1,100)
total = 0
guess = (input("Enter a integer from 1 to 100 or quit to leave game: "))
while guess !=n: #this loop will run as long as the input is not equal to random number
if guess == 'quit': #this gives the user a chance to leave game midway through
@coffeechug
coffeechug / Change Maker
Last active March 16, 2020 16:52
Making Change Assignment
cost = int(input("Please enter the price of the item in cents "))
payment = int(input("Please enter the amount you paid in cents "))
change = payment - cost
print("Your total change is", change, "and you will receive the following denominations")
# // is floating division
#Divides and returns the integer value of the quotient.
#It dumps the digits after the decimal.
from random import choice
grades = '54 - Alice,35 - Bob,27 - Carol,27 - Chuck,05 - Craig,30 - Dan,27 - Erin,77 - Eve,14 - Fay,20 - Frank,48 - Grace,61 - Heidi,03 - Judy,28 - Mallory,05 - Olivia,44 - Oscar,34 - Peggy,30 - Sybil,82 - Trent,75 - Trudy,92 - Victor,37 - Walter'
student_list = grades.split(',')
final = sorted(student_list, reverse = False)
print(final)
ryears = int(input("How many (human) years old is your dog? "))
dyears = str(real_years * 7)
print ("Your dog is " + dyears + " years old in dog years.")
# Python program to check if number is prime or not
number = int(input("Provide a number to test if it is prime: "))
if number > 1:
for i in range(2, number//2):
# If number is divisible by any number between 2 and n / 2, it is not prime
if (number % i) == 0: