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

def read_data():

def read_data(path='./data/ipl_match.yaml'):
# 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(path,'r') as yfile:
data=yaml.load(yfile)
# return data variable
return data
2 changes: 1 addition & 1 deletion q02_teams/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
def teams(data=data):

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

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

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
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


# Your code here
count=0
d= data['innings'][0]['1st innings']['deliveries']
l= len(d)
for i in range(0,l-1):
k=d[i].keys()
if d[i][k[0]]['batsman']=='RT Ponting':
count+=1
return count
10 changes: 7 additions & 3 deletions q05_runs/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@

# Your Solution
def BC_runs(data):

# Write your code here


runs=0
d= data['innings'][0]['1st innings']['deliveries']
l= len(d)
for i in range(0, l):
k=d[i].keys()
if d[i][k[0]]['batsman']=='BB McCullum':
runs+=d[i][k[0]]['runs']['batsman']
return(runs)
11 changes: 7 additions & 4 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=[]
d2= data['innings'][1]['2nd innings']['deliveries']
l2=len(d2)
for i in range(0,l2):
k2=d2[i].keys()
if ('wicket' in d2[i][k2[0]]) and ((d2[i][k2[0]]['wicket']['kind']) == 'bowled'):
bowled_players.append(d2[i][k2[0]]['wicket']['player_out'])
return bowled_players
19 changes: 16 additions & 3 deletions q07_extras/build.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
# Default Imports
import yaml
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
extras1=[]
extras2=[]

d= data['innings'][0]['1st innings']['deliveries']
l= len(d)
for i in range(0, l):
k=d[i].keys()
if d[i][k[0]]['runs']['extras']!=0:
extras1.append(d[i][k[0]]['runs']['extras'])

difference =
d2= data['innings'][1]['2nd innings']['deliveries']
l2= len(d2)
for i in range(0, l2):
k2=d2[i].keys()
if d2[i][k2[0]]['runs']['extras']!=0:
extras2.append(d2[i][k2[0]]['runs']['extras'])

difference = abs(len(extras1) - len(extras2))

return difference