Skip to content

Commit 45b4d51

Browse files
committed
2 parents 732d0a3 + a25f8de commit 45b4d51

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

Code11.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import pandas as pd
2+
3+
data = pd.read_csv("Week13Assignment.txt")
4+
5+
age_avg = data[" Age"].mean()
6+
7+
male = 0
8+
female=0
9+
for gender in data[" Gender"]:
10+
if gender == "male":
11+
male += 1
12+
elif gender=="female":
13+
female += 1
14+
15+
systolic = list()
16+
diastolic= list()
17+
for bp in data[" BloodPressure"]:
18+
sys, dia = bp.split("/")
19+
systolic.append(int(sys))
20+
diastolic.append(int(dia))
21+
22+
systolic_avg = sum(systolic)/len(systolic)
23+
diastolic_avg= sum(diastolic)/len(diastolic)
24+
25+
temp_avg = data[" Temperature"].mean()
26+
27+
28+
print("-- Patients' Data Statistics --")
29+
print(f"The average age of the patients is {age_avg}.")
30+
print(f"The number of male and female patients is {male} and {female} respectively.")
31+
print(f"The blood pressures have an average systolic pressure of {systolic_avg} and average diastolic pressure of {diastolic_avg}.")
32+
print(f"The highest and lowest systolic pressures are {max(systolic)} and {min(systolic)}.")
33+
print(f"The highest and lowest diastolic pressures are {max(diastolic)} and {min(diastolic)}.")
34+
print(f"The average patient temperature is {temp_avg} celsius.")

Week13Assignment.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Name, Age, Gender, BloodPressure, Temperature
2+
John Doe, 45, Male, 120/80, 36.8
3+
Jane Smith, 32, Female, 130/85, 37.2
4+
Alice Johnson, 50, Female, 140/90, 36.5
5+
Michael Brown, 55, Male, 135/82, 37.0
6+
Emily Wilson, 40, Female, 125/78, 36.9

0 commit comments

Comments
 (0)