Diary of an IT Guy

Heart passion to keep the brain moving>>>

Posts Tagged ‘array

Latihan Numpy Array di Python (2019-01-19)

leave a comment »

In the last few exercises you’ve learned everything there is to know about heights and weights of baseball players. Now it’s time to dive into another sport: soccer.

You’ve contacted FIFA for some data and they handed you two lists. The lists are the following:

positions = ['GK', 'M', 'A', 'D', ...]
heights = [191, 184, 185, 180, ...]

Each element in the lists corresponds to a player. The first list, positions, contains strings representing each player’s position. The possible positions are: 'GK' (goalkeeper), 'M' (midfield), 'A' (attack) and 'D' (defense). The second list, heights, contains integers representing the height of the player in cm. The first player in the lists is a goalkeeper and is pretty tall (191 cm).

You’re fairly confident that the median height of goalkeepers is higher than that of other players on the soccer field. Some of your friends don’t believe you, so you are determined to show them using the data you received from FIFA and your newly acquired Python skills.

# heights and positions are available as lists

# Import numpy
import numpy as np

# Convert positions and heights to numpy arrays: np_positions, np_heights
np_positions = np.array(positions)
np_heights = np.array(heights)

# Heights of the goalkeepers: gk_heights
gk_heights = np.array(np_heights[np_positions=='GK'])
#print (gk_heights)

# Heights of the other players: other_heights
other_heights = np.array(np_heights[np_positions !='GK'])
#print (other_heights)

# Print out the median height of goalkeepers. Replace 'None'
print("Median height of goalkeepers: " + str(np.median(gk_heights)))

# Print out the median height of other players. Replace 'None'
print("Median height of other players: " + str(np.median(other_heights)))


Median height of goalkeepers: 188.0
Median height of other players: 181.0

Written by isal

19 January 2019 at 23:54

Posted in Data Science

Tagged with , ,

Kadang Ada Bug di Situs Detik.Com

leave a comment »

Wah akhir-akhir ini dan terakhir pagi ini eke akses situs detikcom misal halaman http://www.detikinet.com/index.php/detik.read/tahun/2008/bulan/03/tgl/28/time/091111/idnews/914655/idkanal/323 ternyata suka ada bugs spt ini:

Fatal error: Call to a member function attributes() on a non-object in /data/application/apps/parserXML/read/actToArrayArticle.php on line 5

Mungkin traffic lagi tinggi sehingga bug menghinggapi file


Atau hasil pemrosesan dari webserver tidak dengan baik ditangkap oleh proxy server. Cepat dibetulin ya maklum programmer juga manusia. 🙂

bugs detik

Written by isal

28 March 2008 at 09:46

%d bloggers like this: