Skip to content

Commit Live PR #281

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 8 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
Empty file added myfile.txt
Empty file.
17 changes: 13 additions & 4 deletions q01_read_data/build.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
# %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') as file :

data = yaml.load(file)

# return data variable
return data

d = read_data()
d


10 changes: 7 additions & 3 deletions q02_teams/build.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
# %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 =
# write your code here
teams = data['info']['teams']

return teams




11 changes: 10 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,16 @@
def first_batsman(data=data):

# Write your code here


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



return name







16 changes: 12 additions & 4 deletions q04_count/build.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
# %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):
i=0
deliveries = data['innings'][0]['1st innings']['deliveries']
for delivery in deliveries:
for delivery_number, delivery_info in delivery.items():
if delivery_info['batsman'] == 'RT Ponting':
i += 1

# Your code here


return count
return i



16 changes: 15 additions & 1 deletion 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 @@ -7,6 +8,19 @@
def BC_runs(data):

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

runs = 0

for i in deliveries:
for key in i:
run_var = i[key]
if run_var['batsman'] == 'BB McCullum':
runs += run_var['runs']['batsman']

return(runs)

b = BC_runs(data)
b


return(runs)
34 changes: 34 additions & 0 deletions q06_bowled_players/build.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# %load q06_bowled_players/build.py
# Default Imports
from greyatomlib.python_getting_started.q01_read_data.build import read_data
data = read_data()
Expand All @@ -6,6 +7,39 @@
def bowled_out(data=data):

# Write your code here
bowled_players = []




return bowled_players

# %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 delivery in deliveries:

for key in delivery:

run_variable = delivery[key]

if 'wicket' in run_variable and run_variable['wicket']['kind'] == 'bowled':

bowled_players.append(run_variable['batsman'])




return bowled_players



59 changes: 58 additions & 1 deletion q07_extras/build.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,34 @@
from greyatomlib.python_getting_started.q01_read_data.build import read_data
data = read_data()

def extras_runs(data=data):
deliveries1 = data['innings'][0]['1st innings']['deliveries']
extras1=[]

for delivery1 in deliveries1:

for key in delivery1:

extras1.append(delivery1[key]['runs']['extras'])

deliveries2 = data['innings'][1]['2nd innings']['deliveries']

extras2=[]

for delivery2 in deliveries2:

for key in delivery2:

extras2.append(delivery2[key]['runs']['extras'])

difference=sum(extras2)-sum(extras1)

return difference

e = extras_runs(data=data)
e

# %load q07_extras/build.py
# Default Imports
from greyatomlib.python_getting_started.q01_read_data.build import read_data
data = read_data()
Expand All @@ -6,9 +37,35 @@
def extras_runs(data=data):

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


for i in deliveries1:
for key in i:
run_var = i[key]
if 'extras' in run_var:
for key1 in run_var['extras']:
first_innings += 1


difference =
second_innings = 0
deliveries2 = data['innings'][1]['2nd innings']['deliveries']


for i in deliveries2:
for key in i:
run_var = i[key]
if 'extras' in run_var:
for key2 in run_var['extras']:
second_innings += 1


difference = (second_innings - first_innings)

return difference

extras_runs(data=data)