diff --git a/scripts/lint.py b/scripts/lint.py index d83be5bb3..f01eadc82 100644 --- a/scripts/lint.py +++ b/scripts/lint.py @@ -9,7 +9,7 @@ for file in files: fileData = someFile.read() someFile.close() originalCode = re.search(codeRe,fileData).group(0) - print(re.split(codeRe,fileData)[0]) + #print(re.split(codeRe,fileData)[0]) formatedCode = autopep8.fix_code(re.split(codeRe,fileData)[1]) fileToSave = fileData.replace(originalCode,('```python \n'+formatedCode+'\n```')) someFile = open("snippets/"+file,'w') diff --git a/snippets/average.md b/snippets/average.md new file mode 100644 index 000000000..d818556a0 --- /dev/null +++ b/snippets/average.md @@ -0,0 +1,20 @@ +### average + +:information_source: Already implemented via `statistics.mean`. `statistics.mean` takes an array as an argument whereas this function takes variadic arguments. + +Returns the average of two or more numbers. + +Takes the sum of all the `args` and divides it by `len(args)`. The secind argument `0.0` in sum is to handle floating point division in `python2`. + +```python + + +def average(*args): + return sum(args, 0.0) / len(args) + +``` + +``` python +average(*[1, 2, 3]) # 2.0 +average(1, 2, 3) # 2.0 +``` \ No newline at end of file