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
#!/usr/bin/env python | |
def add_ints(*args): | |
return_sum = 0 | |
for i in args: | |
if type(i) in [list, tuple]: | |
for list_key in i: | |
return_sum += add_ints(list_key) | |
if type(i) == dict: |
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 os, datetime, random | |
while True: | |
os.system('clear') | |
print "ENTER to continue, or type 'quit'" | |
print datetime.datetime.now() | |
print '' | |
print(random.choice(('Left', 'Right'))) | |
print '' | |
prompt = raw_input("") | |
if prompt == 'quit': |
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 os | |
def file_len(fname): #get file linecount | |
if os.stat(fname).st_size == 0: | |
return 0 | |
with open(fname) as f: | |
for i, l in enumerate(f): | |
pass | |
return i+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
# convert base10 number to desired base | |
def convertbase(num, base): | |
mods = [] | |
while num >= base: | |
mods.append(num % base) | |
num = num / base | |
if num <= base: | |
mods.append(num) | |
mods.reverse() |
NewerOlder