Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Worksheet 1.

3
DS100-2
PYTHON DATA SCIENCE TOOLBOX
APPLIED DATA SCIENCE
Name:

Jason Kidd M. Garcia Page 1 of 5

Write codes in Jupyter notebook as required by the problems. Copy both code and output as screen grab or screen shot and paste
them here.

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

Ages: 24 27 24 27 28 35 28 23 23 26
Heights: 188 180 185 160 180 185 189 185 219 230
Weights: 73 73 74 74 69 70 73 75 78 79

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.
Code and Output

2 Refer to the code in #1. Write a code that determines the age of the 4th player. The output should be in the following form:
The 4th player is <age> years old.
Code and Output

3 Refer to the code in #1. Print out the ages of the young players (those who are 26 years old and below).

Page 1 of 5
Code and Output

4 Create a line plot showing the yearly CO2 emissions per person in Lao. Make sure to add labels and a title to your plot.

CO2 Emissions per country per year (tons per person)


country 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014
Brunei 13.9 13.7 13.1 22.5 24 20.5 21.1 24.6 24.2 19.2 22.1
Cambodia 0.187 0.209 0.223 0.253 0.281 0.33 0.35 0.358 0.369 0.373 0.438
Indonesia 1.51 1.51 1.5 1.61 1.76 1.87 1.77 2.46 2.56 1.95 1.82
Lao 0.246 0.244 0.265 0.153 0.156 0.204 0.262 0.256 0.265 0.243 0.297
Malaysia 6.51 6.8 6.41 6.94 7.53 7.2 7.77 7.7 7.5 7.96 8.03
Myanmar 0.259 0.239 0.263 0.262 0.198 0.205 0.25 0.283 0.217 0.25 0.417
Philippines 0.875 0.867 0.771 0.808 0.869 0.841 0.905 0.897 0.942 0.996 1.06
Singapore 6.52 6.76 6.68 4.21 7.45 11.3 11 8.74 6.9 10.4 10.3
Thailand 3.74 3.78 3.83 3.81 3.79 4 4.19 4.12 4.37 4.4 4.62
Vietnam 1.08 1.16 1.21 1.22 1.36 1.47 1.61 1.7 1.57 1.61 1.8

Code and Output

Page 2 of 5
4. Code and output

Page 3 of 5
5 Visualize Fertility as a function of GDP per Capita for the following South East Asia countries. Use Population as an additional
argument. Do not forget to label the axes and to add a title.

Fertility Life Expectancy Population Child Mortality GDP Per Capita


Philippines 3.151 68.207 93.2 31.9 5614
Thailand 1.443 73.852 69.1 14.5 12822
Singapore 1.261 81.788 50.9 2.8 72056
Vietnam 1.82 75.49 87.8 24.8 4486
Indonesia 2.434 70.185 239.9 33.1 8498
Malaysia 2.001 74.479 48.0 8.3 20398

Code and Output

6 Import cars.csv. Use the country abbreviations as index. Print the last two lines.
Code and Output

Page 4 of 5
7 Refer to the cars dataset. Create a code that prints out the country name and whether the country drives on the right-
hand-side in Japan, India and Russia.
Code and Output

8 Refer to the cars dataset. Create a code that prints out the observations for the countries with lots of cars (cars per
capita greater than 500).
Code and Output

Page 5 of 5

You might also like