-
Notifications
You must be signed in to change notification settings - Fork 1
/
EDD 2.py
38 lines (26 loc) · 1.19 KB
/
EDD 2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
"""
This promgram computes the Expected Date of Delivery (EDD) when a user
enters the date of their Last Menstrual Period (LMP).
"""
from datetime import timedelta, date
try:
#getting LMP from the user
lmp = input("Enter the date of your last period in DD-MM-YYYY format: ")
lst = lmp.split("-") #splitting the date to change to int numbers
day, month, year = int(lst[0]), int(lst[1]), int(lst[2])
lmp_date = date(year, month, day) #converting the LMP to datetime object
delta = timedelta(days = 280)
edd_date = lmp_date + delta #adding 280 days which is the duration of pregnancy
print(f"Your expected date of delivery is {edd_date}.")
except:
print("Error! Please enter a valid date in the specified format.")
#another method by adding 40 weeks to LMP
# delta5 = timedelta(weeks = 40)
# date5 = date1 + delta5
# print(date5)
#using Naegle's rules are
# delta1 = timedelta(days = 7, weeks = -13)
# date2 = date + delta1 #adding 7 to days and subtracting 3 months i.e 13 weeks
# delta2 = timedelta(weeks = 52)
# date3 = date2 + delta2 #adding 1 year to the date i.e 52 weeks
# print(date3)