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
http://stackoverflow.com/questions/101268/hidden-features-of-python#111176 |
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 triangle(rows): | |
for rownum in range (rows): | |
newValue=1 | |
PrintingList = [newValue] | |
for iteration in range (rownum): | |
newValue = newValue * ( rownum-iteration ) / ( iteration + 1 ) | |
PrintingList.append(int(newValue)) | |
print(PrintingList) | |
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 json | |
def combine_json(): | |
with open('j1.json') as file: | |
d1 = json.loads(file.read()) | |
with open('j2.json') as file: | |
d2 = json.loads(file.read()) | |
result = combine_dict(d1,d2) | |
j3 = json.dumps(result) | |
return j3 |
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
#Factorial Recursive Function | |
def factorial(n): | |
if n>1: | |
return n * factorial(n-1) | |
else: | |
return 1 | |
#Fibonnaci Function | |
l = [] |
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
{ | |
"expression": [ | |
{ | |
"_function": "bind", | |
"population": { | |
"_function": "all" | |
}, | |
"populationName": "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
#!/bin/bash | |
# Functions ============================================== | |
# return 1 if global command line program installed, else 0 | |
# example | |
# echo "node: $(program_is_installed node)" | |
function program_is_installed { | |
# set to 1 initially | |
local return_=1 |