Simple Calculator Using While Loop in Python

  • Post author:
  • Post category:Python
  • Reading time:1 mins read

Here is an example of a simple calculator program using the while loop in Python.

Example: Python Calculator Using While Loop

sum1 = 0
while True:
    x = input()
    if x == 'stop':
        print(sum1)
        break
    else:
        sum1 += int(x)

print("Finished")

Output:

87
9
76
stop
172
Finished

See also:

Vinish Kapoor

An Oracle Apex Consultant, Oracle ACE, and founder of foxinfotech.in and orclqa.com a question and answer forum for developers.