Skip to content

Commit Live PR #286

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
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
11 changes: 9 additions & 2 deletions q01_read_data/build.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
# %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



8 changes: 8 additions & 0 deletions q02_teams/build.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# %load q02_teams/build.py
# default imports
from greyatomlib.python_getting_started.q01_read_data.build import read_data
data = read_data()
Expand All @@ -7,5 +8,12 @@ def teams(data=data):

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

return teams






6 changes: 4 additions & 2 deletions q03_first_batsman/build.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# %load q03_first_batsman/build.py
# Default Imports
from greyatomlib.python_getting_started.q01_read_data.build import read_data
data = read_data()
Expand All @@ -6,8 +7,9 @@
def first_batsman(data=data):

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

return name




return name
14 changes: 13 additions & 1 deletion q04_count/build.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# %load q04_count/build.py
# Default Imports
from greyatomlib.python_getting_started.q01_read_data.build import read_data
data = read_data()
Expand All @@ -6,6 +7,17 @@
def deliveries_count(data=data):

# Your code here

d=data['innings'][0]['1st innings']['deliveries']
count=0
for item in d:
for v in item.values():
for key,values in v.items():
if key=='batsman':
if values=='RT Ponting':
count=count+1


return count



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

def BC_runs(data=data):
runs=0
d=data['innings'][0]['1st innings']['deliveries']
for i in d:
for v in i.values():
for key,values in v.items():
if key=='batsman':
if values=='BB McCullum':
runs=v.get('runs')['batsman']+runs

return runs


# Your Solution
def BC_runs(data):

# Write your code here


return(runs)
20 changes: 14 additions & 6 deletions q06_bowled_players/build.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
# 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=''
bowled_players=[]
d=data['innings'][1]['2nd innings']['deliveries']
for index,values in enumerate(d):
for key,val in values.items():
for key,v in val.items():
if key=='wicket':
for key,va in v.items():
if key=='kind':
if va=='bowled':
bowled=v.get('player_out')
bowled_players.append(bowled)

return bowled_players

# Write your code here


return bowled_players
31 changes: 22 additions & 9 deletions q07_extras/build.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
# 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


difference =



e1=[]
d1=data['innings'][0]['1st innings']['deliveries']
for index,v in enumerate(d1):
for key,va in v.items():
for key,val in va.items():
if key=='extras':
for key,values in val.items():
e1.append(values)

e2=[]
d2=data['innings'][1]['2nd innings']['deliveries']
for index,v in enumerate(d2):
for key,va in v.items():
for key,val in va.items():
if key=='extras':
for key,values in val.items():
e2.append(values)

difference=len(e2)-len(e1)

return difference