0% found this document useful (0 votes)
95 views

WS#3 Python Data Science Toolbox NAVAL

The document is a worksheet for a Python data science course. It contains 5 coding exercises: 1) identifying equivalent NumPy code, 2) creating a NumPy array from lists of player data and converting units, 3) determining the age of the 8th player, 4) printing the ages of young players aged 25 and below, and 5) printing average weight, median height and median age. The student provides code snippets and outputs for each exercise.

Uploaded by

Carlo Naval
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
95 views

WS#3 Python Data Science Toolbox NAVAL

The document is a worksheet for a Python data science course. It contains 5 coding exercises: 1) identifying equivalent NumPy code, 2) creating a NumPy array from lists of player data and converting units, 3) determining the age of the 8th player, 4) printing the ages of young players aged 25 and below, and 5) printing average weight, median height and median age. The student provides code snippets and outputs for each exercise.

Uploaded by

Carlo Naval
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Name NAVAL , CARLSON B.

APPLIED DATA SCIENCE

WORKSHEET #3: PYTHON DATA SCIENCE TOOLBOX

1 Date:
Refer to the following line of code: np.array([True,1,2]) + np.array([3,4,False])
Which code chunk builds the exact same Python object?
A. np.array([True,1,2,3,4,False])
B. np.array([4,3,0]) + np.array([0,2,2])
C. np.array([1,1,2]) + np.array([3,4,-1])
D. np.array([0,1,2,3,4,5])

2 Date:
Create a list of lists. The individual lists should contain, in the correct order, the height (in inches), the weight (in pounds) and the
age of the baseball players.

Heights: 74 74 72 72 73 69 69 71 76 71 73 73 74 74 69 70 73 75 78 79
Weights: 180 215 210 210 188 176 209 200 231 180 188 180 185 160 180 185 189 185 219 230
Ages: 23 35 31 36 36 30 31 36 31 28 24 27 24 27 28 35 28 23 23 26

Convert the list of lists into a NumPy array named np_baseball. Using NumPy functionality, convert the unit of height to m and
that of weight to kg. Print the resulting array.

Write the code here and take a snapshot of the output using the Web Note function of the Jupyter notebook. Paste the snapshot
into an MS Word file and submit through Cardinal Edge Worksheet Submission.
Code

BB Submission

Page 1 of 3
Name NAVAL , CARLSON B. APPLIED DATA SCIENCE

WORKSHEET #3: PYTHON DATA SCIENCE TOOLBOX

3 Date:
Write a code that determines the age of the 8 th player. The output should be in the following form:
The 8th player is <age> years old.
Code

Output
The 8th player is 36 years old

4 Date:
Print out the ages of the young players (those who are 25 years old and below).
Code

Output
[ 23 24 23 23]

Page 2 of 3
Name NAVAL , CARLSON B. APPLIED DATA SCIENCE

WORKSHEET #3: PYTHON DATA SCIENCE TOOLBOX

5 Date:
Print out the average weight, median height and median age of the players. The output should be in the following form:
Average Weight: <average weight>
Median Height: <median height>
Median Age: <median age>
Code

Output

Average Height: 1.851377777…


Median Height: 88.83849…
Median Age: 29.1

Page 3 of 3

You might also like