# Calculator

**URL:** <https://community.thunkable.com/t/calculator/4100257>\
**Category:** Questions about Thunkable X\
**Created:** [August 19, 2025, 4:42pm UTC](https://community.thunkable.com/t/calculator/4100257 "2025-08-19T16:42:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ahmedmohamedgebril20](https://avatars.discourse-cdn.com/v4/letter/a/7feea3/32.png) [@ahmedmohamedgebril20](https://community.thunkable.com/u/ahmedmohamedgebril20)\
**Post date:** [August 19, 2025, 4:42pm UTC](https://community.thunkable.com/t/calculator/4100257/1 "2025-08-19T16:42:24Z")

</div>

```auto
def calculate():
    """
    A simple calculator function that takes two numbers and an operation as input.
    """
    try:
        num1 = float(input("Enter the first number: "))
        operation = input("Enter the operation (+, -, *, /, **): ")
        num2 = float(input("Enter the second number: "))

        if operation == '+':
            result = num1 + num2
        elif operation == '-':
            result = num1 - num2
        elif operation == '*':
            result = num1 * num2
        elif operation == '/':
            if num2 == 0:
                return "Cannot divide by zero"
            result = num1 / num2
        elif operation == '**':
             result = num1 ** num2
        else:
            return "Invalid operation"

        return result

    except ValueError:
        return "Invalid input. Please enter numbers only."

# Example usage
print(calculate())

```

---

<div class="post-metadata">

**Author:** ![matt\_conroy](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/matt_conroy/32/150843_2.png) [@matt\_conroy](https://community.thunkable.com/u/matt_conroy)\
**Post date:** [August 19, 2025, 7:35pm UTC](https://community.thunkable.com/t/calculator/4100257/2 "2025-08-19T19:35:18Z")

</div>

Hi ahmedmohamedgebril20, welcome to Thunkable! 🎉

Be sure to check out [How to ask Great Questions v2.0](https://community.thunkable.com/t/how-to-ask-great-questions-v2-0/2689983/1), the [Community Guidelines](https://community.thunkable.com/t/community-guidelines/78/8), and our [Getting Started Guide](https://docs.thunkable.com/getting-started/get-started) to make the best of your Thunkable Community experience!

Could you share a bit more about what you’re trying to do? Since Thunkable is a no-code platform for building mobile apps, you don’t need to post large chunks of code—we’ll be better able to help if you describe your goal or the problem you’re running into.

You might also find it helpful to search the Community for “Calculator apps” to see if others have already solved something similar.

[https://community.thunkable.com/search?q=calculator%20app](https://community.thunkable.com/search?q=calculator%20app)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/f/0f59f292712368bce16ff80133ae10de8a6f27e8.png) [@system](https://community.thunkable.com/u/system)\
**Post date:** [November 17, 2025, 7:35pm UTC](https://community.thunkable.com/t/calculator/4100257/3 "2025-11-17T19:35:24Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
