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
12 changes: 4 additions & 8 deletions q01_read_data/build.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import yaml

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 =

# return data variable
with open('./data/ipl_match.yaml') as f:
data = yaml.load(f)
print data
return data
read_data()
8 changes: 4 additions & 4 deletions q02_teams/build.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# %load q02_teams/build.py
# default imports
from greyatomlib.python_getting_started.q01_read_data.build import read_data
data = read_data()

# solution
def teams(data=data):

# write your code here
#teams =
teams = data['info']['teams']

return teams

teams()
9 changes: 4 additions & 5 deletions q03_first_batsman/build.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# %load q03_first_batsman/build.py
# Default Imports
from greyatomlib.python_getting_started.q01_read_data.build import read_data
data = read_data()

global name
# 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()
28 changes: 17 additions & 11 deletions q04_count/build.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
# Default Imports
from greyatomlib.python_getting_started.q01_read_data.build import read_data
data = read_data()

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

# Your code here


return count
# %load q04_count/build.py
# Default Imports
from greyatomlib.python_getting_started.q01_read_data.build import read_data
data = read_data()

# Your Solution Here
def deliveries_count(data=data):
# Your code here
x = data['innings'][0]['1st innings']['deliveries']
count=0
for a in x:
for i in a:
if a[i]['batsman'] == 'RT Ponting':
count+=1
return count

deliveries_count()
12 changes: 11 additions & 1 deletion q05_runs/build.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Default Imports
# %load q05_runs/build.py
# Default Imports
from greyatomlib.python_getting_started.q01_read_data.build import read_data
data = read_data()

Expand All @@ -7,6 +9,14 @@
def BC_runs(data):

# Write your code here

runs=0
for a in data['innings']:
for i in a:
for b in a[i]['deliveries']:
for k in b:
if b[k]['batsman'] == 'BB McCullum':
runs=runs+b[k]['runs']['batsman']

return(runs)

BC_runs(data)
11 changes: 10 additions & 1 deletion q06_bowled_players/build.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
# %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):

bowled_players=[]
x=data['innings'][1]['2nd innings']['deliveries']
for a in x:
for i in a:
if 'wicket' in a[i]:
if a[i]['wicket']['kind'] == 'bowled':
bowled_players.append(a[i]['wicket']['player_out'])
# Write your code here


return bowled_players

bowled_out()
26 changes: 22 additions & 4 deletions q07_extras/build.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,32 @@
# %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):
firstextra = 0
secondextra = 0
y=data['innings'][0]['1st innings']['deliveries']
for a in y:
for i in a:
if 'extras' in a[i]:
firstextra +=1

# Write your code here


difference =
#print firstextra
x=data['innings'][1]['2nd innings']['deliveries']
for a in x:
for i in a:
if 'extras' in a[i]:
secondextra +=1
#print secondextra
#d=secondextra - firstextra
if (secondextra - firstextra) > 0:
difference = (secondextra - firstextra)
else:
difference = (firstextra - secondextra)


return difference

extras_runs()