-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.git.py
More file actions
32 lines (26 loc) · 993 Bytes
/
Copy pathtest.git.py
File metadata and controls
32 lines (26 loc) · 993 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
def calculator():
print("Добре дошъл в Калкулаторaaaaaaaaaа!")
print("Операции: + - * /")
try:
num1 = float(input("Въведи първо число: "))
operation = input("Избери операция (+, -, *, /): ")
num2 = float(input("Въведи второ число: "))
if operation == '+':
result = num1 + num2
elif operation == '-':
result = num1 - num2
elif operation == '*':
result = num1 * num2
elif operation == '/':
if num2 != 0:
result = num1 / num2
else:
print("Грешка: Деление на нула!")
return
else:
print("Невалидна операция.")
return
print(f"Резултат: {result}")
except ValueError:
print("Моля, въведи валидни числа!")
calculator()