Looking for Feedback on My First Python Project: A Simple Calculator

0
7
Asked By CuriousCoder57 On

Hey everyone! I'm 15 years old and I've just started learning Python. For my first real project, I created a simple calculator program. Here's the code I wrote:

```python
num1 = int(input("Choose a number: "))
num2 = int(input("Choose another number: ")) # selecting the numbers
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 here to get some advice on this program and also looking to learn more about Python in general. If anyone has similar projects, I'd love to hear about those too! Thanks for taking the time to read this.

5 Answers

Answered By CodeCrafter88 On

Nice work! If you're up for a challenge, why not try adding multiplication to your calculator? It could be a fun addition!

Answered By PythonPro10 On

Great start! You should check out Python's `eval` function; it might be a neat way to simplify your calculator logic and handle expressions more dynamically.

Answered By FutureDev99 On

This is awesome! Remember, programming is all about solving problems. Focus on improving your code and fixing any bugs you find. You'll learn a lot that way! Keep it up!

Answered By LearningNinja00 On

Cool project! Also, have you considered using floats instead of integers? That way, users can input decimal numbers, which is super useful for calculations!

Answered By HelpfulHacker21 On

Congrats on your first project! Just a tip, consider formatting your code using markdown next time; it makes it a lot easier for others to read. Have you thought about what happens if the user inputs a letter instead of a number? Or what if they choose an operation that's not listed? And don’t forget to check for division by zero! Also, what's the largest and smallest number your calculator can handle?

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.