Skip to content

Instantly share code, notes, and snippets.

@martingaido
Created December 3, 2022 20:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martingaido/fe45619b59f63876143065feb8103004 to your computer and use it in GitHub Desktop.
Save martingaido/fe45619b59f63876143065feb8103004 to your computer and use it in GitHub Desktop.
Script to calculate your biorhythm
from datetime import datetime, timedelta
import math
def calculate_biorhythm(birthday, current_date, rhythm_type):
days_difference = (current_date - birthday).days
if rhythm_type == 'physical':
cycle = 23
elif rhythm_type == 'emotional':
cycle = 28
elif rhythm_type == 'intellectual':
cycle = 33
biorhythm = round(math.sin(2 * math.pi * days_difference / cycle), 2)
return biorhythm
current_date = datetime.now()
biorhythm_p = calculate_biorhythm(datetime.strptime('1900-01-01', '%Y-%m-%d'), current_date, 'physical')
biorhythm_e = calculate_biorhythm(datetime.strptime('1900-01-01', '%Y-%m-%d'), current_date, 'emotional')
biorhythm_i = calculate_biorhythm(datetime.strptime('1900-01-01', '%Y-%m-%d'), current_date, 'intellectual')
print('Physical: ' + str(biorhythm_p))
print('Emotional: ' + str(biorhythm_e))
print('Intellectual: ' + str(biorhythm_i))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment