Skip to content

Commit Live PR #279

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
12 changes: 12 additions & 0 deletions ipl_match.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
a list:
- 1
- 42
- 3.141
- 1337
- help
- "â\x82¬"
a string: bla
another dict:
foo: bar
key: value
the answer: 42
13 changes: 5 additions & 8 deletions q01_read_data/build.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import yaml

def read_data():
import yaml
with open('ipl_match.yaml', 'r') as f:
doc = yaml.load(f)
return doc


# 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
7 changes: 5 additions & 2 deletions q02_teams/build.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
# %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):

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



return teams
4 changes: 3 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 @@ -7,7 +8,8 @@ def first_batsman(data=data):

# Write your code here

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

return name


return name
15 changes: 12 additions & 3 deletions q04_count/build.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
# %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):
def deliveries_count(deliveries_count=data):

# Your code here

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



return count
12 changes: 10 additions & 2 deletions q05_runs/build.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
# %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;
data1=data['innings'][0]['1st innings']['deliveries'];
for x in data1:
for y in x:
if (x[y]['batsman'] == 'BB McCullum'):
runs=runs+int(x[y]['runs']['batsman']);

return(runs)



return(runs)
18 changes: 16 additions & 2 deletions q06_bowled_players/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
# Your Solution Here
def bowled_out(data=data):
l=(data['innings'][1]['2nd innings']['deliveries'])
c=[]
for x in l:
for y in x:
if 'wicket' in x[y].keys():
if 'bowled' in x[y]['wicket']['kind']:
#print(x[y]['wicket']['player_out'])
c.append(x[y]['wicket']['player_out'])


# Write your code here

# Write your code here

bowled_players=c
return bowled_players
print (bowled_out(data))


39 changes: 38 additions & 1 deletion 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 @@ -6,9 +7,45 @@
def extras_runs(data=data):

# Write your code here

l=(data['innings'][0]['1st innings']['deliveries'])
e1=[0,0,0]
c1=0
for x in l:
for y in x:
if 'extras' in x[y].keys():
c1+=1
if 'wides' in x[y]['extras'].keys():
e1[0]+=1

elif 'legbyes' in x[y]['extras'].keys():
e1[1]+=1
else:
e1[2]+=1


l2=(data['innings'][1]['2nd innings']['deliveries'])
e2=[0,0,0]
c2=0
for x in l2:
for y in x:
if 'extras' in x[y].keys():
c2+=1
if 'wides' in x[y]['extras'].keys():
e2[0]+=1

difference =
elif 'legbyes' in x[y]['extras'].keys():
e2[1]+=1
else:
e2[2]+=1



difference =c2-c1


return difference
print (extras_runs(data))