Hey everyone! I'm 15 years old and just started learning Python. For my first real project, I created a calculator, and I'd love to get your feedback on it. Here's a snippet of my code:
```python
num1=int(input("Choose a number: "))
num2=int(input("Choose another number: "))
operator=int(input("Choose an operator (1=+, 2=-, 3=/): "))
if operator == 1:
result = num1 + num2
elif operator == 2:
result = num1 - num2
elif operator == 3:
result = num1 / num2
print("Here is your result:", result)
```
I'm looking for any advice on my code and also general tips for Python. If you have small projects to share, I'd be interested in those too. Thanks for reading!
6 Answers
Congrats on completing your first project! One suggestion is to format your code using markdown next time so it's easier to read. Here are some questions to think about:
- What happens if a user enters a letter instead of a number?
- How will your program handle unexpected operators?
- What if someone tries to divide by zero?
- What's the largest or smallest number your calculator can compute?
Great job! Maybe consider adding multiplication to your calculator options. It could really enhance its functionality.
Well done! Just a quick question—could you use `float` instead of `int` to allow users to enter decimal numbers? That might make your calculator more versatile!
Nice work on your calculator! Check out Python's `eval` function; it can simplify your code and allow for more flexibility in calculations.
Have you thought about creating a hangman game? It's fun and definitely achievable for your level!
Awesome! Here’s some advice: programming is really about problem-solving. Focus on troubleshooting your code and understanding the errors you encounter. Good luck!

You might want to consider parsing user input to allow full expressions like '1+2', and then splitting it into parts. This will help you understand types better. Plus, if you're using an IDE, try enabling flake8 hints to improve readability and clean up your code.