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
11 changes: 6 additions & 5 deletions q01_read_data/build.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from __future__ import print_function, division, unicode_literals
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

data =

with open('./data/ipl_match.yaml', 'r') as yaml_data:
data = yaml.safe_load(yaml_data)
# return data variable
return data
return data

print(read_data())
10 changes: 6 additions & 4 deletions q02_teams/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
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 =
def teams(data=data):
teams = []
for team in data['info'] ['teams']:
teams.append(team)

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

# Write your code here




return name
def first_batsman(data = data):
innings = data['innings'][0]
first_innings = innings['1st innings']
deliveries = first_innings['deliveries']
first_ball =(deliveries[0] [0.1])
first_batsman = first_ball['batsman']
return(first_batsman)
print(first_batsman(data))
14 changes: 10 additions & 4 deletions q04_count/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@

# Your Solution Here
def deliveries_count(data=data):

# Your code here

innings = data['innings'][0]
first_innings = innings['1st innings']
deliveries = first_innings['deliveries']
deliveries_count = 0
for k in deliveries:
for key, value in k.iteritems():
if value['batsman'] == 'RT Ponting':
deliveries_count +=1
return(deliveries_count)

return count
print(deliveries_count(data))
13 changes: 9 additions & 4 deletions q05_runs/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@

# Your Solution
def BC_runs(data):

# Write your code here


runs = 0
innings = data['innings'][0]
first_innings = innings['1st innings']
deliveries = first_innings['deliveries']
for k in deliveries:
for key, value in k.iteritems():
if value['batsman'] == 'BB McCullum':
runs = runs + value['runs']['batsman']
return(runs)
print(BC_runs(data))
16 changes: 12 additions & 4 deletions q06_bowled_players/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,16 @@

# Your Solution
def bowled_out(data=data):

# Write your code here


bowled_players = []
innings = data ['innings'][1]
second_innings = innings['2nd innings']
deliveries = second_innings['deliveries']
counter = 0
for k in deliveries:
for key, value in k.iteritems():
if 'wicket' in value:
if value['wicket']['kind'] == 'bowled':
bowled_players.insert(counter, value['wicket']['player_out'])
counter += 1
return bowled_players
print (bowled_out(data))