Skip to content

Instantly share code, notes, and snippets.

@slizzered
Last active August 29, 2015 14:22
Show Gist options
  • Save slizzered/6dd747423995a726c6b3 to your computer and use it in GitHub Desktop.
Save slizzered/6dd747423995a726c6b3 to your computer and use it in GitHub Desktop.
calculate your grade for the degree "Diplom-Informatik (Studienordnung 2004)" at "Technische Universität Dresden"
#!/usr/bin/python3
# The MIT License (MIT)
#
# Copyright (c) 2015 Carlchristian Eckert [email protected]
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# Use this script to calculate your grade for the degree
# "Diplom-Informatik (Studienordnung 2004)" at "Technische Universität Dresden"
# Put grades here
Teilfach1a = 1.0
Teilfach1b = 1.0
Teilfach2a = 1.0
Teilfach2b = 1.0
Vertiefung = 1.0
Nebenfach = 1.0
Diplom = 1.0
# round decimal digit to values .0 .3 or .7
# 2.13 -> 2.0
# 2.20 -> 2.3
# 2.55 -> 2.7
# 2.90 -> 3.0
def grade_rounding(grade):
integer = grade // 1
fractional = grade % 1
if (fractional <= .15): return integer
elif(fractional <= .50): return integer + .3
elif(fractional <= .85): return integer + .7
else: return integer + 1
Fach1 = grade_rounding( (Teilfach1a + Teilfach1b) / 2 )
Fach2 = grade_rounding( (Teilfach2a + Teilfach2b) / 2 )
Vertiefung = grade_rounding( Vertiefung )
Nebenfach = grade_rounding( Nebenfach )
Fachnote = grade_rounding( (Fach1 + Fach2 + Vertiefung + Nebenfach) / 4 )
Gesamtnote = grade_rounding( (Fachnote + 2*Diplom) / 3 )
print("Fachgebiet I ", Fach1)
print("Fachgebiet II ", Fach2)
print("Vertiefung ", Vertiefung)
print("Nebenfach ", Nebenfach)
print("------------------")
print("Fachnote ", Fachnote)
print("Diplomarbeit ", Diplom)
print("==================")
print("Gesamtnote ", Gesamtnote)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment