Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions q01_read_data/build.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
import yaml

# from greyatomlib.python_getting_started.q01_read_data.build import read_data
# data = read_data()
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', 'r'))
# return data variable
return data
# return data[0]






7 changes: 6 additions & 1 deletion q02_teams/build.py
Original file line number Diff line number Diff line change
@@ -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()
Expand All @@ -6,6 +7,10 @@
def teams(data=data):

# write your code here
#teams =
teams = list(data['info']['teams'])

return teams




9 changes: 7 additions & 2 deletions q03_first_batsman/build.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
# %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):

# name = data['innings'][0]['1st innings']['deliveries'][0]['0.1']['batsman'])
name = data['innings'][0]['1st innings']['deliveries'][0][0.1]['batsman']
return name



# Write your code here




return name
15 changes: 11 additions & 4 deletions q04_count/build.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
# %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):

# Your code here


count = 0
my_list = data['innings'][0]['1st innings']['deliveries']
for x in my_list:
for y in x.values():
if y['batsman'] == 'RT Ponting':
count+=1
return count




11 changes: 9 additions & 2 deletions q05_runs/build.py
Original file line number Diff line number Diff line change
@@ -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):
runs = 0
my_list = data['innings'][0]['1st innings']['deliveries']
# print(my_list)
for x in my_list:
for y in x.values():
if y['batsman'] == 'BB McCullum':
runs = runs+y['runs']['batsman']
return(runs)

# Write your code here


return(runs)
14 changes: 12 additions & 2 deletions q06_bowled_players/build.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
# %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):
bowled_players = []
my_list = data['innings'][1]['2nd innings']['deliveries']
for x in my_list:
for key in x:
var1 = x[key]
for key2 in var1:
if key2 == 'wicket':
key3 = var1[key2]
if key3['kind'] == 'bowled':
bowled_players.append(key3['player_out'])
return bowled_players

# Write your code here


return bowled_players
29 changes: 24 additions & 5 deletions q07_extras/build.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,33 @@
# %load q07_extras/build.py
# Default Imports
from greyatomlib.python_getting_started.q01_read_data.build import read_data
data = read_data()

# Your Solution
def extras_runs(data=data):
list1extras=0
list2extras=0
list1= data['innings'][0]['1st innings']['deliveries']
list2= data['innings'][1]['2nd innings']['deliveries']
for a in list1:
for b in a:
var1=a[b]
for c in var1:
if c == 'extras':
var2 = var1[c]
for d in var2:
list1extras = list1extras + 1
for e in list2:
for f in e:
var3=e[f]
# print(var1)
for g in var3:
if g == 'extras':
var4 = var3[g]
for h in var4:
list2extras= list2extras + 1
difference = list2extras - list1extras
return difference

# Write your code here


difference =


return difference