Skip to content

Commit Live PR #278

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 7 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
17 changes: 11 additions & 6 deletions q01_read_data/build.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import yaml

def read_data():

data1= open('./data/ipl_match.yaml','r')
data=yaml.load(data1)




return 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 =

# return data variable
return data
39 changes: 31 additions & 8 deletions q02_teams/build.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,34 @@
# default imports
from greyatomlib.python_getting_started.q01_read_data.build import read_data
data = read_data()
#%load q02_teams/build.py

import yaml

def teams(data):
data1=open('./data/ipl_match.yaml','r')
data=yaml.load(data1)

teams1=data['info']['teams']

return teams1





















# solution
def teams(data=data):

# write your code here
#teams =

return teams
21 changes: 14 additions & 7 deletions q03_first_batsman/build.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
# Default Imports
from greyatomlib.python_getting_started.q01_read_data.build import read_data
data = read_data()
#%load q03_first_batsman/build.py

import yaml

def first_batsman(d):
data=open('./data/ipl_match.yaml','r')
data1=yaml.load(data)
data2=data1['innings'][0]['1st innings']['deliveries'][0][0.1]['batsman']
#data3=data2['1st innings']['deliveries'][0][0.1]['batsman']
#print(data3)
return data2




# Your Solution
def first_batsman(data=data):

# Write your code here




return name
43 changes: 37 additions & 6 deletions q04_count/build.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,42 @@
# Default Imports
from greyatomlib.python_getting_started.q01_read_data.build import read_data
data = read_data()
#%load q04_count/build.py

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

def deliveries_count(data):

# Your code here
import yaml

data=open('./data/ipl_match.yaml','r')
data1=yaml.load(data)
d=data1['innings'][0]['1st innings']['deliveries']

#d1=d
count=0

for key,value in enumerate(d):
value1=d[key]
#print(value)
#print(key,value,type(value))
for k,v in value1.items():


#print(v)
if value1[k]['batsman']=='RT Ponting':

count += 1

return count


#deliveries_count(d1)












29 changes: 23 additions & 6 deletions q05_runs/build.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
# %load q05_runs/build.py
# Default Imports
from greyatomlib.python_getting_started.q01_read_data.build import read_data
data = read_data()


#om greyatomlib.python_getting_started.q01_read_data.build import read_data
#ata = read_data()
#rint(data)
# Your Solution
def BC_runs(data):
#def BC_runs(data):

# Write your code here


return(runs)
#return(runs)
import yaml
def BC_runs(data):

data=open('./data/ipl_match.yaml','r')
data1=yaml.load(data)
data2=data1['innings'][0]['1st innings']['deliveries']
runs=0
for key,value in enumerate(data2):
for k,v in value.items():
if v['batsman']=='BB McCullum':
runs+=(v['runs']['batsman'])



return runs


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

# Your Solution
def bowled_out(data=data):
import yaml

def bowled_out(data):
data=open('./data/ipl_match.yaml','r')
data1=yaml.load(data)
data2=data1['innings'][1]['2nd innings']['deliveries']
bowled_players=[]
for key,value in enumerate(data2):
for k,v in value.items():
if 'wicket' in v.keys():
if (v['wicket']['kind'])=='bowled':
bowled_players.append(v['wicket']['player_out'])
#print(bowled_players)
#


return (bowled_players)
#print(v.keys())
#if v.keys() =='wicket':#['wicket']['kind']=='bowled':
#print(v)

#print(v)

#print(type(value))
#print(data2)

# Write your code here


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

# Your Solution
def extras_runs(data=data):
import yaml

# Write your code here
def extras_runs(data):

data=open('./data/ipl_match.yaml','r')
data1=yaml.load(data)
data_2nd=data1['innings'][1]['2nd innings']['deliveries']

data_1st=data1['innings'][0]['1st innings']['deliveries']
count1=[]
count2=[]
for key,value in enumerate(data_2nd):

for k,v in value.items():

if v['runs']['extras']>0:

count2.append(v['runs']['extras'])




difference =

for key1,value1 in enumerate(data_1st):

for k1,v1 in value1.items():
if v1['runs']['extras']>0:
count1.append(v1['runs']['extras'])

#print(len(count1))
difference=(len(count2)-len(count1))

return difference