Skip to content

Commit Live PR #292

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
15 changes: 9 additions & 6 deletions q01_read_data/build.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
# %load q01_read_data/build.py
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
with open('./data/ipl_match.yaml') as f:
data = yaml.load(f)
return data

ocl=read_data()
type(ocl)

print(ocl)

data =

# return data variable
return data
34 changes: 33 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,37 @@
def teams(data=data):

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

print(type(teams))

return teams

from greyatomlib.python_getting_started.q01_read_data.build import read_data
data = read_data()

teams = data['info']['teams']
type(teams)
type(data)
teams[1]
teams
for i in teams:
print(i)
len(teams)
teams.append('Crack Commandoes')
for k in teams:
print(k)
teams.insert(2,'Baja')
for j in teams:
print(j)
teams.pop()
teams
teams.reverse()
for i in teams: print(i)
del teams[0]
teams

teams.reverse()
teams


32 changes: 31 additions & 1 deletion q03_first_batsman/build.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# %load q03_first_batsman/build.py
# Default Imports
from greyatomlib.python_getting_started.q01_read_data.build import read_data
data = read_data()
Expand All @@ -6,8 +7,37 @@
def first_batsman(data=data):

# Write your code here
name = data['innings'][0]['1st innings']['deliveries'][0][0.1]['batsman']
return name

from greyatomlib.python_getting_started.q01_read_data.build import read_data
data = read_data()

piq = first_batsman()
type(piq)
type(data)
for i in data: print(i)
for i in data.values(): crass = i
type(data['innings'][0])
data['innings'][0]['1st innings']['deliveries'][0][0.1]['batsman']
data['innings'][0]['1st innings']['deliveries'][0][0.1]
type(crass[0])
indict = crass[0]
for i in indict.values():
print(i)
type(indict)
for x,y in indict.items():
#print(type(x))
#print(type(y))
indict2=y
#print('the key is :'+x+' while the value is '+str(y))
type(indict)
type(indict2)
for i in indict2.values(): inlist2 = i
type(inlist2)
for i,j in indict2.items(): print('the key is '+i+' while the value is '+str(j))
type(inlist2[0])
type(inlist2[0][0.1])
inlist2[0][0.1]['batsman']


return name
21 changes: 20 additions & 1 deletion q04_count/build.py
Original file line number Diff line number Diff line change
@@ -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()
Expand All @@ -6,6 +7,24 @@
def deliveries_count(data=data):

# Your code here
count=0
x = data['innings'][0]['1st innings']['deliveries']


for i in x:
for k in i.values():
print(k['batsman'])
if k['batsman'] == 'RT Ponting':
count = count + 1

return count

count=0
x = data['innings'][0]['1st innings']['deliveries']
for i in x:
for k in i.values():
print(k['batsman'])
if k['batsman'] == 'RT Ponting':
count = count + 1
print(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):

# Write your code here
runs = 0
varfin=data['innings'][0]['1st innings']['deliveries']
for y in varfin:
for v,w in y.items():
if (w['batsman']) == 'BB McCullum':
runs=runs+(w['runs']['batsman'])
return(runs)



return(runs)
12 changes: 12 additions & 0 deletions q06_bowled_players/build.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# %load q06_bowled_players/build.py
# Default Imports
from greyatomlib.python_getting_started.q01_read_data.build import read_data
data = read_data()
Expand All @@ -7,5 +8,16 @@ def bowled_out(data=data):

# Write your code here

bowled_players = []
varfin2=data['innings'][1]['2nd innings']['deliveries']
for indict in varfin2:
for j,k in indict.items():
for l,m in k.items():
if ((l == 'wicket') and (m['kind'] == 'bowled')):
bowled_players.append(str(k['batsman']))

return bowled_players

bowled_out(data)


30 changes: 28 additions & 2 deletions q07_extras/build.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# %load q07_extras/build.py
# Default Imports
from greyatomlib.python_getting_started.q01_read_data.build import read_data
data = read_data()
Expand All @@ -7,8 +8,33 @@ def extras_runs(data=data):

# Write your code here

lst1=data['innings'][0]['1st innings']['deliveries']
ext1 = []
for inlst1 in lst1:
for x,y in inlst1.items():
for m,n in y.items():
if (m == 'runs'):
for r,s in n.items():
if ((r == 'extras') and (s != 0)):
ext1.append(s)
break

lst2=data['innings'][1]['2nd innings']['deliveries']
ext2 = []
for inlst2 in lst2:
for x,y in inlst2.items():
for m,n in y.items():
if (m == 'runs'):
for r,s in n.items():
if ((r == 'extras') and (s != 0)):
ext2.append(s)
break

difference = len(ext2)-len(ext1)

difference =
return difference

extras_runs()
extras_runs()


return difference