From dd6e9ae0f4029ea3b0514c8d181013a82f5d2ffa Mon Sep 17 00:00:00 2001 From: mario-the-legend Date: Sun, 9 Sep 2018 07:39:31 +0000 Subject: [PATCH 1/7] Done --- q01_read_data/build.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/q01_read_data/build.py b/q01_read_data/build.py index e13d2f74..20a5b6e8 100644 --- a/q01_read_data/build.py +++ b/q01_read_data/build.py @@ -1,12 +1,15 @@ +# %load q01_read_data/build.py import yaml def read_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 + with open('./data/ipl_match.yaml') as f: + data = yaml.load(f) + return data + +ocl=read_data() +type(ocl) + +print(ocl) - data = - # return data variable - return data From 3b61452474580670229002605988546d22120d44 Mon Sep 17 00:00:00 2001 From: mario-the-legend Date: Mon, 10 Sep 2018 15:54:51 +0000 Subject: [PATCH 2/7] Done --- q02_teams/build.py | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/q02_teams/build.py b/q02_teams/build.py index 3cf9d3cf..b26c21b3 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,37 @@ def teams(data=data): # write your code here - #teams = + teams = data['info']['teams'] + print(type(teams)) + return teams + +from greyatomlib.python_getting_started.q01_read_data.build import read_data +data = read_data() + +teams = data['info']['teams'] +type(teams) +type(data) +teams[1] +teams +for i in teams: + print(i) +len(teams) +teams.append('Crack Commandoes') +for k in teams: + print(k) +teams.insert(2,'Baja') +for j in teams: + print(j) +teams.pop() +teams +teams.reverse() +for i in teams: print(i) +del teams[0] +teams + +teams.reverse() +teams + + From 92d478be164da22957ace71630188d094e21de9e Mon Sep 17 00:00:00 2001 From: mario-the-legend Date: Tue, 11 Sep 2018 02:57:08 +0000 Subject: [PATCH 3/7] Done --- q03_first_batsman/build.py | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/q03_first_batsman/build.py b/q03_first_batsman/build.py index 84984081..001af0dd 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,37 @@ def first_batsman(data=data): # Write your code here + name = data['innings'][0]['1st innings']['deliveries'][0][0.1]['batsman'] + return name +from greyatomlib.python_getting_started.q01_read_data.build import read_data +data = read_data() +piq = first_batsman() +type(piq) +type(data) +for i in data: print(i) +for i in data.values(): crass = i +type(data['innings'][0]) +data['innings'][0]['1st innings']['deliveries'][0][0.1]['batsman'] +data['innings'][0]['1st innings']['deliveries'][0][0.1] +type(crass[0]) +indict = crass[0] +for i in indict.values(): + print(i) +type(indict) +for x,y in indict.items(): + #print(type(x)) + #print(type(y)) + indict2=y + #print('the key is :'+x+' while the value is '+str(y)) +type(indict) +type(indict2) +for i in indict2.values(): inlist2 = i +type(inlist2) +for i,j in indict2.items(): print('the key is '+i+' while the value is '+str(j)) +type(inlist2[0]) +type(inlist2[0][0.1]) +inlist2[0][0.1]['batsman'] - return name From 4e05964fb65ad852a7195bc5e9ad220a87a5a539 Mon Sep 17 00:00:00 2001 From: mario-the-legend Date: Tue, 11 Sep 2018 03:29:50 +0000 Subject: [PATCH 4/7] Done --- q04_count/build.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/q04_count/build.py b/q04_count/build.py index 6cf3dcbc..916b9a0a 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,24 @@ def deliveries_count(data=data): # Your code here + count=0 + x = data['innings'][0]['1st innings']['deliveries'] - + for i in x: + for k in i.values(): + print(k['batsman']) + if k['batsman'] == 'RT Ponting': + count = count + 1 + return count + +count=0 +x = data['innings'][0]['1st innings']['deliveries'] +for i in x: + for k in i.values(): + print(k['batsman']) + if k['batsman'] == 'RT Ponting': + count = count + 1 +print(count) + + From ff5d15f33dd5d326d0d0686c90646cf0dd057308 Mon Sep 17 00:00:00 2001 From: mario-the-legend Date: Fri, 14 Sep 2018 05:37:00 +0000 Subject: [PATCH 5/7] Done --- q05_runs/build.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/q05_runs/build.py b/q05_runs/build.py index a250631a..9762b87b 100644 --- a/q05_runs/build.py +++ b/q05_runs/build.py @@ -1,12 +1,19 @@ +# %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 + varfin=data['innings'][0]['1st innings']['deliveries'] + for y in varfin: + for v,w in y.items(): + if (w['batsman']) == 'BB McCullum': + runs=runs+(w['runs']['batsman']) + return(runs) + - return(runs) From 14d5c18be3760d2fde888f6738ec278553b80d0c Mon Sep 17 00:00:00 2001 From: mario-the-legend Date: Fri, 14 Sep 2018 09:44:13 +0000 Subject: [PATCH 6/7] Done --- q06_bowled_players/build.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/q06_bowled_players/build.py b/q06_bowled_players/build.py index 914cb6d2..584c860e 100644 --- a/q06_bowled_players/build.py +++ b/q06_bowled_players/build.py @@ -1,3 +1,4 @@ +# %load q06_bowled_players/build.py # Default Imports from greyatomlib.python_getting_started.q01_read_data.build import read_data data = read_data() @@ -7,5 +8,16 @@ def bowled_out(data=data): # Write your code here + bowled_players = [] + varfin2=data['innings'][1]['2nd innings']['deliveries'] + for indict in varfin2: + for j,k in indict.items(): + for l,m in k.items(): + if ((l == 'wicket') and (m['kind'] == 'bowled')): + bowled_players.append(str(k['batsman'])) return bowled_players + +bowled_out(data) + + From 7b029b61f324734cfc38fd7c8084535d3a925cc9 Mon Sep 17 00:00:00 2001 From: mario-the-legend Date: Fri, 14 Sep 2018 13:53:02 +0000 Subject: [PATCH 7/7] Done --- q07_extras/build.py | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/q07_extras/build.py b/q07_extras/build.py index cdeb803b..01281fd9 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() @@ -7,8 +8,33 @@ def extras_runs(data=data): # Write your code here + lst1=data['innings'][0]['1st innings']['deliveries'] + ext1 = [] + for inlst1 in lst1: + for x,y in inlst1.items(): + for m,n in y.items(): + if (m == 'runs'): + for r,s in n.items(): + if ((r == 'extras') and (s != 0)): + ext1.append(s) + break + + lst2=data['innings'][1]['2nd innings']['deliveries'] + ext2 = [] + for inlst2 in lst2: + for x,y in inlst2.items(): + for m,n in y.items(): + if (m == 'runs'): + for r,s in n.items(): + if ((r == 'extras') and (s != 0)): + ext2.append(s) + break + + difference = len(ext2)-len(ext1) - difference = + return difference + +extras_runs() +extras_runs() - return difference