From 90d2c9dcfa635fac8818e7a4abf33d479db3ff89 Mon Sep 17 00:00:00 2001 From: Wiktoria Lipkowska Date: Sat, 23 Jul 2022 20:52:42 +0200 Subject: [PATCH] Create NumpyExample --- NumpyExample | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 NumpyExample diff --git a/NumpyExample b/NumpyExample new file mode 100644 index 0000000..fb5a048 --- /dev/null +++ b/NumpyExample @@ -0,0 +1,18 @@ +#convert the list of weights from a list to a Numpy array. +#Then, convert all of the weights from kilograms to pounds. +#Use the scalar conversion of 2.2 lbs per kilogram to make your conversion. +#Lastly, print the resulting array of weights in pounds. + +weight_kg = [81.65, 97.52, 95.25, 92.98, 86.18, 88.45] + +import numpy as np + +# Create a numpy array np_weight_kg from weight_kg +np_weight_kg = np.array(weight_kg) + + +# Create np_weight_lbs from np_weight_kg + +np_weight_lbs = np_weight_kg/2.2 +# Print out np_weight_lbs +print(np_weight_lbs)