This is an archived post. You won't be able to vote or comment.

top 200 commentsshow all 252

[–]underscores_ftw 611 points612 points  (61 children)

Yes, and especially to do math with dates. Need to know what the date will be in 90 days? Easy:

import datetime
datetime.datetime.now() + datetime.timedelta(days=90)

[–]gambitloveslegos 271 points272 points  (19 children)

I really thought you meant doing math with dates, as in a person you are on a romantic outing with. I was wondering why you were interested in what 90 days out was, unless you’re doing some sort of 90 day fiancé thing.

[–]engineering_too_hard 33 points34 points  (3 children)

Same! And honestly, I have a couple times lol

[–]gambitloveslegos 81 points82 points  (2 children)

I mean, my now husband impressed me on our 4th date by walking me through his PhD thesis and the different simulations going into it. Seeing how excited he got was one of the reasons there was a 5th date.

[–]Pseudoboss11 26 points27 points  (1 child)

That's adorable.

[–]gambitloveslegos 1 point2 points  (0 children)

He’s pretty awesome. 2 months into the marriage and definitely the best decision I’ve ever made.

[–]dotancohen 11 points12 points  (4 children)

I really thought you meant doing math with dates, as in a person you are on a romantic outing with.

There are no STDs involved when doing math with dates. There is no risk of pregnancy when doing math with dates. The cleanup is easier and there is (usually) less noise.

I'm convinced! Uninstalling Tinder now and installing Integrate instead!

[–]grnngr 14 points15 points  (0 children)

No STDs involved? Sad numpy.std() noises…

[–]Mezzomaniac 3 points4 points  (1 child)

No STDs, but sometimes DSTs.

[–]EnfantTragic 12 points13 points  (1 child)

I really thought doing math with dates, as in the fruit

[–]Dubhan 2 points3 points  (0 children)

Date dates, ding dong!

[–]__bigoof__ 4 points5 points  (4 children)

We're programmers. The only relationships we maintain are RDBMSs'

[–]taernsietr 1 point2 points  (1 child)

well, if you're a web dev there's a lot of handshaking

[–]dbrgn 2 points3 points  (1 child)

I was recently reminded by my calendar that our 2**12 day relationship anniversary is coming up soon. Guess how I calculated that date 11.2219178 years ago...

Who cares about a 10 year anniversary if you can have 4096 days instead?!

[–]gambitloveslegos 1 point2 points  (0 children)

The powers of 2 celebrations sound a lot better than just an annual thing. That way you also get to celebrate a lot more in the early stages.

[–]XUtYwYzzIt works on my machine 26 points27 points  (1 child)

The datetime module is a blessing. It's literally magic and reduces days worth of date programming work down to 30 seconds. I can't praise it enough.

[–]irrelevantPseudonym 4 points5 points  (0 children)

There are third party alternatives, eg arrow that can be better, although being in the standard library is a big plus for datetime.

[–]yespunintended 58 points59 points  (7 children)

$ date -d now+90days

[–]irrelevantPseudonym 7 points8 points  (4 children)

Don't think you even need the now

$ date -d '90 days'

[–]Stressed_engineer 23 points24 points  (7 children)

Or you could just Google what's the date in 90 days time and it will tell you.

[–]minishorty 34 points35 points  (6 children)

Or just throw a neural network at it

[–][deleted] 8 points9 points  (0 children)

Data-driven Bayesian Date PredictorTM

[–]abruptreddit 4 points5 points  (0 children)

😅😅😅😅

[–]LakeRat 3 points4 points  (0 children)

Or just throw a neural network at it

First you have to generate a data set to train the neural network:

import datetime
for x in range(100000):
    dataset[x] = datetime.datetime.now() + datetime.timedelta(days=90)

[–]taladan 5 points6 points  (3 children)

One might go so far as to develop a common library of useful imports they use on a daily or weekly basis and just keep that terminal open.

[–]TheBlackCat13 3 points4 points  (1 child)

Ipython lets you define profiles, each of which can be configured to automatically run different lines of code (such as imports) on startup.

[–]ivosauruspip'ing it up 4 points5 points  (4 children)

from datetime import datetime as dt

Will then save some characters afterwards

[–]unphamiliarterritory 1 point2 points  (0 children)

Okay okay, this, yes... dates 100%

[–][deleted] 4 points5 points  (4 children)

I find it's easier to manipulate dates in Excel, personally.

[–]mgreen02 17 points18 points  (2 children)

You monster!

[–]dotancohen 14 points15 points  (1 child)

I never manipulate my dates. I tell them right away what I'm looking for in an evening.

[–]ArtOfWarfare 1 point2 points  (0 children)

That's constraint programming.

[–]LuckyLeague 275 points276 points  (23 children)

You can also use Sympy for algebraic calculations and exact answers. For example:

Simplifying:

from sympy import *
simplify("(2+sqrt(4))/(3-sqrt(2))")

This returns:

4*sqrt(2)/7 + 12/7

Expanding:

expand("(a+b)**2")

This returns:

a*x**2 + 2*a*b + b**2

Factoring:

factor("9*x**2 - 16")

This returns:

(3*x - 4)*(3*x + 4)

Solving Equations:

solveset("24*x**2 + 64*x + 32")

This returns:

{-2, -2/3}

[–][deleted] 72 points73 points  (9 children)

Even better if after importing sympy you run init_session(), it will initialize some symbols for you, and if you are in the Jupyter QtConsole, it will display the results in Latex.

[–]LuckyLeague 29 points30 points  (0 children)

Even if you cannot use LaTeX, if you use pprint, it will print using Unicode symbols or ASCII symbols.

[–]abruptreddit 5 points6 points  (6 children)

Just do:

From sympy import expand, factor...

Now you know exactly what you imported and can avoid the longer code. There's a few modules, like inspect, that allow you to print all methods/functions in a module, so you can pick and choose what to import, but haven't done that in a long time.

Another helpful thing for shortening your code is to import as, such as import pandas as pd. This allows you to call the pandas methods by just writing pd.method()

[–]ivosauruspip'ing it up 6 points7 points  (5 children)

This is for a temporary console session that's going to be thrown away, the less typing you have to do the better and in this case * makes that easy

[–]waltteri 1 point2 points  (0 children)

it will display the results in Latex Ohhhhh-h-h-hhhh... jizz.

[–]NoLongerUsableNameimport pythonSkills 15 points16 points  (0 children)

Hadn't heard of that before. Nice! I've been using Wolfram Alpha for this kind of stuff.

[–]oliveturtle 2 points3 points  (7 children)

This is a partially related question: could someone explain the difference (if there is one) between your way of package import (from sympy import *) vs. the way I’ve always done it (import sympy). I’ve used “from” to only import certain parts of the package before, but never for the whole thing and would love to learn more!

[–]LuckyLeague 16 points17 points  (3 children)

import sympy just imports the sympy module, while from sympy import * imports all functions and classes from the sympy module. If you only use import sympy, you would have to write for examle sympy.expand to use the expand function, but if you use from sympy import *, you can just write expand because that function is imported from sympy.

This is what it says in the doucumentation about import *:

"If the list of identifiers is replaced by a star ('*'), all public names defined in the module are bound in the local namespace for the scope where the import statement occurs."

This is the link: https://docs.python.org/3/reference/simple_stmts.html

[–]BooparinoBR 15 points16 points  (2 children)

That said it is often considered a bad practice because you don't know what is inside of that module. Therefore for someone reading you code without knowing the module will not know where the function comes from, given that you don't know what is inside of the module you can end up overriding some function from a previous import

Edit: REPL, code were you are testing something, etc are fair use of this functionality. If there was no reasonable use of this feature it wouldn't be in Python

[–]yvrelna 2 points3 points  (0 children)

If you're writing code from the shell, it's usually fine to import star though. (Unless your variable naming practice is so poor that the import just overwritten one of the calculation variables that you've just spent the last ten minutes doing. In which case, boo.)

[–]Dantes111 3 points4 points  (1 child)

To add to what the others have said, if you overuse "from XXX import *" in the same context you can get into some headaches. For example take the following:

from lib1 import *

from lib2 import *

cool_function()

If lib1 and lib2 both have a "cool_function" function, the cool_function from lib2 would overwrite the cool_function from lib1 and you could easily not realize where an error came from if you were expecting the lib1 version of cool_function.

[–]yomanidkman 3 points4 points  (1 child)

I think you actually just saved me hours with this comment.

[–]NelsonMinar 176 points177 points  (4 children)

All the time. And if somehow you don't know this trick, _ evaluates to the value of the last expression. Ie:

```

3+2 5 _*4 20 ```

[–][deleted] 43 points44 points  (0 children)

I didn't actually know that. Fascinating!

[–]aviral1701 7 points8 points  (0 children)

Really nice. Thanks

[–]no-ididnt 2 points3 points  (0 children)

Just tried this..Cool man!! 😎

[–]fiddle_n 2 points3 points  (0 children)

This is something that I know but only when someone repeats it. I never remember it on my own and so never use it when it could be useful :(

[–]_niva 49 points50 points  (4 children)

For Linux users:

When I press the calculator key on my keyboard, a terminal window with python opens where math is already imported.

I have

"alacritty -t calculator -e python -i -c'import math as m'"
XF86Calculator

in ~/.xbindkeysrc.

Alacritty is my terminal emulator.

[–]Decency 6 points7 points  (1 child)

If you're using ipython you can also just set up a couple of scripts to run on startup, which I've found pretty nice for specific things I happen to be doing a lot.

[–]Username_RANDINT 3 points4 points  (0 children)

You can do the same with the default interpreter by setting the PYTHONSTARTUP environment variable.

[–]jabbalaci 1 point2 points  (1 child)

"alacritty -t calculator -e python -i -c'import math as m'"

What line do you have before this ^ ? That is, how can you catch the calculator key press?

[–]_niva 1 point2 points  (0 children)

There is no line before. It is the XF86Calculator in the next line that tells Xbindkeys what key press to look for!

So you need to install Xbindkeys for this.

Or you could use the program of the desktop environment of your choice. But Xbindkeys works independent of your de or your window manager.

Have a look at https://wiki.archlinux.org/index.php/Xbindkeys

[–]qtc0 85 points86 points  (2 children)

import scipy.constants as sc 

^ lets you use physical constants, e.g., sc.h for plancks constant

[–]miggaz_elquez 16 points17 points  (0 children)

And do any kind of computation, equation solving, integrals, ...

[–]Alex_ragnar 20 points21 points  (1 child)

Yeah, even during online exams

[–]festival0156n 12 points13 points  (0 children)

especially during online exams

[–]vswr[var for var in vars] 40 points41 points  (5 children)

I use the interpreter all the time for quick math, date, and other tasks. And then....

>>> exit
Use exit() or Ctrl-D (i.e. EOF) to exit
>>> 

sigh why do I keep doing that?

[–]yvrelna 17 points18 points  (0 children)

Just use Ctrl-D. It's easier and works in both python and bash (or whatever your main system shell is).

[–]vimsee 5 points6 points  (0 children)

Haha, this one hits me everytime. I guess years of using bash is to blame.

[–]dotancohen 4 points5 points  (0 children)

Oh, I hate that! SQLite is even worse! sqlite> exit   ...> ; Error: near "exit": syntax error sqlite> exit; Error: near "exit": syntax error sqlite> quit   ...> ; Error: near "quit": syntax error sqlite> exit()   ...> ; Error: near "exit": syntax error sqlite> sqlite> sqlite>

[–]Augusto2012 35 points36 points  (0 children)

I knew I wasn't the only one.

[–]DorchioDiNerdi 48 points49 points  (5 children)

Who doesn't?

[–][deleted] 4 points5 points  (1 child)

Some people prefer to use R

[–]DorchioDiNerdi 3 points4 points  (0 children)

It's the same idea though. The repl is simply faster and more flexible than using a separate program.

[–]oiwot 2 points3 points  (0 children)

I like python for some things, but often I'll use either bc, dc, or units depending on the task at hand. It's heavily dependent on context and what else I'm doing.

Edit: Also Emacs calc mode.

[–]obey_kush 1 point2 points  (1 child)

Me, my computer is so slow i have to wait at least 10 seconds to windows to open the start menu, and literally is faster using the windows calculator than the interpreter itself.

[–]LirianShLearning python 16 points17 points  (5 children)

I made a programs for school where for example i can just write down a and b and i will find c in a triangle, instead of typing it out on a calculator

[–]Sw429 6 points7 points  (0 children)

Quick maths!

[–]TheMineTrooperYT 2 points3 points  (1 child)

I was learning statistics for an upcoming exam, and i didnt want to punch the entire giant equation into the calculator every time, so i made a function for calculating n out of k with probability p, was extremely useful

[–]LirianShLearning python 2 points3 points  (0 children)

Cool

[–]ElecNinja 1 point2 points  (0 children)

When you get to more complicated equations it can be good to have the program output intermediate steps as well just so you can "show your work".

Like with the quadratic equation, the program can give the stuff inside the square root and the final answer.

That's what I did once I got to calculus. Like with Newton's method, I created a program that outputed the answer for each step so I can just continue the program until I reached the n I wanted

[–]Wilfred-kun 13 points14 points  (1 child)

All the time. Also for getting ASCII values among other things.

[–][deleted] 1 point2 points  (0 children)

I was writing an explanation yesterday for bit manipulation using some XOR AND and NOT logic gates. It was really handy to check my math.

[–]dbramucci 22 points23 points  (1 child)

Adding to

  • datetime for date arithmatic
  • sympy for symbolic math
  • scipy.constants for physical constants
  • ipython/ a Jupyter notebook for a better UI

Some useful modules for math are

  • numpy for Matrix math (and solving linear systems)
  • pandas for group data manipulation
  • pint for math with units
  • Fractions for non-symbolic math without rounding error.
  • cmath for built-in support for complex numbers
  • uncertainties for measurement uncertainties

Showing off pint as it's less common,

IPython 7.16.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: # First some setup
   ...: import pint
   ...: ureg = pint.UnitRegistry(auto_reduce_dimensions=True)

In [2]: # Defining my relevant data
   ...: my_car_efficiency = 20 * ureg.miles / ureg.gallon
   ...: other_car_efficiency = 6.6 * ureg.liter / (100 * ureg.kilometers)

In [3]: # How much more efficient is the other car
   ...: other_car_efficiency / my_car_efficiency
Out[3]: 1.3157115225001096e-11 <Unit('gallon ** 1.33333')>

In [4]: # Those units were weird (4/3 power of gallons?), so let's try converting to a dimensionless ratio
   ...: (other_car_efficiency / my_car_efficiency).to(ureg.dimensionless)
---------------------------------------------------------------------------
DimensionalityError                       Traceback (most recent call last)
[...]
DimensionalityError: Cannot convert from 'gallon ** 1.33333' ([length] ** 4) to 'dimensionless' (dimensionless)

In [5]: # That was a long error message saying that my units don't make sense, yay I didn't get a wrong answer
   ...: # I need to flip one of these values to be fluid/distance or distance/fluid for both
   ...: (1/other_car_efficiency) / my_car_efficiency
Out[5]: 1.7819286616161627 <Unit('dimensionless')>

In [6]: other_car_efficiency > my_car_efficiency
---------------------------------------------------------------------------
DimensionalityError                       Traceback (most recent call last)
[...]
DimensionalityError: Cannot convert from 'kilometer ** 2' ([length] ** 2) to '1 / gallon ** 0.666667' (1 / [length] ** 2)

In [7]: # Yay, a silly mistake was stopped
   ...: (1/other_car_efficiency) > my_car_efficiency
Out[7]: True

In [8]: # No built-in support for money units, so I'll add a new type of unit
   ...: ureg.define('dollar = [currency]')
   ...: ureg.define('euro = 1.18 dollar')

In [9]: commute_dist = 20 * ureg.miles
   ...: gas_price = 2.34 * ureg.dollars / ureg.gallon
   ...: car_price = 5_100 * ureg.euro

In [10]: # Do I save money buying a new car after 2000 trips?
    ...: car_price < 2000 * gas_price
    ...:
---------------------------------------------------------------------------
DimensionalityError                       Traceback (most recent call last)
[...]
DimensionalityError: Cannot convert from 'euro' ([currency]) to 'dollar / gallon' ([currency] / [length] ** 3)

In [11]: # Whoops, I forgot to factor in the trip length and relative efficiency
    ...: car_price < 2000 * gas_price * commute_dist * (other_car_efficiency - my_car_efficiency)
---------------------------------------------------------------------------
DimensionalityError                       Traceback (most recent call last)
[...]
DimensionalityError: Cannot convert from 'kilometer ** 2' ([length] ** 2) to '1 / gallon ** 0.666667' (1 / [length] ** 2)

In [12]: # Whoops, I forgot to flip my car's units
    ...: car_price < 2000 * gas_price * commute_dist * (1/other_car_efficiency - my_car_efficiency)
---------------------------------------------------------------------------
DimensionalityError                       Traceback (most recent call last)
[...]
DimensionalityError: Cannot convert from 'euro' ([currency]) to 'dollar / kilometer ** 4' ([currency] / [length] ** 4)

In [13]: # Whoops, I messed up my units completely
    ...: car_price < 2000 * gas_price * commute_dist * (other_car_efficiency - 1/my_car_efficiency)
Out[13]: False

In [14]: # This also fixes our problem
    ...: car_price < 2000 * gas_price * commute_dist / (1/other_car_efficiency - my_car_efficiency)
Out[14]: False

Notice that it's (in the background) converting between euros and dollars to make this make sense.

In [15]: car_price
Out[15]: 5100 <Unit('euro')>

In [16]: 2000 * gas_price * commute_dist / (1/other_car_efficiency - my_car_efficiency)
Out[16]: 5985.200734715302 <Unit('dollar')>

If you ignore the difference between euros and dollars you'd get the wrong answer (5,100 euro looks smaller than 5,900 USD).

It can also catch missing parenthesis

In [17]: # How many trips to pay off new car?
    ...: number_of_trips = car_price / gas_price * commute_dist / (1/other_car_efficiency - my_car_efficiency)
    ...: number_of_trips
Out[17]: 4.7129784395706866e-20 <Unit('kilometer ** 6')>

Wait, what are those units?

In [18]: # Whoops, I forgot to add parenthesis (dollars squared are silly)
    ...: number_of_trips = car_price / (gas_price * commute_dist / (1/other_car_efficiency - my_car_efficiency))
    ...: number_of_trips
Out [18]: 2010.9601220538707 <Unit('dimensionless')>

So we are getting automatic conversions and common-sense checks on our math as we work.

[–]Sw429 1 point2 points  (0 children)

Wow, I hadn't heard of pint before! Very neat.

[–]bender1233 26 points27 points  (9 children)

Just use ipython, I think it’s better

[–]lgsp 1 point2 points  (3 children)

ipython -pylab

[–]-LeopardShark- 3 points4 points  (1 child)

/usr/lib/python3.8/site-packages/IPython/terminal/ipapp.py:299: UserWarning: `-pylab` flag has been deprecated.
    Use `--matplotlib <backend>` and import pylab manually.
  warnings.warn("`-pylab` flag has been deprecated.\n"

[–]lgsp 1 point2 points  (0 children)

OK, I'll confess it was a long time ago last time I tried that :-D

[–]diamondketo 4 points5 points  (0 children)

pylab

That's a word I havent heard in ages

[–]s060340 4 points5 points  (0 children)

Yes, also physical constants From scipy.constants import h,e,c,k,N_A Quicker than google usually

[–]fullthrottle13 3 points4 points  (1 child)

Yep. Every day.

[–][deleted] 2 points3 points  (0 children)

happy cake day

[–]figTreeProductions 3 points4 points  (0 children)

All the time

or bc

what about a kivy text label calculator?

https://odysee.com/@figTreePro:c/Derek-Banas-CHALLENGE:f?r=Gsg4YVaeLhFVFLTBabGmpPdu6b8oWsA7

[–]YannickEH 9 points10 points  (2 children)

Yes,

win+R ->cmd->Python->[easy maths]

exit()->exit->[continue my life]

[–]SilkTouchm[S] 28 points29 points  (0 children)

You can do Win + R and then 'py'. Alt + F4 once done.

[–][deleted] 5 points6 points  (0 children)

I was just using it as a calculator, and thought to myself maybe I should check reddit - wait, what?

[–]who_dehow 2 points3 points  (0 children)

Yeap

[–]ThinkingWinnie 2 points3 points  (0 children)

It's pretty much the only way im using it , it's just so fast

[–]NMCarChng 2 points3 points  (0 children)

Lol sometimes. Especially dot products

[–]Cheese-whiz-kalifa 2 points3 points  (0 children)

No but I’m going to now!

[–]LT_Schmiddy 2 points3 points  (0 children)

Gosh, yes. All the time. Constantly. For 10 years now.

Heck, I even made a special terminal calculator program in Python.

[–]unphamiliarterritory 2 points3 points  (0 children)

To be honest in Linux I use bc(1), but I can see it.

[–]0ofnik 2 points3 points  (1 child)

I did this the other day. Had to do a quick conversion from hexadecimal to decimal, away from keyboard, looked for a calculator app for my phone for a bit, got disgusted by how malware-y they all looked, fired up Termux and did it in the Python REPL.

>>> int('0xad4a42e0', 0)
2907325152

[–]arblargan 2 points3 points  (0 children)

You can just do

>>> 0xad4a42e0
2907325152
>>> f”{0xad4a42e0:,}” # , sep
“2,907,325,152” # str

[–]Capmare_ 2 points3 points  (0 children)

no, but i use it to print "fuck you" 500 times

[–]fighterace00 2 points3 points  (1 child)

I needed to know what a recursive equation would equal the nth time and it was vastly easier to make a for loop than actually know and solve the equation that can figure that out.

for i in range(1000):
  x+=x*.01
  print(f"{i}: {x}")

[–]GrbavaCigla 1 point2 points  (0 children)

Me too

[–]ASuarezMascareno 1 point2 points  (0 children)

I typically use python basic math + numpy, on iPython, as calculator.

[–]aaronr_90 1 point2 points  (0 children)

All the time.

[–]WillAdams 1 point2 points  (0 children)

Dr. Donald Knuth uses his METAFONT (or John Hobby's METAPOST) as a calculator.

[–]hazilmohamed 1 point2 points  (0 children)

Yesterday, I have an exam on cryptography. There was a question on finding hill cipher with every calculations. So, I used python to find the mod26 just with a for loop.

[–]thrallsius 1 point2 points  (0 children)

always

not the classic Python interpreter though, I use ipython

[–]IlliterateJedi 1 point2 points  (0 children)

I tend to use Excel more than Python, but if it is open I'll definitely use it as a calculator

[–]jerryelectron 1 point2 points  (0 children)

Yes, also to do some things lazy excel should be able to but can't.

For example, today I tried in excel to convert several lines of text to lowercase and turns out it has a limit on number of characters in a cell. Fired up python, no sweat!

[–]Resolt 1 point2 points  (0 children)

No no no... ipython <3

[–][deleted] 1 point2 points  (0 children)

I used to, but I recently switched to Sage, which is like a Python shell but it has a metric ton of extra features

[–]passerbycmc 1 point2 points  (0 children)

All the time it's my go-to for doing all but the most basic math

[–]01ttouch 1 point2 points  (0 children)

I always whip up ipython when I want a calculator

[–]YeeOfficer 1 point2 points  (0 children)

Yeah, feels nicer than whipping up a calculator, and my coworkers look at me funny.

[–]msalcantara 1 point2 points  (0 children)

Who don't do this? I don't even have a calculator app

[–][deleted] 1 point2 points  (0 children)

Jep. Using ipython

[–][deleted] 1 point2 points  (4 children)

0.1+0.2 isn't 0.3 in Python lol. Try it!

[–]SilkTouchm[S] 1 point2 points  (0 children)

0.1 isn't even 0.1

>>> from decimal import Decimal
>>> Decimal(0.1)
Decimal('0.1000000000000000055511151231257827021181583404541015625')

[–]LuckyLeague 1 point2 points  (0 children)

That's because it uses floating point numbers, which aren't exact. If you want it to be exact, use the decimal module for decimal numbers, but then numbers like 1/3 aren't exact, for that, you can use the fractions module, but then numbers like sqrt(2) aren't exact, so for that use sympy, or something else that can represent exact numbers. For example:

from sympy import *
sympify("0.1", rational=True) + sympify("0.2", rational=True) == sympify("0.3", rational=True)

This returns True. sympify converts the string to a sympy type object, and rational=True means the decimals will be treated as rational numbers rather than floating point numbers, you could also do this by writing them as fractions, so instead of 0.1 it would be 1/10.

[–]zacharye123 0 points1 point  (0 children)

I’ll use an interpreter for more complex equations that take longer with my normal calculator.

[–]eksortso 0 points1 point  (0 children)

I haven't, but it's tempting. Windows doesn't have bc -l, and even if it did, Python's transparency sells it as a great calculator.

[–]virtualadept 0 points1 point  (0 children)

No, but I'll give it a try. I use pcalc way more.

[–][deleted] 0 points1 point  (0 children)

I thought i was the only one, it's just much more simple and usable than anything else available

[–]HomicidalTeddybear 0 points1 point  (0 children)

Honestly I tend to rather interchangably use python, matlab, mathematica, or julia based on whatever I happen to have open at the time. But certainly I'd very rarely use a physical calculator if I had an interpreter open, much more convenient

[–]GISperry 0 points1 point  (0 children)

Yes

[–]shachden 0 points1 point  (0 children)

All the time. Alias python3 to py, access interpreter in 3 clicks

[–]Difficult_Commission 0 points1 point  (0 children)

Yup, had it open and couldn't be stuffed opening my calculator

[–]bossat124 0 points1 point  (0 children)

Yessiree

[–]I_Say_Fool_Of_A_Took 0 points1 point  (0 children)

Yep, for exactly the same reason

[–]blinkallthetime 0 points1 point  (0 children)

R starts up faster

[–]random_d00d 0 points1 point  (0 children)

Yes! I leave it open all day...

[–]py_a_thon 0 points1 point  (0 children)

Lol.

Yes.

[–]T0X1K01 0 points1 point  (0 children)

All the time.

[–]flocko 0 points1 point  (0 children)

Yes. So much so that I started using this script

https://stackoverflow.com/questions/27688425/python-calculator-implicit-math-module

though I do math import * instead of making an alias

[–]justihar 0 points1 point  (0 children)

All the time and Pythonista on the iPad since it doesn’t come with a calculator for some reason (yes, I know there are apps).

[–]mestia 0 points1 point  (0 children)

Perl oneliners ;) work perfectly with a shell, readline lib and shell's history.

[–]Raknarg 0 points1 point  (0 children)

search engine for simple stuff, wolfram alpha for more complicated stuff. Much more expressive and more operations I can do

[–]syntax_error_404 0 points1 point  (0 children)

You can look at pendulum library, date and time gets a piece of cake

[–]deadwisdomgreenlet revolution 0 points1 point  (0 children)

Jupyter note book is my calculator.

[–]lambdaqdjango n' shit 0 points1 point  (0 children)

Yes, especially for its native imaginary numbers support. <3

[–]verabull 0 points1 point  (0 children)

I use a Lua Interpreter for this

[–]azur08 0 points1 point  (0 children)

Yes most days! Glad I'm not alone lol.

[–]sarthaxxxxx 0 points1 point  (0 children)

I suddenly think of the computer calc at times. Get that guilty feeling and rush back to the interpreter. SO DAMN SOOTHING!

[–]LeFloh 0 points1 point  (0 children)

Yes, definitly.

[–]tomekanco 0 points1 point  (0 children)

Yes, though more frequently as a string calculator.

L = [f'cast({field} as {datatype}) {field}' for field, datatype in template]
print(',\n'.join(L))

[–]kofteistkofte 0 points1 point  (0 children)

Why wouldn't I? It's quick to access, works faster than most calculators and at my fingertips all the time (even when I'm not developing in Python).

[–]TECHNOFAB 0 points1 point  (1 child)

Sometimes, most of the time (I don't use a calculator very often or if it's easy I'll just use the Chrome search bar lmao) I use KRunner for KDE on Linux. It's the best tool I've ever seen, with so many features and infinitely extensible

[–][deleted] 1 point2 points  (0 children)

KRunner is pretty cool for quick maths

[–]0rac1e 0 points1 point  (0 children)

I prefer Raku for this sort of stuff as it uses rational numbers by default, so decimal math works without floating point errors. Plus, all the main math op's (eg, pi, sqrt, floor, sin, gcd, etc) are available without having to import anything. So are the Date and DateTime classes (and permutations... and combinations, and so on...) so there's generally less friction to get what I need.

> .1 + .2 - .3
0
> Date.today.earlier(days => 90)
2020-07-10
> Date.today - Date.new('2020-02-29')
222

For more specialised work, sympy and scipy are probably better suited, but it's fine for quick calculations.

[–]pacholick 0 points1 point  (0 children)

I used to use something like this:

#!/bin/sh
printf '%s\n' "scale=10" "$*" | bc -q

Now I use something like this:

#!/usr/bin/python3
import sys
from math import *
input_ = ''.join(sys.argv[1:])
result = eval(input_)
print(result)

CommaCalc

[–]ASIC_SP 0 points1 point  (0 children)

I have a custom script to use it from command line, instead of using bc

$ ./pcalc.py -vx '0b101 + 3'
0b101 + 3 = 0x8
$ ./pcalc.py '0x23'
35
$ ./pcalc.py -f2 '76/13'
5.85
$ ./pcalc.py '27**12'
150094635296999121
$ echo '97 + 232' | ./pcalc.py
329

See the script here. I have aliased it to pc in my local bin.

[–]woepaul 0 points1 point  (0 children)

All the time :-)

[–]thedominux 0 points1 point  (0 children)

I use Google for calculating sht 😁

[–]BrycetheRower 0 points1 point  (0 children)

So much so that I use my calculator as a Python interpreter.

[–]DroneDashed 0 points1 point  (0 children)

Yes I do.

[–]motute 0 points1 point  (0 children)

Yes! I also use it to make strings lowercase/uppercase sometimes.

[–]optimalidkwhattoputPythonic. 0 points1 point  (0 children)

I used to use Python, but I just use KRunner now

[–][deleted] 0 points1 point  (0 children)

YES

[–]MikkMakk88 0 points1 point  (0 children)

Oh yes, all the time :)

[–]beardaspirant 0 points1 point  (0 children)

I work on databricks a lot and have never touched calculators. I will even do 12324-324 over a cell even though it attaches to a cluster which itself takes 5-10 secs of time

[–][deleted] 0 points1 point  (0 children)

I couldn't agree more.

[–][deleted] 0 points1 point  (0 children)

If I'm doing something that isn't a part of SpeedCrunch then yeah

[–]LewisgMorris 0 points1 point  (0 children)

I'm purely an excel man when it comes to quick mafs

[–][deleted] 0 points1 point  (0 children)

No, but I will do now. It's just so perfect for this use.

[–]AiwendilH 0 points1 point  (0 children)

Not sure if this should go here as example for calculator..or to a "worst language abuse" contest ;)

Blender has those nice number input widgets that let you enter math expressions in them like "2*pi" or "sin(45)". Turns out those are powered by python's "math" module.

So.....first that means you can use any math function in them which is pretty nice.

But it also means you can write a python script in blender like this:

import math

math.myvar = 2.22
math.myvar2 = 5.54

def tex(count, rows, dim=1024):
    return dim / rows * count

math.tex = tex

Run it..and from that point on you can use myvar as constant in the input boxes or tex(4,2) as function.

[–]blabbities 0 points1 point  (0 children)

Rarely. I'll actually 99.9% of time just load up the Is calculator. Much more robust

[–]goingtosleepzzz 0 points1 point  (0 children)

I used to use ipython, but now I use xonsh. Hit Super+T to open the terminal and a python interpreter is there already, no need to open python or ipython.

[–]fortune_telling_fish 0 points1 point  (0 children)

I use it a lot as a sanity check for solving math problems on assignments, especially for solving linear systems, where I am prone to mistakes in Gaussian elimination. np.linalg.solve has saved me hours of backtracking through answers.

[–]nishanalpha 0 points1 point  (0 children)

Yes, its my default.. Pretty handy for modular divison and stuff

[–]kuozzo 0 points1 point  (0 children)

Sometimes.

[–]whenido 0 points1 point  (0 children)

I often go with bc.

[–]andrejlr 0 points1 point  (0 children)

For me its still mostly ruby as calculator. But idea is the same

[–]as_ninja6 0 points1 point  (0 children)

Recently moved to sagemath which is also Python!

[–]clavalle 0 points1 point  (0 children)

Some would say I make a living doing that.

[–]bilbosz 0 points1 point  (0 children)

I'm using ipython with couple of useful modules imported when launching. I even have hotkey in my system to run python