Forum Archive

Calculator Pro

Truppelito

Hi guys! Here is my own calculator that I did entirely on my iPhone in two days. I'm actually pretty happy with the result. In my opinion, it is a more useful calculator than the one that comes with iOS. The one downside is that it takes more taps to open my calcultor in Pythonista than a normal calculator app, and with an iPhone 4 and iOS 7, more taps means exponentially more time... :D

You can get it here. It should also work on an iPad, but I wouldn't know because I haven't got one.

Let me know what you think!

Features:

  • Enter full mathematical expressions with parenthesis (unlike the calculator that comes with iOS)

  • Comparison support: for example, sin(pi) > cos(pi) yields True

  • Trig functions and their arc variations

  • Constants: pi and e

  • Exponentiation, factorization and natural logarithms

  • Press = equal without a current expression to repeat the last calculation (specially useful when paired with the Ans button)

  • Handles errors with style (try dividing by zero to see what happens!)

  • Press the result screen at the top to copy the last result to the clipboard

due3die

@Truppelito Hi, I am getting error @line 188 (indentionError: unindent does not match any outer indentation level)

Truppelito

@due3die Sorry, slight problem when copying & pasting. It should work now, please redownload the gist.

due3die

@Truppelito Superb...

Sebastian

Nicely done! Great work @Truppelito!
Just out of curiosity; since you don't have an iPad, did you code this on the iPhone or did you use a computer?
Because I can imagine it would be exhausting to write all that on just an iPhone XD

Truppelito

@Sebastian As dificult as that may seem, I did write this entirely on my iPhone 4! I was on vacation and I didn't have my computer, but I had this urge to code, for some reason, and Pythonista is such an amazing app... And so it happened that my perserverance outmatched my tiny screen :)

ccc

A stunning demonstration of the addictive nature of Pythonista ;-)

Truppelito

@ccc Yes, yes it is indeed!

n8o

I feel like I'm missing the way to get gists into Pythonista. There doesn't appear to be an easier way than selecting the source manually and copying. Any tips?

Truppelito

@n8o Yes, in fact there is. On this page, search for Script Integration. That page has loads of cool scripts, and one of them does exactly what you want.

PKHG

I indicated at GitHub a run-time error ;-) and my solution.
Plus a wish to add more functionality
E,g:
Rand gives always a fraction so to have random numbers (1, ..6) you
need to get rid of fraction part (after multiplication etc.)

PeterG

Who is willing to help understanding the code, to add more working buttons?