То что успели на паре
This commit is contained in:
parent
b93d33e01c
commit
36990717e8
47
calc.py
47
calc.py
@ -1,2 +1,45 @@
|
|||||||
print("world says hallo")
|
def main():
|
||||||
print("hello to worlds")
|
print("Welcome to the Calculator")
|
||||||
|
command = input("Select command: + or *\nType exit if u want exit \n")
|
||||||
|
match command:
|
||||||
|
case "+":
|
||||||
|
summ()
|
||||||
|
main()
|
||||||
|
case "*":
|
||||||
|
multiplication()
|
||||||
|
main()
|
||||||
|
case "exit":
|
||||||
|
exit
|
||||||
|
case _:
|
||||||
|
print(KeyError("Incorrect"))
|
||||||
|
main()
|
||||||
|
def summ():
|
||||||
|
print("Enter number to sum, enter space to finish")
|
||||||
|
total = 0
|
||||||
|
while True:
|
||||||
|
num_input = input()
|
||||||
|
if num_input == " ":
|
||||||
|
print (total)
|
||||||
|
main()
|
||||||
|
try:
|
||||||
|
number = float(num_input)
|
||||||
|
total += number
|
||||||
|
print(f"Total summ = {total}")
|
||||||
|
except ValueError:
|
||||||
|
print("Error, enter correct number")
|
||||||
|
def multiplication():
|
||||||
|
print("Enter number to multiplication, enter space to finish")
|
||||||
|
total = 0
|
||||||
|
while True:
|
||||||
|
num_input = input()
|
||||||
|
if num_input == " ":
|
||||||
|
print (total)
|
||||||
|
main()
|
||||||
|
try:
|
||||||
|
number = float(num_input)
|
||||||
|
total *= number
|
||||||
|
print(f"Total multiplication = {total}")
|
||||||
|
except ValueError:
|
||||||
|
print("Error, enter correct number")
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user