Skip to content

Commit Live PR #276

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
12 changes: 9 additions & 3 deletions q01_read_data/build.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
# %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

read_data()


8 changes: 7 additions & 1 deletion 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 @@ -6,6 +7,11 @@
def teams(data=data):

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

return teams

teams()



7 changes: 6 additions & 1 deletion 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,12 @@
def first_batsman(data=data):

# Write your code here

name = data['innings'][0]['1st innings']['deliveries'][0][0.1]['batsman']



return name

first_batsman()


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
deliveries = data['innings'][0]['1st innings']['deliveries']


count = 0

for x in deliveries:
batsman = list(x.values())[0]['batsman']
if batsman == 'RT Ponting':
count += 1
return count

deliveries_count()



15 changes: 13 additions & 2 deletions q05_runs/build.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# %load q05_runs/build.py
# Default Imports
from greyatomlib.python_getting_started.q01_read_data.build import read_data
data = read_data()
Expand All @@ -6,7 +7,17 @@
# Your Solution
def BC_runs(data):

# Write your code here
# Your code here
deliveries = data['innings'][0]['1st innings']['deliveries']

runs = 0

for x in deliveries:
batsman = list(x.values())[0]['batsman']
if batsman == 'BB McCullum':
runs += list(x.values())[0]['runs']['batsman']
return(runs)

BC_runs(data)


return(runs)
17 changes: 15 additions & 2 deletions q06_bowled_players/build.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
# %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
bowled_players = []
deliveries = data['innings'][1]['2nd innings']['deliveries']

for x in deliveries:
delivery = list(x.values())[0]

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

bowled_out()


return bowled_players
19 changes: 17 additions & 2 deletions q07_extras/build.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,29 @@
# %load q07_extras/build.py
# Default Imports
from greyatomlib.python_getting_started.q01_read_data.build import read_data
data = read_data()

def calculate_extras(innings):
extras = 0
for item in innings:
delivery = list(item.values())[0]
if 'extras' in delivery:
extras += 1

return extras
# Your Solution
def extras_runs(data=data):

# Write your code here
inning_first = data['innings'][0]['1st innings']['deliveries']
inning_second = data['innings'][1]['2nd innings']['deliveries']
extra_inning_first = calculate_extras(inning_first)
extra_inning_second = calculate_extras(inning_second)
difference = extra_inning_second - extra_inning_first


difference =
return difference

extras_runs()


return difference