This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def stamps(n): | |
fives = 0 | |
twos = 0 | |
ones = 0 | |
if (n / 5) > 0: | |
fives = (n - (n % 5)) / 5 | |
left = n % 5 | |
twos = (left - (left % 2)) / 2 | |
ones = left % 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# a script that searches a 1st string for all the characters present in the 2nd string, and returns the 2nd string | |
# if each character is present in the 1st. Returns 'give me soemthing that's not useless next time.' if not all | |
#characters are found | |
def fix_machine(search, target): | |
n = len(target) - 1 | |
while n > -1: | |
search.find(target[n]) | |
n = n - 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Abacus script | |
#Enter a value and have it printed out in abacus form | |
from numFinder import * | |
from rep import * | |
# checks if value is between 1 and 1 billion. | |
def valid_Num(num): | |
if num <= 1000000000 and num >= 0: | |
return True | |
else: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def isPrime(num): | |
prime = True | |
for x in range(2, num): | |
if num % x == 0: | |
prime = False | |
return prime |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def isPrime(num): | |
prime = True | |
for x in range(2, num): | |
if num % x == 0: | |
prime = False | |
return prime | |
def nextPrime(num): | |
current = num + 1 | |
while isPrime(current) != True: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from random import randrange | |
class Player: | |
def __init__(self, name): | |
self.health = 100 | |
self.name = name | |
self.dam = 0 | |
def low_damage (self): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
If pip isn’t installed install pip by going to the command line and typing: | |
>>>sudo easy_install pip | |
#sudo stands for super user d. | |
Once pip is installed you can install packages by typing: | |
>>>sudo pip install <package name> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-Libraries and webpages have unique directory structures. | |
Library: | |
<library name> | |
<library name> | |
-modules | |
__init__.py | |
#The main __init__.py imports all the things that the library requires. | |
#ex: https://github.com/kennethreitz/requests/blob/master/requests/__init__.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
line = raw_input() | |
temp = [int(x) for x in line.split()] | |
row, column = temp | |
def rowValue(row): | |
if row > 2 and row % 2 == 1: | |
return ((row - 1)/2) * 10 | |
elif row > 2 and row % 2 == 0: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def inception(dictionary): | |
if isinstance(dictionary, dict): | |
new_dict = {key:value for key, value in dictionary.items()} | |
dictionary['self'] = new_dict | |
return dictionary |
OlderNewer