For example, the algorithm in Python may look like this:
a = int(input("How old is your first friend? "))
b = int(input("How old is your second friend? "))
c = int(input("How old is your third friend? "))
d = int(input("How old is your fourth friend? "))
average = ((a+b+c+d)/4)
f = round(average, 2)
print("The average age of your friends is", f, "years")
Comments
Leave a comment