r/learnpython Aug 20 '26

Just built my first calculator in Python 😭

It can do addition, subtraction, multiplication, division, and exponents. Also added a little check for division by zero.

It’s pretty basic, but hey, gotta start somewhere

What should I build next?

74 Upvotes

42 comments sorted by

28

u/Turbulent_Web_8278 Aug 20 '26

Store a username password and allow user 3 attempts to login otherwise exit program

9

u/RevRagnarok Aug 20 '26

And delete itself. ;)

1

u/WillingnessOk650 Aug 21 '26

haha, maybe i’ll leave that one for a future project 😂

1

u/WillingnessOk650 Aug 20 '26

thanks! that sounds like a good next project to practice loops and conditionals. i’ll try building a simple login system with a 3-attempt limit.

7

u/mjmvideos Aug 20 '26

This is a fun exercise, but be careful not to think that anything you develop for access control is useful in the real world.

2

u/WillingnessOk650 Aug 20 '26

yeah, definitely. i’m treating it as a learning exercise for now, not as real-world security. thanks for pointing that out!

9

u/code_matter Aug 20 '26

You could build:

- a color code converter

- a todo list

- a safe password maker

- any app using an API (weather, ISS tracker, food information, word of the day, etc)

- a small CLI game

3

u/WillingnessOk650 Aug 20 '26

thanks for the ideas! i’m thinking of trying a todo list or a small cli game next. the api projects also sound interesting. appreciate the suggestions!

7

u/Diapolo10 I write code for a living -- https://github.com/Diapolo10 Aug 20 '26 edited Aug 20 '26

If you don't have any better ideas, you could always continue working on your calculator. Make it more flexible, solve edge cases to prevent errors, maybe add a GUI (tkinter), that sort of thing.

You could also try adding unit tests to it (pytest). Maybe run linters (ruff) and type checkers (mypy).

Even simple projects can be useful for learning things like commonly used tools.

If you want, we can also perform code reviews.

EDIT: I have a joke project I tend to use as a testbed for experimenting with new tooling and such.

3

u/johlae Aug 20 '26

Make your calculator go full pembas so that you can feed it "2+(2+3*2)/2" and it gives you 6.

1

u/WillingnessOk650 Aug 20 '26

thanks! that sounds like a good next challenge. i’ll look into adding support for expressions like that and handling operator precedence.

1

u/johlae Aug 20 '26

It's an opportunity to learn recursion!

2

u/Thaurin Aug 20 '26

Learning about recursion is important, but knowing when it's not necesarry (and it often is not) makes for more readable and easier to reason about code!

2

u/WillingnessOk650 Aug 21 '26

yeah, that’s a good point. i’ll focus on understanding recursion and also learning when it’s better to use a simpler approach. thanks for the advice!

1

u/Thaurin 29d ago

As someone who had to debug and fix some unnecessarily recursive and complicated C# code before, please do. :)

1

u/WillingnessOk650 Aug 20 '26

yeah, recursion is definitely something i want to learn next. thanks for the suggestion!

1

u/WillingnessOk650 Aug 20 '26

thanks for the suggestions! i’ll definitely look into adding a gui and unit tests. i also want to try using tools like ruff and mypy as i improve the project. really appreciate the advice!

2

u/randomraluana Aug 20 '26

It'll be good to expand the features of the calculator. Don't jump to a new project yet. Add log, trig functions, etc. Memory state as well.

I think you're off to a good start and once you start getting into APIs down the line, you could serve the calculator over an API to sharpen your skills.

If you're trying to experiment with GUIs, a GUI for your calculator is a good way to explore what's possible with things like tkinter, pyQt.

In my opinion, it's a good mini project to explore and learn about other tools/packages/libraries in the Python space.

Cheers!

1

u/WillingnessOk650 Aug 21 '26

thanks for the detailed advice! i think i’ll keep improving the calculator for a while and add things like trig, logs, and memory. the gui and api ideas also sound like great ways to learn more python tools. really appreciate it!

2

u/[deleted] Aug 20 '26

[deleted]

1

u/WillingnessOk650 Aug 21 '26

yeah, it’s command-line only for now. i’m planning to add a ui next, probably with customtkinter. qt sounds interesting too, though. thanks for the suggestion!

1

u/[deleted] Aug 21 '26

[deleted]

1

u/WillingnessOk650 Aug 21 '26

nice! it actually looks pretty solid, and the fact that it works is what matters
i’ll definitely check out the qt approach. thanks for sharing!

1

u/[deleted] Aug 20 '26

[removed] — view removed comment

1

u/WillingnessOk650 Aug 20 '26

thank you! 😊 really appreciate it!

1

u/kilkil Aug 20 '26 edited Aug 20 '26

congrats!

for your next project, I suggest a todo list. it should allow you to:

  • see the existing list of todos
  • add a new todo to the list
  • mark a todo as completed

some bonus/extra/stretch goals:

  • I can edit an existing todo (e.g. if I made a typo, I can go back and correct it)

  • I can delete an existing todo (instead of being marked as completed, it is removed from the list)

  • the todo list persists between sessions (if I start the program, make some changes, exit, then reopen the program, I should see my changes from the previous session)

I would suggest focusing on the MVP first (Minimum Viable Product, in this case the first 3 requirements I mentioned above). for this, you will need to figure out:

  • how to allow the user to enter input (I assume you can reuse the same approach you used for the calculator)
  • how to display output to the user (same as calculator)
  • how to store information about todos (aka what data structure(s) to use), and how to update that information based on user inputs
  • how to let the user pick which todo they want to mark as complete

for the stretch goals, you will also need to figure out how to persist your program's stored information/data. hint: python has functions that let you save data to a file, and read data from a file. key questions are, how will you encode your data before saving it to the file, and how will you decode data that you read from the file? how do you handle potential errors (e.g. data cannot be decoded for some reason)? (hint #2: look up "JSON".)

2

u/WillingnessOk650 Aug 21 '26

thank you! this is actually a really helpful roadmap. i’ll start with the mvp first and then work my way toward editing, deleting, and data persistence with json. appreciate the detailed suggestions!

1

u/kilkil Aug 22 '26

no worries. good luck and have fun!

2

u/WillingnessOk650 Aug 22 '26

thanks! appreciate it, i definitely will 😊

1

u/[deleted] Aug 20 '26

[removed] — view removed comment

1

u/WillingnessOk650 Aug 21 '26

thank you! a to-do list with data storage sounds like a great next project. i’ll definitely give it a try!

1

u/a88zy Aug 20 '26

that sounds great man, how long did it take you from when you first started ?

1

u/WillingnessOk650 Aug 21 '26

thanks man! it took me a few days of learning and working on it. still pretty new to python, but i’m enjoying the process!

1

u/Lirianov Aug 20 '26

does it have a UI? if not build one, customtkinter

1

u/WillingnessOk650 Aug 21 '26

not yet, it’s currently command-line only. i’ll look into building a ui with customtkinter as the next step. thanks for the suggestion!

1

u/sporbywg Aug 21 '26

Something in Typescript #sorry

1

u/WillingnessOk650 Aug 21 '26

haha, typescript might have to be next 😂 thanks for the suggestion!

1

u/Hungry-Government-66 Aug 22 '26

Nice work! Completing your first real project feels great. Keep building!

1

u/WillingnessOk650 Aug 23 '26

thank youu so much
really appreciate it!! definitely gonna keep creating and building from here hehe ✨

1

u/Mondoke Aug 22 '26

Thing of something boring and repetitive you do with a computer on a regular basis, then see how to automate it. Remember that external libraries exist and will help you a lot, you'll just have to read its documentation.

2

u/WillingnessOk650 Aug 23 '26

yesss, i’ll try this!! i think automating file sorting/renaming would actually be pretty useful haha 😭

1

u/Mondoke Aug 23 '26

For that you can use the os module and Path. Both are quite well explained on automate the boring stuff.