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: 3 additions & 1 deletion q01_read_data/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ def read_data():
# You can use this path to access the CSV file: '../data/ipl_match.yaml'
# Write your code here

data =
file_path = 'data/ipl_match.yaml'
with open(file_path) as yaml_file:
data = yaml.load(yaml_file)

# 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
7 changes: 1 addition & 6 deletions q03_first_batsman/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,5 @@

# Your Solution
def first_batsman(data=data):

# Write your code here




name = data['innings'][0]['1st innings']['deliveries'][0][0.1]['batsman']
return name
11 changes: 7 additions & 4 deletions q04_count/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@

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

# Your code here


count = 0
inning1 = data['innings'][0]['1st innings']['deliveries']
for item in inning1:
for v in item.values():
if v['batsman'] == 'RT Ponting':
count = count + v['runs']['batsman']

return count
8 changes: 6 additions & 2 deletions q05_runs/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@

# Your Solution
def BC_runs(data):
runs = 0

# Write your code here

inning1 = data['innings'][0]['1st innings']['deliveries']
for item in inning1:
for v in item.values():
if v['batsman'] == 'BB McCullum':
runs = runs + v['runs']['batsman']

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 @@ -5,7 +5,13 @@
# Your Solution
def bowled_out(data=data):

# Write your code here
bowled_players = []

innings = data['innings']
for inning in innings:
for delivery in inning.values()[0]['deliveries']:
delivery = delivery.values()[0]
if 'wicket' in delivery and delivery['wicket']['kind'] == 'bowled':
bowled_players.append(delivery['batsman'])

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

# Write your code here


difference =

extras_inn1, extras_inn2 = 0, 0
for delivery in data['innings'][0]['1st innings']['deliveries']:
delivery_content = delivery[next(iter(delivery))]
if 'extras' in delivery_content:
extras_inn1 += 1
for delivery in data['innings'][1]['2nd innings']['deliveries']:
delivery_content = delivery[next(iter(delivery))]
if 'extras' in delivery_content:
extras_inn2 += 1
difference = extras_inn2 - extras_inn1

return difference