From eea2567de6fcf44fff228aa0290a044ff8e1dc02 Mon Sep 17 00:00:00 2001 From: Jas-simran Date: Mon, 3 Sep 2018 17:02:41 +0000 Subject: [PATCH 1/7] Done --- q01_read_data/build.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/q01_read_data/build.py b/q01_read_data/build.py index e13d2f74..8dd3539f 100644 --- a/q01_read_data/build.py +++ b/q01_read_data/build.py @@ -1,12 +1,16 @@ + 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 From c7256e4460cdcdf2bd13dff94f2b917b5c02b958 Mon Sep 17 00:00:00 2001 From: Jas-simran Date: Tue, 4 Sep 2018 11:41:40 +0000 Subject: [PATCH 2/7] Done --- q02_teams/build.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/q02_teams/build.py b/q02_teams/build.py index 3cf9d3cf..88b7b997 100644 --- a/q02_teams/build.py +++ b/q02_teams/build.py @@ -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() @@ -6,6 +7,10 @@ def teams(data=data): # write your code here - #teams = - + teams =data['info']['teams'] + print(type(teams)) return teams +teams() + + + From d41014a1b199d5e135907c42d0c40a402efb94c3 Mon Sep 17 00:00:00 2001 From: Jas-simran Date: Tue, 4 Sep 2018 11:56:14 +0000 Subject: [PATCH 3/7] Done --- q03_first_batsman/build.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/q03_first_batsman/build.py b/q03_first_batsman/build.py index 84984081..06e4e33b 100644 --- a/q03_first_batsman/build.py +++ b/q03_first_batsman/build.py @@ -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() @@ -6,8 +7,15 @@ 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 From 3c835830fdd5c1bf140d6cb4951fbdd8fd0f5df9 Mon Sep 17 00:00:00 2001 From: Jas-simran Date: Wed, 5 Sep 2018 17:00:33 +0000 Subject: [PATCH 4/7] Done --- q04_count/build.py | 18 ++++++++++++++++-- q05_runs/build.py | 14 +++++++++++--- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/q04_count/build.py b/q04_count/build.py index 6cf3dcbc..3ee5fb28 100644 --- a/q04_count/build.py +++ b/q04_count/build.py @@ -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() @@ -5,7 +6,20 @@ # Your Solution Here def deliveries_count(data=data): - # Your code here - + count = 0 + + l=data['innings'][0]['1st innings']['deliveries'] + for x in l: + for y in x: + if(x[y]['batsman'])=='RT Ponting': + count=count+1 + + return count + + + + + + diff --git a/q05_runs/build.py b/q05_runs/build.py index a250631a..f9ec9995 100644 --- a/q05_runs/build.py +++ b/q05_runs/build.py @@ -1,12 +1,20 @@ +# %load q05_runs/build.py # Default Imports from greyatomlib.python_getting_started.q01_read_data.build import read_data data = read_data() +from unittest import TestCase # Your Solution -def BC_runs(data): - # Write your code here + +class TestBC_runs(TestCase): + def test_BC_runs_return_type() + self.assertIsInstance(McCullum_runs, int, 'The Expected type does not match the return type') + + def test_BC_runs_return_values(self): + self.assertEqual(158, McCullum_runs, 'The Expected value does not match the return value') + + - return(runs) From 351f1b0381240f318266406a9b3eb3ab26263773 Mon Sep 17 00:00:00 2001 From: Jas-simran Date: Wed, 5 Sep 2018 17:03:42 +0000 Subject: [PATCH 5/7] Done --- q05_runs/build.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/q05_runs/build.py b/q05_runs/build.py index f9ec9995..5aa27fbc 100644 --- a/q05_runs/build.py +++ b/q05_runs/build.py @@ -6,14 +6,20 @@ # Your Solution +def BC_runs(data): + + l=(data['innings'][0]['1st innings']['deliveries']) + c=0 + for x in l: + for y in x: + if(x[y]['batsman'])=='BB McCullum': + c+=(x[y]['runs']['batsman']) + -class TestBC_runs(TestCase): - def test_BC_runs_return_type() - self.assertIsInstance(McCullum_runs, int, 'The Expected type does not match the return type') - def test_BC_runs_return_values(self): - self.assertEqual(158, McCullum_runs, 'The Expected value does not match the return value') + runs=c + return(runs) From 1ed30722d063dc0652977334df89b77bd999c46f Mon Sep 17 00:00:00 2001 From: Jas-simran Date: Wed, 26 Sep 2018 17:11:34 +0000 Subject: [PATCH 6/7] Done --- q06_bowled_players/build.py | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/q06_bowled_players/build.py b/q06_bowled_players/build.py index 914cb6d2..af2e34c4 100644 --- a/q06_bowled_players/build.py +++ b/q06_bowled_players/build.py @@ -1,11 +1,32 @@ +# %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 + l=(data['innings'][1]['2nd innings']['deliveries']) + c=[] + + for x in l: + for y in x: + if 'wicket' in x[y]: + + if 'bowled' in x[y]['wicket']['kind']: + print(x[y]['wicket']['player_out']) + + c.append(x[y]['wicket']['player_out']) + + bowled_players=c + return bowled_players + - # Write your code here + + + + +bowled_out - return bowled_players From ce29beef55b0e153f4876db1240cd2fe4b91750e Mon Sep 17 00:00:00 2001 From: Jas-simran Date: Mon, 1 Oct 2018 20:56:21 +0000 Subject: [PATCH 7/7] Done --- q07_extras/build.py | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/q07_extras/build.py b/q07_extras/build.py index cdeb803b..b872fcee 100644 --- a/q07_extras/build.py +++ b/q07_extras/build.py @@ -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() # Your Solution def extras_runs(data=data): - - # Write your code here - - - difference = + ball=data['innings'][0]['1st innings']['deliveries'] + list_of_a=[] + for x in range(len(ball)): + d=data['innings'][0]['1st innings']['deliveries'][x] + for v in d.keys(): + if 'extras' in d[v]: + list_of_a.append(d[v]['extras']) + ball2=data['innings'][1]['2nd innings']['deliveries'] + list_of_b=[] + for x in range(len(ball2)): + d2=data['innings'][1]['2nd innings']['deliveries'][x] + for v2 in d2.keys(): + if 'extras' in d2[v2]: + list_of_b.append (d2[v2] ['extras']) + + + + difference=len(list_of_b)-len(list_of_a) + return difference +extras_runs(data) - return difference