User Tools

Site Tools


user:amalgamated_marks

Amalgamated Marks

Python Program

<Code:Python> t = [0 for _ in range(50)]

  1. array of marks goes here

a = [ “1:6”, “2:2”, 5, 5, 5, -5, -15, 10 ]

for m in a:

  if ':' in str(m):
      m, p = m.split(':', 1)
      t[int(m)] += int(p)
  else:
      if m > 0:
          t[m] = += 1
      else:
          t[abs(m)] -= 1

for x in range(50):

  print (str(x) + ", " + str(t[x]))

</Code>

user/amalgamated_marks.txt · Last modified: (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki