Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions q01_read_data/build.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
# %load q01_read_data/build.py
import yaml

def read_data():

# import the csv file into `data` variable
# import the csv file into variable
# You can use this path to access the CSV file: '../data/ipl_match.yaml'
# Write your code here

data =
with open('./data/ipl_match.yaml', 'r') as stream:
data = yaml.load(stream)

# return data variable
return data

read_data()


10 changes: 10 additions & 0 deletions q02_teams/build.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# %load q02_teams/build.py
# default imports
from greyatomlib.python_getting_started.q01_read_data.build import read_data
data = read_data()
Expand All @@ -8,4 +9,13 @@ def teams(data=data):
# write your code here
#teams =

info = {}
teams = []

info = data['info']
teams = info['teams']

return teams



7 changes: 4 additions & 3 deletions q03_first_batsman/build.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# %load q03_first_batsman/build.py
# Default Imports
from greyatomlib.python_getting_started.q01_read_data.build import read_data
data = read_data()

# Your Solution
def first_batsman(data=data):

# Write your code here
innings = data['innings']
name = innings[0]['1st innings']['deliveries'][0][0.1]['batsman']

return name



return name
12 changes: 11 additions & 1 deletion q04_count/build.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# %load q04_count/build.py
# Default Imports
from greyatomlib.python_getting_started.q01_read_data.build import read_data
data = read_data()
Expand All @@ -6,6 +7,15 @@
def deliveries_count(data=data):

# Your code here

count = 0
deliveries = data['innings'][0]['1st innings']['deliveries']
for delivery in deliveries:
for ball in delivery:
if(delivery[ball]['batsman'] == 'RT Ponting'):
count = count + 1

return count

print(deliveries_count(data))


12 changes: 11 additions & 1 deletion q05_runs/build.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# %load q05_runs/build.py
# Default Imports
from greyatomlib.python_getting_started.q01_read_data.build import read_data
data = read_data()
Expand All @@ -7,6 +8,15 @@
def BC_runs(data):

# Write your code here

runs = 0
deliveries = data['innings'][0]['1st innings']['deliveries']
for delivery in deliveries:
for ball in delivery:
if(delivery[ball]['batsman'] == 'BB McCullum'):
runs = runs + delivery[ball]['runs']['batsman']

return(runs)

print(BC_runs(data))


11 changes: 10 additions & 1 deletion q06_bowled_players/build.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# %load q06_bowled_players/build.py
# Default Imports
from greyatomlib.python_getting_started.q01_read_data.build import read_data
data = read_data()
Expand All @@ -6,6 +7,14 @@
def bowled_out(data=data):

# Write your code here

bowled_players = []
deliveries = data['innings'][1]['2nd innings']['deliveries']
for delivery in deliveries:
for ball in delivery:
if 'wicket' in delivery[ball]:
if (delivery[ball]['wicket']['kind'] == 'bowled'):
bowled_players.append(delivery[ball]['wicket']['player_out'])

return bowled_players


19 changes: 18 additions & 1 deletion q07_extras/build.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# %load q07_extras/build.py
# Default Imports
from greyatomlib.python_getting_started.q01_read_data.build import read_data
data = read_data()
Expand All @@ -6,9 +7,25 @@
def extras_runs(data=data):

# Write your code here
first_innings_extra = []
second_innings_extra = []
difference = 0

first_innings_deliveries = data['innings'][0]['1st innings']['deliveries']
second_innings_deliveries = data['innings'][1]['2nd innings']['deliveries']

difference =
for first_innings_delivery in first_innings_deliveries:
for ball in first_innings_delivery:
if (first_innings_delivery[ball]['runs']['extras'] > 0):
first_innings_extra.append(first_innings_delivery[ball]['runs']['extras'])

for second_innings_delivery in second_innings_deliveries:
for ball in second_innings_delivery:
if (second_innings_delivery[ball]['runs']['extras'] > 0):
second_innings_extra.append(second_innings_delivery[ball]['runs']['extras'])

difference = abs(len(first_innings_extra) - len(second_innings_extra))

return difference