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
5 changes: 3 additions & 2 deletions q01_read_data/build.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# %load q01_read_data/build.py
import yaml

def read_data():

# import the csv file into `data` 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') as f:
data = yaml.load(f)

# return data variable
return data
2 changes: 1 addition & 1 deletion q02_teams/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
def teams(data=data):

# write your code here
#teams =
teams = data['info']['teams']

return teams
2 changes: 1 addition & 1 deletion q03_first_batsman/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def first_batsman(data=data):

# Write your code here


name = data['innings'][0]['1st innings']['deliveries'][0][0.1]['batsman']


return name
10 changes: 7 additions & 3 deletions q04_count/build.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
# Default Imports
from greyatomlib.python_getting_started.q01_read_data.build import read_data
data = read_data()

# Your Solution Here
def deliveries_count(data=data):

# Your code here

count = 0
deliveries = data['innings'][0]['1st innings']['deliveries']
for delivery in deliveries:
for key,value in delivery.items():
if value['batsman'] == 'RT Ponting':
count=count+1

return count
7 changes: 7 additions & 0 deletions 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,12 @@
def BC_runs(data):

# Write your code here
runs = 0
deliveries = data['innings'][0]['1st innings']['deliveries']
for delivery in deliveries:
for key,value in delivery.items():
if value['batsman'] == 'BB McCullum':
runs = runs + value['runs']['batsman']


return(runs)
17 changes: 16 additions & 1 deletion q06_bowled_players/build.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
# Default Imports
from greyatomlib.python_getting_started.q01_read_data.build import read_data
from pprint import pprint

data = read_data()

# Your Solution
def bowled_out(data=data):

# Write your code here
bowled_players = []

deliveries1 = data['innings'][0]['1st innings']['deliveries']
for delivery in deliveries1:
for key,value in delivery.items():
for key,value in value.items():
if key == 'wicket' and value['kind'] == 'bowled':
bowled_players.append(value['player_out'])

deliveries2 = data['innings'][1]['2nd innings']['deliveries']
for delivery in deliveries2:
for key,value in delivery.items():
for key,value in value.items():
if key == 'wicket' and value['kind'] == 'bowled':
bowled_players.append(value['player_out'])

return bowled_players
14 changes: 11 additions & 3 deletions q07_extras/build.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
# Default Imports
from greyatomlib.python_getting_started.q01_read_data.build import read_data
data = read_data()

# Your Solution
def extras_runs(data=data):

# Write your code here
extras1 = 0
extras2 = 0

deliveries1 = data['innings'][0]['1st innings']['deliveries']
for delivery in deliveries1:
for key,value in delivery.items():
extras1 += value['runs']['extras']

difference =

deliveries2 = data['innings'][1]['2nd innings']['deliveries']
for delivery in deliveries2:
for key,value in delivery.items():
extras2 += value['runs']['extras']

difference = extras2 - extras1
return difference