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():

with open("./data/ipl_match.yaml") as f:
data = yaml.load(f)
return 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 =
#data =

# return data variable
return data
#return data
#data.seek(0)
read_data()
7 changes: 4 additions & 3 deletions q02_teams/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@

# solution
def teams(data=data):

# write your code here
#teams =
teams = []
for team in data['info']['teams']:
teams.append(team)

return teams
teams(data)
9 changes: 3 additions & 6 deletions q03_first_batsman/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@

# Your Solution
def first_batsman(data=data):

# Write your code here




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

first_batsman(data)
11 changes: 8 additions & 3 deletions q04_count/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@

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

# Your code here


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


return count
deliveries_count(data)
8 changes: 5 additions & 3 deletions q05_runs/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@

# Your Solution
def BC_runs(data):

# Write your code here

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

return(runs)
9 changes: 6 additions & 3 deletions q06_bowled_players/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@

# Your Solution
def bowled_out(data=data):

# Write your code here

bowled_players = []
for d in data['innings'][1]['2nd innings']['deliveries']:
for k, v in d.items():
if v.get('wicket',{}).get('kind') == 'bowled':
bowled_players.append(v['batsman'])

return bowled_players
bowled_out(data)
18 changes: 13 additions & 5 deletions q07_extras/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,19 @@

# Your Solution
def extras_runs(data=data):
extras_1 = []
extras_2 = []
for d in data['innings'][1]['2nd innings']['deliveries']:
for k, v in d.items():
if v['runs']['extras'] > 0:
extras_2.append(v['runs']['extras'])
for d in data['innings'][0]['1st innings']['deliveries']:
for k, v in d.items():
if v['runs']['extras'] > 0:
extras_1.append(v['runs']['extras'])

# Write your code here


difference =

difference = len(extras_2) - len(extras_1)

return difference

extras_runs(data)