Skip to content

Instantly share code, notes, and snippets.

@GrandNewbien
Created March 25, 2018 05:37
Show Gist options
  • Save GrandNewbien/73fd1bb6eca5b047aaa3c108338217b8 to your computer and use it in GitHub Desktop.
Save GrandNewbien/73fd1bb6eca5b047aaa3c108338217b8 to your computer and use it in GitHub Desktop.
class DicotQ:
def __init__(self, question, optionA, optionB):
while True:
self.ans = input(question + ' ({} or {}): '.format(optionA,optionB))
self.ans = self.ans.upper()
if self.ans != optionA and self.ans != optionB:
print("Please input {} or {}: ".format(optionA,optionB))
continue
else:
break
class NumberQ:
def __init__(self,question):
while True:
try:
self.ans = float(input(question))
except ValueError:
print("Please enter a number: ")
continue
else:
break
# Use DicotQ(question,optionA,optionB) for questions with 2 answers
# Use NumberQ(question) for questions with a numerical answer
# Access the answer by using the varible.ans
age = NumberQ("How old are you?")
gender = DicotQ("What is your gender?",'M','F')
bp = DicotQ("""Select the letter representing your blood pressure range from the following options:
A. 140-159 / 90-99 mmHg
B. 160+ / 100+ mmHg
""",'A','B')
weight = NumberQ("What is your weight in kg?")
height = NumberQ("What is your height in meters?")
bmi = float((weight.ans/height.ans)/height.ans)
waist = NumberQ("What is the circumference of your waist in cm?")
dash = DicotQ("Are you currently following the DASH diet?",'Y','N')
sodium = NumberQ("How much sodium you consume on average per serving in mg?")
hyperalemia = DicotQ("Have you been diagnosed with hyperkalemia?", 'Y','N')
potassium = DicotQ("Do you currently consume a lot of foods that are rich in potassium in your diet (eg. bananas, yogurt, potatoes, lentils)?",'Y','N')
exerciseMin = NumberQ("How many minutes of moderate exercise do participate in per day on average?")
exerciseDay = NumberQ("Around how many days do you exercise a week?")
weightlift = DicotQ("Do you currently weightlift or participate in resistance training?",'Y','N')
drinksday = NumberQ("How many drinks on average do you have per day?")
drinksweek = NumberQ("How many drinks on average do you have per week?")
stress = DicotQ("Do you get stressed often?",'Y','N')
smoke = DicotQ("Do you currently smoke?",'Y','N')
if bp.ans == 'A':
print("\n You are currently at stage 1 hypertension.")
else:
print("\n You are currently at stage 2 hypertension.")
if age.ans >= 60:
print("\n Your optimum blood pressure should be less than 150/90.")
else:
print("\n Your optimum blood pressure should be less than 140/90.")
if bmi < 18.5:
print("\n Your BMI is {}. Optimally, your BMI should be between 18.5 and 24.9".format(bmi))
elif bmi > 24.9:
print("\n Your BMI is {}. Optimally, you should try and lower your weight to reduce hypertension!".format(bmi))
else :
print("\n You are at your optimal BMI level! Keep it up!")
if (waist.ans > 102 and gender.ans == 'M') or (waist.ans > 88 and gender.ans == 'F'):
print("Your waist is getting a little big! Optimally, you should try and reduce your weight to fix this.")
input("Press enter to get some tips.")
if (dash.ans == 'N') or (waist.ans > 102 and gender.ans == 'M') or (waist.ans > 88 and gender.ans == 'F'):
print("\nOne way to lose weight and reduce your blood pressure is to undergo the Dietary Approaches to Stopping Hypertension (DASH):")
print("4-5 daily servings of vegetables (eg.1 serving = 1 cup raw leafy vegetables)")
print("4-5 daily servings of fruits (eg. 1 serving = 1 medium piece of fruit)")
print("7-8 daily servings of mainly whole grains (eg.1 serving = 1 piece of bread)")
print("2-3 daily servings of low/no fat dairy foods (eg. 1 serving = 1 cup of milk)")
print("2 or less daily servings of lean mets, poultry and fish (eg. 1 serving = 3 ounces of meats)")
print("4-5 weekly servings of nuts (eg. 1 serving = 1/3 cup nuts)")
print("2-3 servings of fats and oils (eg. 1 serving = 1 tbsp soft margarine)")
input("Press enter to continue.")
if sodium.ans >= 121:
print("\n \nYour sodium consumption is a little too high! Try and buy foods that have around 0-120 mg of sodium per serving!")
input("Press Enter to continue...")
if hyperalemia.ans == 'N' or sodium.ans == 'N':
print("\nEating foods that are rich in potassium can help reduce your blood pressure by making your arteries more flexible and reduce your sodium levels!")
print("It is recommended that you consume at least 4700 mg of potassium per day!")
print("Try integrating foods like bananas, yogurt, orange juice, potatoes and avacados into your diet!")
input("Press Enter to continue...")
if exerciseMin.ans < 30 or exerciseDay < 4:
print("\nExercise can help reduce your blood pressure! Try aiming for 30-60 minutes of moderate aerobic activity (eg. jogging, swimming) daily 4-7 times a week!")
input("Press Enter to continue...")
if weightlift.ans =='N' and bp.ans =='A':
print("\nHit up the gym! You can also try weight lifting or resistance training exercises as well!")
input("Press Enter to continue...")
elif weightlift.ans == 'Y' and bp.ans == 'B':
print("\nBecause you are currently at stage 2 of hypertension, you should probably pause your weight training, as it may adversely affect your blood pressure")
input("Press Enter to continue...")
if drinksday.ans > 2:
print("\nCool your jets! Try and limit your number of drinks to less than 2 a day!")
print("Did you know that consuming less than 2 drinks per day can drop your systolic blood pressure by 3.9 mmHg and diastolic blood pressure by 2.4 mmHg?")
input("Press Enter to continue...")
if drinksweek.ans > 14 and gender.ans == 'M':
print("\nWhoa, hold your horses pal! Try and limit your alcohol consumption to 14 or less drinks per week.")
print("Did you know that consuming less than 2 drinks per day can drop your systolic blood pressure by 3.9 mmHg and diastolic blood pressure by 2.4 mmHg?")
input("Press Enter to continue...")
elif drinksweek.ans > 9 and gender.ans == 'F':
print("\nWhoa, take it easy! Try and limit your alcohol consumption to 9 or less drinks per week.")
print("Did you know that consuming less than 2 drinks per day can drop your systolic blood pressure by 3.9 mmHg and diastolic blood pressure by 2.4 mmHg?")
input("Press Enter to continue...")
if stress.ans == 'Y':
print("\nBeing stressed out can also raise your blood pressure! In addition to a healthy diet and lifestyle, the practice of relaxation techniques like meditation have been proven to reduce one's stress!")
print("You could also talk to your close friends and family about your problems as well to help reduce some of your stress!")
input("Press Enter to continue...")
if smoke.ans == 'Y':
print("\nDid you know that the smoking can raise your blood pressure? It narrows your arteries while making their walls a lot harder and further constrict them!")
print("There are many ways to try and quit smoking.")
print("These may include the use of quitting medications like nicotine gum, switching over to e-cigarettes and even acupuncture!")
input("Press Enter to continue...")
print("\nLooks like that's all we have for you! Please try doing a combination of the above recommendations for optimal results. Good luck on your journey to lower blood pressure :)")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment