Skip to content
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

Commit Live PR #290

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
21 changes: 16 additions & 5 deletions q01_read_data/build.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
# %load q01_read_data/build.py
import yaml

def read_data():

# import the csv file into `data` variable
# You can use this path to access the CSV file: '../data/ipl_match.yaml'
# import the csv file into variable
#ta 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 file_obj:
data = yaml.load(file_obj) # to load content of file
#print(type(data))
print(data)

# return data variable
return data
read_data()






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

# write your code here
#teams =

teams = data['info']['teams']
print(type(teams))
return teams
teams()


8 changes: 7 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,13 @@
def first_batsman(data=data):

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


return name
name = first_batsman()
print(name)



return name
21 changes: 21 additions & 0 deletions q04_count/build.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,32 @@
# %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
number_of_bowl = len(data['innings'][0]['1st innings']['deliveries']) #no of ball in 1st innings
count = 0 #to count the number of ball RT pointing played

for ball_no in range(number_of_bowl): #loop over each ball

#return dictionary of particular ball no
di = data['innings'][0]['1st innings']['deliveries'][ball_no]

for ke in di.keys():
if data['innings'][0]['1st innings']['deliveries'][ball_no][ke]['batsman'] == 'RT Ponting':
count = count + 1
print(type(count))

return count

deliveries_count()






19 changes: 18 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,22 @@
def BC_runs(data):

# Write your code here

number_of_bowl = len(data['innings'][0]['1st innings']['deliveries']) #no of ball in 1st innings
runs = 0 #to count the number of runs scored by Brendon maCcullum

for ball_no in range(number_of_bowl): #loop over each ball

#return dictionary of particular ball no
di = data['innings'][0]['1st innings']['deliveries'][ball_no]

for ke in di.keys():
if data['innings'][0]['1st innings']['deliveries'][ball_no][ke]['batsman'] == 'BB McCullum':

runs = runs + data['innings'][0]['1st innings']['deliveries'][ball_no][ke]['runs']['batsman']


return(runs)

BC_runs(data)


26 changes: 25 additions & 1 deletion 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,29 @@
def bowled_out(data=data):

# Write your code here


bowled_players = [] #empty list for storing bowled players

#total number of ball played in whole match
number_of_balls_played = len(data['innings'][1]['2nd innings']['deliveries'])

for ball_number in range(number_of_balls_played):

#dictionary of each ball
di = data['innings'][1]['2nd innings']['deliveries'][ball_number]

for ke in di.keys(): # to get inside the ball details

# check whether player out or not in particular ball
if ( 'wicket' in data['innings'][1]['2nd innings']['deliveries'][ball_number][ke].keys()):

# check wicket get was bowled
if data['innings'][1]['2nd innings']['deliveries'][ball_number][ke]['wicket']['kind'] == 'bowled':

bowled_players.append(data['innings'][1]['2nd innings']['deliveries'][ball_number][ke]['wicket']['player_out'])

return bowled_players

bowled_out(data)


41 changes: 39 additions & 2 deletions q07_extras/build.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# %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 +7,45 @@
def extras_runs(data=data):

# Write your code here
#for Ist innings

list_of_extra_runs_in_1st_innings = []
number_of_balls_played = len(data['innings'][0]['1st innings']['deliveries'])


for ball_number in range(number_of_balls_played):

di = data['innings'][0]['1st innings']['deliveries'][ball_number]

for ke in di.keys():

if 'extras' in data['innings'][0]['1st innings']['deliveries'][ball_number][ke]:
list_of_extra_runs_in_1st_innings.append(data['innings'][0]['1st innings']['deliveries'][ball_number][ke]['extras'])


# for 2nd innings

list_of_extra_runs_in_2nd_innings = []
number_of_balls_played = len(data['innings'][1]['2nd innings']['deliveries'])


for ball_number in range(number_of_balls_played):

di = data['innings'][1]['2nd innings']['deliveries'][ball_number]

for ke in di.keys():

if 'extras' in data['innings'][1]['2nd innings']['deliveries'][ball_number][ke]:
list_of_extra_runs_in_2nd_innings.append(data['innings'][1]['2nd innings']['deliveries'][ball_number][ke]['extras'])





difference = len(list_of_extra_runs_in_2nd_innings) - len (list_of_extra_runs_in_1st_innings)

return difference

difference =
extras_runs()


return difference