-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCode1.py
More file actions
43 lines (31 loc) · 1.39 KB
/
Code1.py
File metadata and controls
43 lines (31 loc) · 1.39 KB
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
39
40
41
42
43
# -*- coding: utf-8 -*-
from decimal import Decimal, getcontext
#from uncertainties import ufloat
getcontext().prec = 3
Unit_measurement = 100000 # Per this many people
InitialPopulation=int(input('Beginning Population?: '))
ConvertStat=Decimal(Unit_measurement/InitialPopulation)
Prevalence = Decimal(input("How many affected?: "))*ConvertStat
print("Prevalence:", Prevalence, "per", Unit_measurement, "people affected.")
Incidence = Decimal(input("How many new people affected?: "))*ConvertStat
print("Incidence:",Incidence, "new cases per", Unit_measurement, "people.")
MortalityRate=Decimal(input("How many people died?: "))*ConvertStat
print("Mortality Rate:", MortalityRate, "deaths per", Unit_measurement, "people.")
CalcYearsLost = input("Calculate years of potential life lost?: ")
if CalcYearsLost=="y":
CalcYearsLost=True
else:
CalcYearsLost=False
LifeExpectation = None
while CalcYearsLost:
if LifeExpectation==None:
LifeExpectation= float(input("What is the life expectancy age?: "))
else:
try:
question1=int(input("What was the age of a person who died? (Provide no answer if no ages are known): "))
difference=LifeExpectation-question1
if difference<0:
difference=0
print("This person lost", difference, "years of life")
except ValueError:
CalcYearsLost = False