tpc2 done

This commit is contained in:
Tiago Sousa 2023-02-21 17:06:27 +00:00
parent d7f38904f4
commit 79fc8f3bfd

24
TPC2/tpc2.py Normal file
View file

@ -0,0 +1,24 @@
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()