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
4 changes: 2 additions & 2 deletions q01_read_data/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ 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 @@ -6,7 +6,7 @@
def first_batsman(data=data):

# Write your code here

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



Expand Down
10 changes: 8 additions & 2 deletions q04_count/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@

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

# Your code here

count = 0
delivs = data['innings'][0]['1st innings']['deliveries']
for d in delivs:
for ball_no, info in d.items():
if info['batsman'] == 'RT Ponting':
balls_faced = ball_no
count += 1

return count
8 changes: 7 additions & 1 deletion q05_runs/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
def BC_runs(data):

# Write your code here

runs = 0
delivs = data['innings'][0]['1st innings']['deliveries']
for d in delivs:
for ball_no, info in d.items():
if info['batsman'] == 'BB McCullum':
run_scored = info['runs']['batsman']
runs += run_scored

return(runs)
8 changes: 7 additions & 1 deletion q06_bowled_players/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
def bowled_out(data=data):

# Write your code here

bowled_players = []
deliv = data['innings'][1]['2nd innings']['deliveries']
for d in deliv:
for ball_no, info in d.items():
for w, k in info.items():
if w == 'wicket' and k['kind'] == 'bowled':
bowled_players.append(info['batsman'])

return bowled_players
14 changes: 13 additions & 1 deletion q07_extras/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,21 @@
def extras_runs(data=data):

# Write your code here
extra1 = 0
extra2 = 0
deliv1 = data['innings'][0]['1st innings']['deliveries']
deliv2 = data['innings'][1]['2nd innings']['deliveries']
for d in deliv1:
for ball_no, info in d.items():
if info['runs']['extras'] > 0:
extra1 += 1

for d in deliv2:
for ball_no, info in d.items():
if info['runs']['extras'] > 0:
extra2 += 1

difference =
difference = extra2 - extra1


return difference