Skip to content

Instantly share code, notes, and snippets.

@ssov
Created March 21, 2012 04:23
Show Gist options
  • Save ssov/2144315 to your computer and use it in GitHub Desktop.
Save ssov/2144315 to your computer and use it in GitHub Desktop.
A率
#!/usr/bin/env python
# coding: utf-8
def main():
f = open("campus", "r")
all_credit=0
a_credit=0
for i in f.readlines():
k = i.replace("\n", "").split(",")
if len(k) != 1 and k[6].isalpha() and k[6] != "D":
all_credit += float(k[5])
if(k[6] == "A"):
a_credit += float(k[5])
print "A率: %f" % (a_credit/all_credit * 100)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment