Skip to content

Commit Live PR #288

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
10 changes: 5 additions & 5 deletions q01_read_data/build.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
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 stream:
data = yaml.load(stream)
# return data variable
return data


18 changes: 9 additions & 9 deletions q02_teams/build.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# default imports
from greyatomlib.python_getting_started.q01_read_data.build import read_data
data = read_data()
import yaml
def teams(data):
info = data['info']
team = info['teams']
return team

# solution
def teams(data=data):
with open('data/ipl_match.yaml','r') as stream:
data = yaml.load(stream)

teams(data)

# write your code here
#teams =

return teams
8 changes: 3 additions & 5 deletions q03_first_batsman/build.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
# %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):

# Write your code here


name = batsman_name = data['innings'][0].get('1st innings').get('deliveries')[0].get(0.1).get('batsman')
return name


return name
15 changes: 11 additions & 4 deletions q04_count/build.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
# %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


count = 0
first_innings = data['innings'][0].get('1st innings').get('deliveries')
count = 0
for x in range(0,len(first_innings)):
delivery = first_innings[x]
for key in delivery:
if delivery[key].get('batsman') == 'RT Ponting':
count = count+1
return count

14 changes: 10 additions & 4 deletions q05_runs/build.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
# %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):
first_innings = data['innings'][0].get('1st innings').get('deliveries')
count = 0
runs = 0
for x in range(0,len(first_innings)):
delivery = first_innings[x]
for key in delivery:
if delivery[key].get('batsman') == 'BB McCullum':
runs = runs + delivery[key].get('runs').get('batsman')
return runs

# Write your code here


return(runs)
18 changes: 14 additions & 4 deletions q06_bowled_players/build.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
# %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


second_innings = data['innings'][1].get('2nd innings').get('deliveries')
bowled_players = []

for x in range(0,len(second_innings)):
delivery = second_innings[x]

for key in delivery:
if delivery[key].get('wicket') != None:

if delivery[key].get('wicket').get('kind') == 'bowled':
bowled_players.append(delivery[key].get('batsman'))

return bowled_players

30 changes: 24 additions & 6 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):

# Write your code here


difference =


st_innis = data.get('innings')[0].get('1st innings').get('deliveries')
nd_innis = data.get('innings')[1].get('2nd innings').get('deliveries')

extras_in_st_inngs = []
extras_in_nd_inngs = []

for x in range(0,len(st_innis)):
current_delivery = st_innis[x]
for key in current_delivery:
extras_per_delivery = current_delivery.get(key).get('runs').get('extras')
if extras_per_delivery != 0:
extras_in_st_inngs.append(extras_per_delivery)


for x in range(0,len(nd_innis)):
current_delivery = nd_innis[x]
for key in current_delivery:
extras_per_delivery = current_delivery.get(key).get('runs').get('extras')
if extras_per_delivery != 0:
extras_in_nd_inngs.append(extras_per_delivery)

difference = len(extras_in_nd_inngs)-len(extras_in_st_inngs)
return difference