I am trying to make this program that asks a user for their grades and displays their grades with 2 decimals. - ex. if they got a 10/15 on their Assignment it would show Assignment 1: 66.66%
In my code, it seems I am having trouble converting the numbers calculated to two decimals.
print("Please enter your grade on the following pieces of work:")
a1 = int(input("Assignment 1 (/15):"))
a2 = int(input("Assignment 2 (/20):"))
a3 = int(input("Assignment 3 (/25):"))
a4 = int(input("Assignment 4 (/20):"))
a5 = int(input("Assignment 5 (/30):"))
t = int(input("Tutorials (/10):"))
m = int(input("Midterm (/30):"))
fe = int(input("Final Exam (/50):"))
print("Here are your grades: ")
print(f"Assignment 1:{a1/15*100}%")
print(f"Assignment 2:{a2/20*100}%")
print(f"Assignment 3:{a3/25*100}%")
print(f"Assignment 4:{a4/20*100}%")
print(f"Assignment 5:{a5/30*100}%")
print(f"Tutorials: {t/10*100}%")
print(f"Midterm: {m/30*100}%")
print(f"Final Exam: {fe/50*100}%")
These answers give the whole decimal answer, for example instead of showing 66.66% it would show 66.666667%. How would I make this into 66.66%? Thanks in advance.
Edit: Also how would I take these answers and create the average percentage?
{a1/15*100:.2f}should do the trick for the first one. so basically add:.2fto get to decimals