From ac3cac890a5f2f9a101ae8fb123a556276f7046d Mon Sep 17 00:00:00 2001 From: seema200 Date: Wed, 24 Jan 2018 03:43:54 +0000 Subject: [PATCH 1/7] Done --- q01_read_data/build.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/q01_read_data/build.py b/q01_read_data/build.py index e13d2f74..fa813b0f 100644 --- a/q01_read_data/build.py +++ b/q01_read_data/build.py @@ -1,12 +1,10 @@ import yaml -def read_data(): - +def read_data(path='./data/ipl_match.yaml'): # 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 = - + with open(path,'r') as yfile: + data=yaml.load(yfile) # return data variable return data From c4dc1fb4ec9b989fe60d8ada62215c86f5303513 Mon Sep 17 00:00:00 2001 From: seema200 Date: Thu, 25 Jan 2018 04:22:32 +0000 Subject: [PATCH 2/7] Done --- q02_teams/build.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/q02_teams/build.py b/q02_teams/build.py index 3cf9d3cf..e68ac45e 100644 --- a/q02_teams/build.py +++ b/q02_teams/build.py @@ -6,6 +6,6 @@ def teams(data=data): # write your code here - #teams = + teams =data['info']['teams'] return teams From 0ec66e45e183e927b54bea1bcf5ddff17167058e Mon Sep 17 00:00:00 2001 From: seema200 Date: Thu, 25 Jan 2018 05:40:11 +0000 Subject: [PATCH 3/7] Done --- q03_first_batsman/build.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/q03_first_batsman/build.py b/q03_first_batsman/build.py index 84984081..9355e7bc 100644 --- a/q03_first_batsman/build.py +++ b/q03_first_batsman/build.py @@ -1,13 +1,10 @@ # Default Imports from greyatomlib.python_getting_started.q01_read_data.build import read_data data = read_data() - +name='' # Your Solution def first_batsman(data=data): # Write your code here - - - - + name= data['innings'][0]['1st innings']['deliveries'][0][0.1]['batsman'] return name From d064e65081d0cd2a5687f3641f6ca66005eefd59 Mon Sep 17 00:00:00 2001 From: seema200 Date: Wed, 31 Jan 2018 05:39:39 +0000 Subject: [PATCH 4/7] Done --- q04_count/build.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/q04_count/build.py b/q04_count/build.py index 6cf3dcbc..1b930001 100644 --- a/q04_count/build.py +++ b/q04_count/build.py @@ -4,8 +4,13 @@ # Your Solution Here def deliveries_count(data=data): - - # Your code here - + # Your code here + count=0 + d= data['innings'][0]['1st innings']['deliveries'] + l= len(d) + for i in range(0,l-1): + k=d[i].keys() + if d[i][k[0]]['batsman']=='RT Ponting': + count+=1 return count From 69be326b8ddf7387bb7b9831120dc1458bb0dd9d Mon Sep 17 00:00:00 2001 From: seema200 Date: Wed, 31 Jan 2018 06:02:46 +0000 Subject: [PATCH 5/7] Done --- q05_runs/build.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/q05_runs/build.py b/q05_runs/build.py index a250631a..ba61de60 100644 --- a/q05_runs/build.py +++ b/q05_runs/build.py @@ -5,8 +5,12 @@ # Your Solution def BC_runs(data): - # Write your code here - - + runs=0 + d= data['innings'][0]['1st innings']['deliveries'] + l= len(d) + for i in range(0, l): + k=d[i].keys() + if d[i][k[0]]['batsman']=='BB McCullum': + runs+=d[i][k[0]]['runs']['batsman'] return(runs) From c4658b300e77f0e3963c4151d1dff20143a7764c Mon Sep 17 00:00:00 2001 From: seema200 Date: Thu, 8 Feb 2018 09:31:13 +0000 Subject: [PATCH 6/7] Done --- q06_bowled_players/build.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/q06_bowled_players/build.py b/q06_bowled_players/build.py index 914cb6d2..d416a53d 100644 --- a/q06_bowled_players/build.py +++ b/q06_bowled_players/build.py @@ -4,8 +4,11 @@ # Your Solution def bowled_out(data=data): - - # Write your code here - - + bowled_players=[] + d2= data['innings'][1]['2nd innings']['deliveries'] + l2=len(d2) + for i in range(0,l2): + k2=d2[i].keys() + if ('wicket' in d2[i][k2[0]]) and ((d2[i][k2[0]]['wicket']['kind']) == 'bowled'): + bowled_players.append(d2[i][k2[0]]['wicket']['player_out']) return bowled_players From 7855e3494a544ce32f9c309d79372dc081cf8e33 Mon Sep 17 00:00:00 2001 From: seema200 Date: Fri, 9 Feb 2018 08:53:04 +0000 Subject: [PATCH 7/7] Done --- q07_extras/build.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/q07_extras/build.py b/q07_extras/build.py index cdeb803b..0161dbef 100644 --- a/q07_extras/build.py +++ b/q07_extras/build.py @@ -1,14 +1,27 @@ -# Default Imports +import yaml 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 + extras1=[] + extras2=[] + d= data['innings'][0]['1st innings']['deliveries'] + l= len(d) + for i in range(0, l): + k=d[i].keys() + if d[i][k[0]]['runs']['extras']!=0: + extras1.append(d[i][k[0]]['runs']['extras']) - difference = + d2= data['innings'][1]['2nd innings']['deliveries'] + l2= len(d2) + for i in range(0, l2): + k2=d2[i].keys() + if d2[i][k2[0]]['runs']['extras']!=0: + extras2.append(d2[i][k2[0]]['runs']['extras']) + difference = abs(len(extras1) - len(extras2)) return difference