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
7 changes: 4 additions & 3 deletions q01_read_data/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

def read_data():

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


# return data variable
return data
return matchdata
1 change: 1 addition & 0 deletions q02_teams/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ def teams(data=data):
# write your code here
#teams =

teams =data['info']['teams']
return teams
2 changes: 2 additions & 0 deletions q03_first_batsman/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
def first_batsman(data=data):

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



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

# 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 delivery_num, delivery_info in delivery.items():
if delivery_info["batsman"] == "RT Ponting":
count = count + 1

print count

return count
9 changes: 9 additions & 0 deletions q05_runs/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@
def BC_runs(data):

# Write your code here
runs = 0

deliveries = data["innings"][0]["1st innings"]["deliveries"]

for delivery in deliveries :
for delivery_num, delivery_info in delivery.items() :
if delivery_info["batsman"] == "BB McCullum" :
runs = runs + delivery_info["runs"]["batsman"]

print runs

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

# Write your code here
bowled = []
deliveries = data["innings"][1]["2nd innings"]["deliveries"]

for delivery in deliveries :
for delivery_num, delivery_info in delivery.items() :
if "wicket" in delivery_info.keys() :
if delivery_info["wicket"]["kind"] == "bowled" :
bowled.append(delivery_info["batsman"])

return bowled_players
print bowled

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

# Write your code here
extra_1 = 0
extra_2 = 0

deliveries1 = data["innings"][0]["1st innings"]["deliveries"]
deliveries2 = data["innings"][1]["2nd innings"]["deliveries"]

difference =
for delivery1 in deliveries1:
for delivery1_num, delivery1_info in delivery1.items() :
if "extras" in delivery1_info.keys() :
extra_1 = extra_1 + 1

for delivery2 in deliveries2:
for delivery2_num, delivery2_info in delivery2.items() :
if "extras" in delivery2_info.keys() :
extra_2 = extra_2 + 1

return difference
diff = extra_2 - extra_1

return diff