From c6371bca5e182143781fc94f1ab49d8c2ef5f30b Mon Sep 17 00:00:00 2001 From: vaibhav-cric Date: Sun, 23 Sep 2018 05:25:18 +0000 Subject: [PATCH 1/9] Done --- q01_read_data/build.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/q01_read_data/build.py b/q01_read_data/build.py index e13d2f74..c05e75cf 100644 --- a/q01_read_data/build.py +++ b/q01_read_data/build.py @@ -1,12 +1,16 @@ +# %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 = + data =yaml.load(open('./data/ipl_match.yaml')) # return data variable return data + + + From 0ad79f00ecc0900ba2a7ba8be3a212e1ac77d50e Mon Sep 17 00:00:00 2001 From: vaibhav-cric Date: Tue, 2 Oct 2018 12:22:30 +0000 Subject: [PATCH 2/9] Done --- q02_teams/build.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/q02_teams/build.py b/q02_teams/build.py index 3cf9d3cf..3f17f6e9 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,9 @@ def teams(data=data): # write your code here - #teams = + teams = data['info']['teams'] return teams + + + From 784c7bbc479cc18c0eee28627bda8e6f969daa52 Mon Sep 17 00:00:00 2001 From: vaibhav-cric Date: Tue, 2 Oct 2018 12:27:39 +0000 Subject: [PATCH 3/9] Done --- q02_teams/build.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/q02_teams/build.py b/q02_teams/build.py index 3f17f6e9..5634db0b 100644 --- a/q02_teams/build.py +++ b/q02_teams/build.py @@ -10,6 +10,7 @@ def teams(data=data): teams = data['info']['teams'] return teams - +T = teams() +T From dec960902f2473123a21aa76bab864ed4ba019d6 Mon Sep 17 00:00:00 2001 From: vaibhav-cric Date: Tue, 9 Oct 2018 14:35:20 +0000 Subject: [PATCH 4/9] Done --- q03_first_batsman/build.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/q03_first_batsman/build.py b/q03_first_batsman/build.py index 84984081..d9493085 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,8 @@ def first_batsman(data=data): # Write your code here + name = data['innings'][0]['1st innings'] ['deliveries'] [0][0.1] ['batsman'] + return name - - return name From 1f1dbce7ed9bb00a761e4d3b250de8174ae069b6 Mon Sep 17 00:00:00 2001 From: vaibhav-cric Date: Tue, 9 Oct 2018 15:42:13 +0000 Subject: [PATCH 5/9] Done --- q03_first_batsman/build.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/q03_first_batsman/build.py b/q03_first_batsman/build.py index d9493085..6490c0e6 100644 --- a/q03_first_batsman/build.py +++ b/q03_first_batsman/build.py @@ -10,5 +10,8 @@ def first_batsman(data=data): name = data['innings'][0]['1st innings'] ['deliveries'] [0][0.1] ['batsman'] return name +name = first_batsman() +name + From 53dd72df8aeeb5f5633b63b4ee511c80c0e2d3e6 Mon Sep 17 00:00:00 2001 From: vaibhav-cric Date: Wed, 10 Oct 2018 15:36:59 +0000 Subject: [PATCH 6/9] Done --- q05_runs/build.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/q05_runs/build.py b/q05_runs/build.py index a250631a..53549adb 100644 --- a/q05_runs/build.py +++ b/q05_runs/build.py @@ -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() @@ -7,6 +8,13 @@ def BC_runs(data): # Write your code here + runs = 0 + p = data['innings'][0]['1st innings']['deliveries'] + for a in p: + for b in a: + if (a[b]['batsman'])=='BB McCullum': + runs += (a[b]['runs']['batsman']) + return(runs) +BC_runs(data) - return(runs) From 2bf57edcd39c87156b83a58f2f64f99b2ad2f2d8 Mon Sep 17 00:00:00 2001 From: vaibhav-cric Date: Mon, 22 Oct 2018 14:59:50 +0000 Subject: [PATCH 7/9] Done --- q06_bowled_players/build.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/q06_bowled_players/build.py b/q06_bowled_players/build.py index 914cb6d2..aa5edf1e 100644 --- a/q06_bowled_players/build.py +++ b/q06_bowled_players/build.py @@ -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 +bowled_players = [] def bowled_out(data=data): # Write your code here + bowled_players = [] + for delivery in data['innings'][1]['2nd innings']['deliveries']: + + if(delivery[next(iter(delivery))].get('wicket', {}).get('kind', None) == 'bowled'): + + bowled_players.append(delivery[next(iter(delivery))]['batsman']) return bowled_players + +ao = bowled_out() +ao + + From 37d4be72832f29720a0c13073d44f5a7ddd510a9 Mon Sep 17 00:00:00 2001 From: vaibhav-cric Date: Tue, 23 Oct 2018 23:49:20 +0000 Subject: [PATCH 8/9] Done --- q07_extras/build.py | 69 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 68 insertions(+), 1 deletion(-) diff --git a/q07_extras/build.py b/q07_extras/build.py index cdeb803b..920167e7 100644 --- a/q07_extras/build.py +++ b/q07_extras/build.py @@ -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() @@ -6,9 +7,75 @@ def extras_runs(data=data): # Write your code here + + l=(data['innings'][0]['1st innings']['deliveries']) + E1=[0,0,0] + x=0 + for a in l: + for b in a: + if 'extras' in a[b].keys(): + x+=1 + if 'wides' in a[b]['extras'].keys(): + E1[0]+=1 + elif 'legbyes' in a[b]['extras'].keys(): + E1[1]+=1 + else: + E1[2]+=1 + + l2=(data['innings'][1]['2nd innings']['deliveries']) + E1=[0,0,0] + y=0 + for a in l2: + for b in a: + if 'extras' in a[b].keys(): + y+=1 + if 'wides' in a[b]['extras'].keys(): + E1[0]+=1 - difference = + elif 'legbyes' in a[b]['extras'].keys(): + E1[1]+=1 + else: + E1[2]+=1 + difference = y-x return difference + +l2=(data['innings'][1]['2nd innings']['deliveries']) +E1=[0,0,0] +x=0 +for a in l2: + for b in a: + if 'extras' in a[b].keys(): + x+=1 + if 'wides' in a[b]['extras'].keys(): + E1[0]+=1 + + elif 'legbyes' in a[b]['extras'].keys(): + E1[1]+=1 + else: + E1[2]+=1 +print(E1) +print(x) +(data['innings'][1]['2nd innings']['deliveries'][1][0.2]['extras']) + +l2=(data['innings'][0]['1st innings']['deliveries']) +E1=[0,0,0] +x=0 +for a in l2: + for b in a: + if 'extras' in a[b].keys(): + x+=1 + if 'wides' in a[b]['extras'].keys(): + E1[0]+=1 + + elif 'legbyes' in a[b]['extras'].keys(): + E1[1]+=1 + else: + E1[2]+=1 + +h = extras_runs() +h + + From 096d1e0a8999a49664a75fb3ca8ff7ac8e29ca06 Mon Sep 17 00:00:00 2001 From: vaibhav-cric Date: Wed, 24 Oct 2018 16:54:23 +0000 Subject: [PATCH 9/9] Done --- q04_count/build.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/q04_count/build.py b/q04_count/build.py index 6cf3dcbc..8f867cba 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() @@ -6,6 +7,16 @@ def deliveries_count(data=data): # Your code here + count = 0 - + p=data['innings'][0]['1st innings']['deliveries'] + for a in p: + for b in a: + if (a[b]['batsman'])=='RT Ponting': + count=count+1 + return count + +deliveries_count(data) + +