Support our Blind Hand Charity by donating at 9818291723. Your contribution has the potential to bring about significant positive change for humanity.

Search This Blog

MY PROGRAMMES

Friday, April 14, 2023

AVERAGE ERROR FOR 5 OR 10 READINGS ONLY

print("How many readings will you enter 5 or 10?")
n=int(input("Enter the number of readings = "))
if n==5:
    r1=float(input("Enter the value of first reading = "))
    r2=float(input("Enter the value of second reading = "))
    r3=float(input("Enter the value of third reading = "))
    r4=float(input("Enter the value of fourth reading = "))
    r5=float(input("Enter the value of fifth reading = "))
    r=(r1+r2+r3+r4+r5)/5
    mar=(abs(r-r1)+abs(r-r2)+abs(r-r3)+abs(r-r4)+abs(r-r5))/5
    re=mar/r
    rpe=(mar/r)*100
    print("Average error =",r)
    print("Mean Absolute error =",mar)
    print("Relative error =",re)
    print("Percentage error =",rpe)
elif n==10:
    r1=float(input("Enter the value of first reading = "))
    r2=float(input("Enter the value of second reading = "))
    r3=float(input("Enter the value of third reading = "))
    r4=float(input("Enter the value of fourth reading = "))
    r5=float(input("Enter the value of fifth reading = "))
    r6=float(input("Enter the value of sixth reading = "))
    r7=float(input("Enter the value of seventh reading = "))
    r8=float(input("Enter the value of eighth reading = "))
    r9=float(input("Enter the value of ninth reading = "))
    r10=float(input("Enter the value of tenth reading = "))
    r=(r1+r2+r3+r4+r5+r6+r7+r8+r9+r10)/10
    mar=(abs(r-r1)+abs(r-r2)+abs(r-r3)+abs(r-r4)+abs(r-r5)+abs(r-r6)+abs(r-r7)+abs(r-r8)+abs(r-r9)+abs(r-r10))/10
    re=mar/r
    rpe=(mar/r)*100
    print("Average error =",r)
    print("Mean Absolute error =",mar)
    print("Relative error =",re)
    print("Percentage error =",rpe)
else:
    print("Kindly take 5 or 10 readings only.")