Skip to content

Commit Live PR #280

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

def read_data():
with open('./data/ipl_match.yaml') as f:
data = yaml.load(f)
return data

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

# return data variable
return data
8 changes: 4 additions & 4 deletions q02_teams/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

# solution
def teams(data=data):

# write your code here
#teams =

teams = data['info']['teams']
return teams



12 changes: 7 additions & 5 deletions q03_first_batsman/build.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
# Default Imports
# default imports
from unittest import TestCase
from greyatomlib.python_getting_started.q01_read_data.build import read_data

data = read_data()

# Your Solution
def first_batsman(data=data):

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

# Write your code here

first_batsman()



return name
20 changes: 16 additions & 4 deletions q04_count/build.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
# %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
deliveries_faced = data['innings'][0]['1st innings']['deliveries']
for ele in deliveries_faced:
for key, value in ele.items():
batsman_name = value['batsman']
print (batsman_name)
if (batsman_name == 'RT Ponting'):
count = count+1
return count

deliveries_count(data)





27 changes: 20 additions & 7 deletions q05_runs/build.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@

# Default Imports
from greyatomlib.python_getting_started.q01_read_data.build import read_data
data = read_data()
# Your Solution Here
def BC_runs (data=data):
# Initialize the variable
runs = 0
runs_scored = 0
# Read list value for deliveries
deliveries_info = data['innings'][0]['1st innings']['deliveries']
for ele in deliveries_info:
# Read jey value pair
for key, value in ele.items():
batsman_name = value['batsman']
runs_scored = value['runs']['batsman']
#Check specific batsman
if (batsman_name == 'BB McCullum'):
runs += runs_scored
return runs
data = read_data()
print (data['innings'][0]['1st innings']['deliveries'][0][0.1])
BC_runs(data)


# Your Solution
def BC_runs(data):

# Write your code here


return(runs)
27 changes: 23 additions & 4 deletions q06_bowled_players/build.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,30 @@

# Default Imports
from greyatomlib.python_getting_started.q01_read_data.build import read_data
data = read_data()
# Your Solution Here
def bowled_out (data=data):
# Initialize the variable
bowled_players =[]
runs = 0
runs_scored = 0
# Read list value for deliveries
deliveries_info = data['innings'][1]['2nd innings']['deliveries']
for i in range (len(deliveries_info)):
for key, value in (data['innings'][1]['2nd innings']['deliveries'][i]).items():
batsman_name = value['batsman']
if ('wicket' in data['innings'][1]['2nd innings']['deliveries'][i][key].keys()):
wicket_kind = value ['wicket']
for key, value in wicket_kind.items():
if (value == 'bowled'):
bowled_players.append(batsman_name)
return bowled_players






# Your Solution
def bowled_out(data=data):

# Write your code here


return bowled_players
56 changes: 48 additions & 8 deletions q07_extras/build.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,54 @@
# 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
#Default Imports
from greyatomlib.python_getting_started.q01_read_data.build import read_data
data = read_data()
# Your Solution Here
def extras_runs (data=data):
# Initialize the variable
extras1 = 0
extras2 = 0
difference = 0
# Read list value for deliveries
for num in range (2):
wides =0
legbyes =0
others = 0
if (num ==0):
inning_sequence = '1st innings'

else:
inning_sequence = '2nd innings'

deliveries_info = data['innings'][num][inning_sequence]['deliveries']

#iterate through deliveries
for i in range (len(deliveries_info)):
for key, value in (data['innings'][num][inning_sequence]['deliveries'][i]).items():
if ('extras' in data['innings'][num][inning_sequence]['deliveries'][i][key].keys()):
extra_key_value = value['extras']
for key, value in extra_key_value.items():

if (key == 'wides'):
wides += value
else:
if (key == 'legbyes'):
legbyes += value
else:
others +=others
if (num ==0):
extras1 = wides + legbyes + others
else:
extras2 = wides + legbyes + others

if (extras1>extras2):
difference = extras1 - extras2
else:
difference = extras2 - extras1
return difference

extras_runs(data)


difference =


return difference