add minus function

This commit is contained in:
BuravovA 2025-11-07 18:18:27 +04:00
parent 36990717e8
commit bbb5379428

26
calc.py
View File

@ -1,25 +1,25 @@
def main():
print("Welcome to the Calculator")
command = input("Select command: + or *\nType exit if u want exit \n")
command = input("Select command: [ + ] [ - ] [ * ] [ / ] \nType exit if u want exit \n")
match command:
case "+":
summ()
main()
case "*":
multiplication()
main()
case "minus":
minus()
case "exit":
exit
case _:
print(KeyError("Incorrect"))
main()
def summ():
print("Enter number to sum, enter space to finish")
print("Enter number(s) to sum, enter space to calculate")
total = 0
while True:
num_input = input()
if num_input == " ":
print (total)
print (f"Total summ = {total}")
main()
try:
number = float(num_input)
@ -27,8 +27,22 @@ def summ():
print(f"Total summ = {total}")
except ValueError:
print("Error, enter correct number")
def minus():
print("Enter number(s) to minus, enter spase to calculate")
total = 0
while True:
num_input = input()
if num_input == " ":
print(total)
main()
try:
number = float(num_input)
total -= number
print(f"Total minus = {total}")
except ValueError:
print("Error, enter correct number")
def multiplication():
print("Enter number to multiplication, enter space to finish")
print("Enter number to multiplication, enter space to calculate")
total = 0
while True:
num_input = input()