The number of goals achieved by two
football teams in matches in a league is
given in the form of two lists. For each match
of team B, compute the total number of
matches of team A where team A has scored
less than or equal to the number of goals
scored by team B in that match.
Example
teamA = [1, 2, 3]
teamB = [2, 4]



Answer :

Using the knowledge in computational language in python it is possible to write a code that number of goals achieved by two football teams in matches in a league is given in the form of two lists.

Writting the code:

# The Basic idea is to compare a value of array b(team_b array) to each element of array a if the element of a is less than are equal to the element of array b then we increment the c and store the final count of c for a particular element for B will be stored in a list.

#The process will repeat for every element of array b

def count(n,a,m,b):

   l=[]

   for i in b:# here i represents the element of array b

       c=0

       for j in a: # here j represents the element of a

           if(j<=i):

               c+=1

       l.append(c)

   return l

#length of array a

n=int(input())

#using list comprehension to take one line list as input

#taking list as input team_a and team_b , map is used  when you want to apply a single transformation function to all the iterable elements. Here we are taking space separated integers and storing them as list

team_a=list(map(int,input().strip().split()))[:n]

#length of array b

m=int(input())

team_b=list(map(int,input().split()))[:m]

#printing the return value of  count function.

print(count(n,team_a,m,team_b))

See more about python at brainly.com/question/13437928

#SPJ1

View image lhmarianateixeira

Other Questions