tpc2 done
This commit is contained in:
parent
d7f38904f4
commit
79fc8f3bfd
1 changed files with 24 additions and 0 deletions
24
TPC2/tpc2.py
Normal file
24
TPC2/tpc2.py
Normal 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()
|
Loading…
Reference in a new issue