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
@@ -1,12 +1,13 @@
import yaml

def read_data():

#import csv
# 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
read_data()
7 changes: 3 additions & 4 deletions q02_teams/build.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# %load q02_teams/build.py
# default imports
from greyatomlib.python_getting_started.q01_read_data.build import read_data
data = read_data()

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

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



Expand Down
16 changes: 13 additions & 3 deletions q04_count/build.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
# Default Imports
from greyatomlib.python_getting_started.q01_read_data.build import read_data
#import yaml
#count = 0
#with open('../data/ipl_match.yaml') as f:
#data = yaml.load(f)
data = read_data()

#print data

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

# Your code here

count = 0
for i in range (len(data['innings'][0]['1st innings']['deliveries'])):
a = data['innings'][0]['1st innings']['deliveries'][i].values()
if (a[0]['batsman']) == "RT Ponting":
count = count+1
print count

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

# Your Solution
def BC_runs(data):

# Write your code here
runs = 0
run = 0
count = 0
for i in range (len(data['innings'][0]['1st innings']['deliveries'])):
a = data['innings'][0]['1st innings']['deliveries'][i].values()
if (a[0]['batsman']) == "BB McCullum":
run = a[0]['runs']['batsman']
count = count+run
#print count
runs=count


return(runs)
16 changes: 14 additions & 2 deletions q06_bowled_players/build.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
# %load q06_bowled_players/build.py
# Default Imports
from greyatomlib.python_getting_started.q01_read_data.build import read_data
data = read_data()

# Your Solution
def bowled_out(data=data):

# Write your code here
bowled_players = []

for ball in range (len(data['innings'][1]['2nd innings']['deliveries'])):
ball_number = list(data['innings'][1]['2nd innings']['deliveries'][ball].keys())[0]
if 'wicket' in (data['innings'][1]['2nd innings']['deliveries'][ball][ball_number].keys()):
if (data['innings'][1]['2nd innings']['deliveries'][ball][ball_number]['wicket']['kind']) == 'bowled':
bowled_players.append((data['innings'][1]['2nd innings']['deliveries'][ball][ball_number]['batsman']))



return bowled_players





24 changes: 22 additions & 2 deletions q07_extras/build.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,34 @@
# %load q07_extras/build.py
# 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
extras2 = 0
for ball in range (len(data['innings'][1]['2nd innings']['deliveries'])):
ball_number = list(data['innings'][1]['2nd innings']['deliveries'][ball].keys())[0]
if 'extras' in (data['innings'][1]['2nd innings']['deliveries'][ball][ball_number].keys()):
extras2 = extras2 + 1


extras1 = 0
for ball in range (len(data['innings'][0]['1st innings']['deliveries'])):
ball_number = list(data['innings'][0]['1st innings']['deliveries'][ball].keys())[0]
if 'extras' in (data['innings'][0]['1st innings']['deliveries'][ball][ball_number].keys()):
extras1 = extras1 + 1


difference =
difference = extras2 - extras1


return difference