Skip to content

Instantly share code, notes, and snippets.

View MrDMurray's full-sized avatar
😎
"On an intergalactic cruise... but he is in his office"

Daniel Murray MrDMurray

😎
"On an intergalactic cruise... but he is in his office"
View GitHub Profile
@MrDMurray
MrDMurray / Shouty.py
Last active September 11, 2016 13:50
STJLOL-DMU-A code to make things uppercase.
print("Welcome to FULL CAPS SHOUTtron")
insult=input("We meet again human. What am I?")
print("OH YEAH? YOU'RE A "+insult.upper())
#adding .upper() makes the string all uppercase (capital letters)
@MrDMurray
MrDMurray / List-all-functions.py
Created September 17, 2016 12:30
List-all-functions.py
#Prints all functions available to the user in a module. Great way to find out all the useful functions that a module (in this case time) can let you access. Try substituting "time" with other modules like "math".
import time
everything =dir(time)
print(everything)
@MrDMurray
MrDMurray / if_Else_Boolean.py
Created September 21, 2016 23:04
STJLOL-DMU- If AND else OR Boolean logic
#-------------------------------------------------------
#The Mr. Murray Detector 9000
#-------------------------------------------------------
#The program asks the user 3 yes or no questions
beard=input("Does this person have a beard? yes or no?")
shirt=input("Does this person wear a shirt? yes or no?")
science=input("Is he talking about science? yes or no?")
#only gives the Mr. Murray answer if all three are equal to yes.
if beard=="yes" and shirt=="yes" and science=="yes":
@MrDMurray
MrDMurray / epicinATOR.py
Created September 26, 2016 18:26
STJLOL-DMU-Functions, Strings:
def epicINATOR(word): #defines the function
print(word+"???") #prints it back with some question marks
print("more like...")
yoke = word+"INATORRRRR!!!" #adds INATORRR to the word you type in
yoke = yoke.upper() #makes is UPPER CASE
print(yoke)
print("THE ROMAN GOD OF " + word.upper() +"ING!") #sticks the result in a sentance
while True:
epicINATOR(input("Giveth me a word mortal.. ")) #calls the function with a user input as it's value
@MrDMurray
MrDMurray / pokeshop.py
Created September 26, 2016 18:56
STJLOL-DMU-Lists: The pokeshop
bag = ['pokeball',"pokedex"] #makes a list with two items called bag
print("Welcome to the pokeshop!")
print("Let's see what's in your bag")
print (bag) #prints out what items are in the bag starting off
while True: #loops this part till a purchase is made
@MrDMurray
MrDMurray / forloopsearch.py
Last active September 29, 2016 08:42
STJLOL-DMU-for loops - Search
#This program accepts an input from the user and then searches through a list to see if there is a match.
#It then counts how many matches there are.
bag = ["raspberry", "pokeball", "pokeball", "pokeball", "great ball", "potion"] #This is the list of items in the bag
print (bag) #Prints the contents of the bag
count = 0 #starts the count at 0
# this piece of code prints out characters and makes the list of words into uppercase
#The list as it is normally
inventory = ["pickaxe", "sword", "diamonds"]
print(inventory)
#Method 1: Using .upper each time
@MrDMurray
MrDMurray / usingforloops.py
Created October 5, 2016 19:30
STJLOL-DMU Using forloops
# this piece of code prints out characters and makes the list of words into uppercase
#The list as it is normally
inventory = ["pickaxe", "sword", "diamonds"]
print(inventory)
#Method 1: Using .upper each time
@MrDMurray
MrDMurray / Score_Count.py
Last active October 10, 2016 20:52
STJLOL-DMU Score or Counter
score = 0 #set the starting score to 0
print (score) #prints the score
score = score + 1 #adds 1 to the score
print(score) #prints the score
score = score + 1 #adds 1 to the score
print(score) #prints the score
score = score + 3 #adds 3 to the score
@MrDMurray
MrDMurray / STJLOLModulo.py
Created October 19, 2016 18:58
Does is divide evenly? Using a Modulo (Remainder)
# / means divide
# 10/2 is ten divided by 2
# 10/2 = 5
# % means remainder
# 10%2 is how much is left over (remainder) when 10
# is divided by 2.
# 10%2 = 0
if 6%2 == 0: