Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions ماشین حساب
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
def calculator():
print("ماشین حساب ساده")
num1 = float(input("عدد اول را وارد کنید: "))
operator = input("عملگر (+, -, *, /) را وارد کنید: ")
num2 = float(input("عدد دوم را وارد کنید: "))

if operator == '+':
result = num1 + num2
elif operator == '-':
result = num1 - num2
elif operator == '*':
result = num1 * num2
elif operator == '/':
if num2 != 0:
result = num1 / num2
else:
return "خطا: تقسیم بر صفر"
else:
return "عملگر نامعتبر"

return f"نتیجه: {result}"

print(calculator())