Last active
December 19, 2015 21:19
-
-
Save cocuh/6019133 to your computer and use it in GitHub Desktop.
筑波大学の成績管理システムtwinsから成績のcsvをダウンロードして引数に渡すとGPAが算出されるPythonワンライナーだよ☆
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| globals().__setitem__('c',lambda n,f:globals().__setitem__(n,f));c('t',float);c('s',__import__('sys'))or c('f',lambda l,A=0,B=0:f(l[1:],A+l[0][0],B+l[0][1])if l else(A,B));c('p',lambda x:s.stdout.write(x+'\n'));p((lambda x,y:"your GPA is {f}".format(f=y/x))(*f([(lambda x,y:(0,0)if y in['P','F']else(t(x),t(x)*dict([(x,n)for n,x in enumerate(['D','C','B','A','A+'])])[y]))(*[y[1:-1] for n,y in enumerate(x.split(","))if n in[5,6]])for x in open(s.argv[1]).read().splitlines()[1:]])))if len(s.argv[1:])else p("USAGE: gpa.py csvfile") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment