Skip to content

Commit Live PR #291

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
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: 12 additions & 3 deletions q01_read_data/build.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
# %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 =
path='./data/ipl_match.yaml'
iplfile=open(path,'r')

data =yaml.load(iplfile)


# return data variable
return data

read_data()



9 changes: 7 additions & 2 deletions q02_teams/build.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
# %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):
info=data.get('info')


# write your code here
#teams =
teams =info.get('teams')

return teams



14 changes: 14 additions & 0 deletions q03_first_batsman/build.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
# %load q03_first_batsman/build.py
# Default Imports
from greyatomlib.python_getting_started.q01_read_data.build import read_data
data = read_data()
#ing=data.get('innings')
#firsting=ing[0]
#print(firsting.get('1st innings').get('deliveries')[0].get(0.1).get('batsman'))


#print(ing)

# Your Solution
def first_batsman(data=data):
ing=data.get('innings')
firsting=ing[0]
name=firsting.get('1st innings').get('deliveries')[0].get(0.1).get('batsman')

# Write your code here




return name

first_batsman(data)


16 changes: 15 additions & 1 deletion q04_count/build.py
Original file line number Diff line number Diff line change
@@ -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 Here
def deliveries_count(data=data):

ing=data.get('innings')
firsting=ing[0]
fingdict=firsting.get('1st innings')
deliveries=fingdict.get('deliveries')
count=0
for ball in deliveries:
bat=list(ball.values())
if bat[0].get('batsman')=='RT Ponting':
count=count+1

# Your code here


return count

deliveries_count(data)


14 changes: 14 additions & 0 deletions q05_runs/build.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
# %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):
ing=data.get('innings')
firsting=ing[0]
fingdict=firsting.get('1st innings')
deliveries=fingdict.get('deliveries')
runs=0
for ball in deliveries:
bat=list(ball.values())
if bat[0].get('batsman')=='BB McCullum':
run=bat[0].get('runs').get('batsman')
runs=runs+run

# Write your code here


return(runs)

BC_runs(data)

19 changes: 19 additions & 0 deletions q06_bowled_players/build.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,30 @@
# %load q06_bowled_players/build.py
# Default Imports
from greyatomlib.python_getting_started.q01_read_data.build import read_data
data = read_data()

bowled_players=[]
# Your Solution
def bowled_out(data=data):
#bowled_players=[]
ing=data.get('innings')
firsting=ing[1]
fingdict=firsting.get('2nd innings')
deliveries=fingdict.get('deliveries')
for ball in deliveries:
bat=list(ball.values())
if ((bat[0].get('wicket'))!=None):
wicket=bat[0].get('wicket')
if(wicket.get('kind')=='bowled'):
player=wicket.get('player_out')
bowled_players.append(player)


# Write your code here


return bowled_players