Skip to content

Instantly share code, notes, and snippets.

@worldmind
Created June 11, 2019 12:44
Show Gist options
  • Save worldmind/cad3701ddb937bdce0168502e3bf460f to your computer and use it in GitHub Desktop.
Save worldmind/cad3701ddb937bdce0168502e3bf460f to your computer and use it in GitHub Desktop.
Most science based 5 factor psychology test :)
from math import ceil, floor
import numpy as np
LEVELS = 10
CENTER = int(LEVELS/2)
FACTORS = [
'Agreeableness',
'Conscientiousness',
'Extraversion',
'Emotional Stability',
'Openness to Experience',
]
def round_to_center(num):
if num < CENTER:
return floor(num)
return ceil(num)
def get_result():
res = np.random.normal(CENTER, LEVELS/6)
res = round_to_center(res)
if res <= 0 or res > LEVELS:
res = CENTER
return res
def main():
for factor in FACTORS:
res = get_result()
output = '-'*(res-1) + str(res) + '-'*(LEVELS-res)
print(f"{factor:24} {output}")
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment