Explain
What is sentinel in python.
Calculating a Running Total
What is sentinel in python.
sentinel is value which we use to stop the loop
like reading numbers from the user untill he enteres -1
so here -1 is sentinel
Running total is reading values from user and adding to sum
Exampl:
n=int(input("Enter number (-1 to exit): "))
total = n
print("Total: ",total)
while(n!=-1):
n=int(input("Enter number (-1 to exit): "))
total+=n
print("Total: ",total)
NOTE : PLEASE COMMENT BELOW IF YOU HAVE CONCERNS.
I AM HERE TO HELP YOUIF YOU LIKE MY ANSWER PLEASE RATE AND HELP ME IT IS VERY IMP FOR ME
Get Answers For Free
Most questions answered within 1 hours.