From 8a02658c3c2e968ad484ef277768c7ee76a997af Mon Sep 17 00:00:00 2001 From: rameshpedagani Date: Sun, 2 Sep 2018 04:08:37 +0000 Subject: [PATCH 1/7] Done --- ipl_match.yaml | 12 ++++++++++++ q01_read_data/build.py | 13 +++++-------- 2 files changed, 17 insertions(+), 8 deletions(-) create mode 100644 ipl_match.yaml diff --git a/ipl_match.yaml b/ipl_match.yaml new file mode 100644 index 00000000..a6300c55 --- /dev/null +++ b/ipl_match.yaml @@ -0,0 +1,12 @@ +a list: +- 1 +- 42 +- 3.141 +- 1337 +- help +- "â\x82¬" +a string: bla +another dict: + foo: bar + key: value + the answer: 42 diff --git a/q01_read_data/build.py b/q01_read_data/build.py index e13d2f74..780602a9 100644 --- a/q01_read_data/build.py +++ b/q01_read_data/build.py @@ -1,12 +1,9 @@ -import yaml - def read_data(): + import yaml + with open('ipl_match.yaml', 'r') as f: + doc = yaml.load(f) + return doc + - # 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 41164d228eca3877832f6629a49172c2f8ad6b03 Mon Sep 17 00:00:00 2001 From: rameshpedagani Date: Sun, 2 Sep 2018 05:44:17 +0000 Subject: [PATCH 2/7] Done --- q02_teams/build.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/q02_teams/build.py b/q02_teams/build.py index 3cf9d3cf..d8324fc0 100644 --- a/q02_teams/build.py +++ b/q02_teams/build.py @@ -1,11 +1,14 @@ +# %load q02_teams/build.py # default imports from greyatomlib.python_getting_started.q01_read_data.build import read_data data = read_data() - # solution def teams(data=data): # write your code here #teams = + teams1=data['info']['teams'] + return teams1 + + - return teams From fd5273b4929aaae9aa3e0f3ba44f0a71b432eacd Mon Sep 17 00:00:00 2001 From: rameshpedagani Date: Sun, 2 Sep 2018 07:43:29 +0000 Subject: [PATCH 3/7] Done --- q03_first_batsman/build.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/q03_first_batsman/build.py b/q03_first_batsman/build.py index 84984081..0c605c61 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() @@ -7,7 +8,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 c962be1fcc20f66f039f8e971bf0215945fc4eb3 Mon Sep 17 00:00:00 2001 From: rameshpedagani Date: Sun, 2 Sep 2018 12:47:34 +0000 Subject: [PATCH 4/7] Done --- q04_count/build.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/q04_count/build.py b/q04_count/build.py index 6cf3dcbc..98d3c4d2 100644 --- a/q04_count/build.py +++ b/q04_count/build.py @@ -1,11 +1,20 @@ +# %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): +def deliveries_count(deliveries_count=data): # Your code here - + count=0; + data1=data['innings'][0]['1st innings']['deliveries']; + for x in data1: + for y in x: + if (x[y]['batsman'] == 'RT Ponting'): + count=count+1; + print (count) + return count; + + - return count From 4a68d61d706a7a7375184b0fe48fb152cbeed792 Mon Sep 17 00:00:00 2001 From: rameshpedagani Date: Sun, 2 Sep 2018 13:04:05 +0000 Subject: [PATCH 5/7] Done --- q05_runs/build.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/q05_runs/build.py b/q05_runs/build.py index a250631a..439492a2 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() - # Your Solution def BC_runs(data): # Write your code here + runs=0; + data1=data['innings'][0]['1st innings']['deliveries']; + for x in data1: + for y in x: + if (x[y]['batsman'] == 'BB McCullum'): + runs=runs+int(x[y]['runs']['batsman']); + + return(runs) + - return(runs) From 7ad7c6f7168821a703931c6c2329540d64d2e155 Mon Sep 17 00:00:00 2001 From: rameshpedagani Date: Sun, 9 Sep 2018 14:24:18 +0000 Subject: [PATCH 6/7] Done --- q06_bowled_players/build.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/q06_bowled_players/build.py b/q06_bowled_players/build.py index 914cb6d2..46dd8808 100644 --- a/q06_bowled_players/build.py +++ b/q06_bowled_players/build.py @@ -1,11 +1,25 @@ +# %load q04_count/build.py # Default Imports from greyatomlib.python_getting_started.q01_read_data.build import read_data data = read_data() -# Your Solution +# Your Solution Here def bowled_out(data=data): + l=(data['innings'][1]['2nd innings']['deliveries']) + c=[] + for x in l: + for y in x: + if 'wicket' in x[y].keys(): + if 'bowled' in x[y]['wicket']['kind']: + #print(x[y]['wicket']['player_out']) + c.append(x[y]['wicket']['player_out']) + - # Write your code here + # Write your code here + bowled_players=c return bowled_players +print (bowled_out(data)) + + From 47d143f8e9a90fc94674131e5e89a67c1d0b8904 Mon Sep 17 00:00:00 2001 From: rameshpedagani Date: Sun, 9 Sep 2018 14:32:33 +0000 Subject: [PATCH 7/7] Done --- q07_extras/build.py | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/q07_extras/build.py b/q07_extras/build.py index cdeb803b..77392375 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,45 @@ def extras_runs(data=data): # Write your code here + + l=(data['innings'][0]['1st innings']['deliveries']) + e1=[0,0,0] + c1=0 + for x in l: + for y in x: + if 'extras' in x[y].keys(): + c1+=1 + if 'wides' in x[y]['extras'].keys(): + e1[0]+=1 + elif 'legbyes' in x[y]['extras'].keys(): + e1[1]+=1 + else: + e1[2]+=1 + + + l2=(data['innings'][1]['2nd innings']['deliveries']) + e2=[0,0,0] + c2=0 + for x in l2: + for y in x: + if 'extras' in x[y].keys(): + c2+=1 + if 'wides' in x[y]['extras'].keys(): + e2[0]+=1 - difference = + elif 'legbyes' in x[y]['extras'].keys(): + e2[1]+=1 + else: + e2[2]+=1 + + + + difference =c2-c1 return difference +print (extras_runs(data)) + + +