From 7869c1ac6c01ec9bed61a5a3029eec129dc04463 Mon Sep 17 00:00:00 2001 From: kailash55 Date: Sat, 1 Sep 2018 17:36:16 +0000 Subject: [PATCH 1/7] Done --- q01_read_data/build.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/q01_read_data/build.py b/q01_read_data/build.py index e13d2f74..befa6220 100644 --- a/q01_read_data/build.py +++ b/q01_read_data/build.py @@ -1,12 +1,18 @@ +# %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 = + with open('data/ipl_match.yaml','r') as f: + data = yaml.load(f) # return data variable return data + +read_data() + + From 5e7d76d19e25c9237b37ca3e986a2c7a3ac58eb5 Mon Sep 17 00:00:00 2001 From: kailash55 Date: Sat, 6 Oct 2018 18:06:53 +0000 Subject: [PATCH 2/7] Done --- q02_teams/build.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/q02_teams/build.py b/q02_teams/build.py index 3cf9d3cf..fe8358e5 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,11 @@ def teams(data=data): # write your code here - #teams = + teams = data['info']['teams'] return teams + +teams() + + + From 51258b3b8b01bb1083bb45710008e6e7a4251ca6 Mon Sep 17 00:00:00 2001 From: kailash55 Date: Sat, 6 Oct 2018 18:19:01 +0000 Subject: [PATCH 3/7] Done --- q03_first_batsman/build.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/q03_first_batsman/build.py b/q03_first_batsman/build.py index 84984081..6b6a8a36 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,12 @@ def first_batsman(data=data): # Write your code here - + name = data['innings'][0]['1st innings']['deliveries'][0][0.1]['batsman'] return name + +first_batsman() + + From 4c50e20e013b0c3c8061d131767eca2a90d285fc Mon Sep 17 00:00:00 2001 From: kailash55 Date: Sun, 25 Nov 2018 18:42:22 +0000 Subject: [PATCH 4/7] Done --- q04_count/build.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/q04_count/build.py b/q04_count/build.py index 6cf3dcbc..fa4c683d 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,17 @@ def deliveries_count(data=data): # Your code here + deliveries = data['innings'][0]['1st innings']['deliveries'] - + count = 0 + + for x in deliveries: + batsman = list(x.values())[0]['batsman'] + if batsman == 'RT Ponting': + count += 1 return count + +deliveries_count() + + + From 092c2fa69c28fd7fc4f3258412c2483f34856825 Mon Sep 17 00:00:00 2001 From: kailash55 Date: Sun, 25 Nov 2018 18:48:09 +0000 Subject: [PATCH 5/7] Done --- q05_runs/build.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/q05_runs/build.py b/q05_runs/build.py index a250631a..1236c8d1 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() @@ -6,7 +7,17 @@ # Your Solution def BC_runs(data): - # Write your code here + # Your code here + deliveries = data['innings'][0]['1st innings']['deliveries'] + + runs = 0 + + for x in deliveries: + batsman = list(x.values())[0]['batsman'] + if batsman == 'BB McCullum': + runs += list(x.values())[0]['runs']['batsman'] + return(runs) + +BC_runs(data) - return(runs) From ce82accfee75f868db894179150a691e07c510ba Mon Sep 17 00:00:00 2001 From: kailash55 Date: Sun, 25 Nov 2018 18:59:53 +0000 Subject: [PATCH 6/7] Done --- q06_bowled_players/build.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/q06_bowled_players/build.py b/q06_bowled_players/build.py index 914cb6d2..87f588d7 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 def bowled_out(data=data): - + + # Write your code here + bowled_players = [] + deliveries = data['innings'][1]['2nd innings']['deliveries'] + + for x in deliveries: + delivery = list(x.values())[0] + + if 'wicket' in delivery: + if delivery['wicket']['kind'] == 'bowled': + bowled_players.append(delivery['batsman']) + return bowled_players + +bowled_out() - return bowled_players From b91947305ca3c40aca15a1317f8555be90895c2a Mon Sep 17 00:00:00 2001 From: kailash55 Date: Sun, 25 Nov 2018 19:14:47 +0000 Subject: [PATCH 7/7] Done --- q07_extras/build.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/q07_extras/build.py b/q07_extras/build.py index cdeb803b..8a52adba 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() +def calculate_extras(innings): + extras = 0 + for item in innings: + delivery = list(item.values())[0] + if 'extras' in delivery: + extras += 1 + + return extras # Your Solution def extras_runs(data=data): # Write your code here + inning_first = data['innings'][0]['1st innings']['deliveries'] + inning_second = data['innings'][1]['2nd innings']['deliveries'] + extra_inning_first = calculate_extras(inning_first) + extra_inning_second = calculate_extras(inning_second) + difference = extra_inning_second - extra_inning_first - difference = + return difference + +extras_runs() - return difference