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
14 changes: 12 additions & 2 deletions q01_read_data/build.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
# %load q01_read_data/build.py
import yaml

def read_data():

# import the csv file into `data` variable
# import the csv file into 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','r') as f:
data=yaml.load(f)

# return data variable
return data








9 changes: 6 additions & 3 deletions q02_teams/build.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
# %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()


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

# Your Solution
def first_batsman(data=data):
name=data['innings'][0]['1st innings']['deliveries'][0][0.1]['batsman']

# Write your code here




return name


24 changes: 23 additions & 1 deletion q04_count/build.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,33 @@
# %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):
count=0
inf=data['innings']
for i in inf:
for k,v in i.items():
for delivery in v['deliveries']:
for a,b in delivery.items():
if b['batsman']=='RT Ponting':
count+=1





return count




# Your code here


return count


deliveries_count()


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


# Your Solution
def BC_runs(data):
runs=0
inf=data['innings']
for i in inf:
for k,v in i.items():
for delivery in v['deliveries']:
for a,b in delivery.items():
if b['batsman']=='BB McCullum':
runs+=b['runs']['batsman']










# Write your code here


return(runs)



21 changes: 20 additions & 1 deletion q06_bowled_players/build.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,30 @@
# %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=[]
inf=data['innings'][1]
for k,v in inf.items():
for delivery in v['deliveries']:
for a,b in delivery.items():
if 'wicket' in b.keys():
### if b['wicket']['kind']=='caught':
### bowled_players.append([b['wicket']['player_out']])
if(b['wicket']['kind'])=='bowled':
bowled_players.append(b['wicket']['player_out'])





# Write your code here


return bowled_players

bowled_out()


36 changes: 35 additions & 1 deletion q07_extras/build.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,48 @@
# %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):
extra1=[]
extra2=[]

inf1=data['innings'][0]
for k,v in inf1.items():
for delivery in v['deliveries']:
for a,b in delivery.items():
if 'extras' in b.keys():
extra1.append(b['runs']['extras'])
e1=len(extra1)

inf2=data['innings'][1]
for k,v in inf2.items():
for delivery in v['deliveries']:
for a,b in delivery.items():
if 'extras' in b.keys():
extra2.append(b['runs']['extras'])
e2=len(extra2)

difference=e2-e1











# Write your code here


difference =
###difference =


return difference