Skip to content

Instantly share code, notes, and snippets.

@nythepegasus
Created January 3, 2021 14:37
Show Gist options
  • Save nythepegasus/ac217b9bf066ec938ff552e6c54f2364 to your computer and use it in GitHub Desktop.
Save nythepegasus/ac217b9bf066ec938ff552e6c54f2364 to your computer and use it in GitHub Desktop.
Some fun oneliners I have made to do math problems easier
import math
### Find Population Standard Deviation ###
pop = [103,99,108,105,114,101]
math.sqrt(sum(list(map(lambda x: (x-sum(pop)/len(pop))**2, pop)))/len(pop))
### Sigma Notation Using Range And Sum
# sum(range(first_num, last_num, step))
sum(range(2, -449, -5))
### Permutations/Combinations ###
r = 6 # How many per
n = 15 # Total
math.factorial(n)/math.factorial(n-r) # Permutations
math.factorial(n)/(math.factorial(r)*math.factorial(n-r)) # Combinations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment