First, you can simplify by removing one of the borders:
if m >= 80:
g = "A"
elif m >= 70:
g = "B"
elif m >= 60:
g = "C"
elif m >= 50:
g = "D"
else:
g = "U"
Secondly, you can capture the repetitive nature of the process with a loop (with a default case, representing an option for the for-else construct):
for grade, score in zip('ABCD', (80, 70, 60, 50)):
if m >= score:
g = grade
break
else:
g = 'U'
source
share