diff --git a/q01_read_data/build.py b/q01_read_data/build.py index e13d2f74..696523eb 100644 --- a/q01_read_data/build.py +++ b/q01_read_data/build.py @@ -1,12 +1,19 @@ +# %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 + +read_data() +Nil=read_data() +Nil + + diff --git a/q02_teams/build.py b/q02_teams/build.py index 3cf9d3cf..bfe399d5 100644 --- a/q02_teams/build.py +++ b/q02_teams/build.py @@ -1,11 +1,21 @@ +# %load q02_teams/build.py # default imports from greyatomlib.python_getting_started.q01_read_data.build import read_data data = read_data() +def teams(data): + Nilesh=data['info']['teams'] + return Nilesh +teams(data) -# solution -def teams(data=data): - # write your code here - #teams = +type(data) +data.keys() +data['info'] +d=data['info'] +type(d) +d.keys() +d['teams'] +Nilesh=data['info']['teams'] +Nilesh + - return teams diff --git a/q03_first_batsman/build.py b/q03_first_batsman/build.py index 84984081..6a9ac1f7 100644 --- a/q03_first_batsman/build.py +++ b/q03_first_batsman/build.py @@ -1,13 +1,35 @@ +# %load q03_first_batsman/build.py # Default Imports from greyatomlib.python_getting_started.q01_read_data.build import read_data data = read_data() # Your Solution -def first_batsman(data=data): +def first_batsman(data): # Write your code here + batsman=data['innings'][0]['1st innings']['deliveries'][0][0.1]['batsman'] + + + return batsman + + + + + + + + + + + + + + + + + + - return name diff --git a/q04_count/build.py b/q04_count/build.py index 6cf3dcbc..6c036697 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,29 @@ def deliveries_count(data=data): # Your code here + count = 0 + deliveries = data['innings'][0]['1st innings']['deliveries'] + for delivery in deliveries: + for delivery_number, delivery_info in delivery.items(): + if delivery_info['batsman'] == 'RT Ponting': + count += 1 return count + +type (data) +data.keys() +(data ['innings']) +type (data ['innings']) +len (data ['innings']) +data ['innings'][0] +type(data ['innings'][0]) +data['innings'][0].keys() +type(data['innings'][0]['1st innings']) + +(data['innings'][0]['1st innings']).keys() +data['innings'][0]['1st innings']['deliveries'] +type(data['innings'][0]['1st innings']['deliveries']) +len(data['innings'][0]['1st innings']['deliveries']) + +