mirror of
https://github.com/wahyd4/code-sandbox.git
synced 2026-08-09 05:07:03 +10:00
24 lines
501 B
Python
24 lines
501 B
Python
# Create 2 new lists height and weight
|
|
import numpy as np
|
|
height = [1.87, 1.87, 1.82, 1.91, 1.90, 1.85]
|
|
weight = [81.65, 97.52, 95.25, 92.98, 86.18, 88.45]
|
|
|
|
# Import the numpy package as np
|
|
|
|
# Create 2 numpy arrays from height and weight
|
|
|
|
np_height = np.array(height)
|
|
np_weight = np.array(weight)
|
|
print(type(np_height))
|
|
# Calculate bmi
|
|
bmi = np_weight / np_height ** 2
|
|
|
|
# Print the result
|
|
print(bmi)
|
|
|
|
# For a boolean response
|
|
# bmi > 23
|
|
|
|
# Print only those observations above 23
|
|
print(bmi[bmi > 25])
|