Created
December 3, 2022 20:19
-
-
Save martingaido/fe45619b59f63876143065feb8103004 to your computer and use it in GitHub Desktop.
Script to calculate your biorhythm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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