PL2023/TPC2/tpc2.py

25 lines
616 B
Python
Raw Normal View History

2023-02-21 17:06:27 +00:00
import sys
def main():
print("--------------------------")
print(" TPC2 Somador on/off ")
print("--------------------------")
is_on = False
sum = 0
for line in sys.stdin:
line = line.strip()
if is_on and line.isdigit():
sum += int(line)
elif line == "=":
print(f"Result -> {sum}")
elif line.lower() == "on":
is_on = True
elif line.lower() == "off":
is_on = False
elif line.lower() == "quit" or line.lower() == "q":
break
print("Bye!")
if __name__ == "__main__":
main()