Skip to content

Added 2 new algorythms (decrypt message, censor) #5883

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 24 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions maths/average_welford.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
def average_welford(values):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide return type hint for the function: average_welford. If the function does not return a value, please provide the type hint as: def function() -> None:

Please provide type hint for the parameter: values

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def average_welford(values):
def average_welford(values) -> float:

"""
>>> average_welford([1, 2, 3, 4, 5])
3.0
>>> average_welford([1.2329435, 2.209462409, 3.230925, 4.47626462, 5.2938759204])
3.2886942898799996
>>> average_welford([-57386462.2329435, 2246262.209462409, 4632463.230925, 856737354.47626462, -243664265.2938759204])
112513070.4779665
"""
avg = 0.0
"""while looping through the list,
we calculate the average of the
current element and the average
of the elements before it"""
for index in range(0, len(values)):
avg += (values[index]-avg)/(index+1)
return avg

if __name__ == "__main__":
import doctest
doctest.testmod()