Calculator using variable names

I’ve recently been assigned an assignment to create a word calculator, and given my knowledge in python is still quite lacking, I want to ask if anybody has any better ideas for any possible solutions. The question is here: Jimmy has invented a new kind of calculator that works with words rather than numbers. Input … Read more

Reversing a number

I was working through a programming challenge I found on Reddit and it seemed easy enough: Find all numbers less than \$10^n\$ where the number and its reverse (the reverse of \$123\$ is \$321\$) are both divisible by \$7\$ and then sum them all together. def challenge_229(power): numbers = [] for x in range(0, 10**power, … Read more

Is there a Pathlib alternate for os.path.join?

I am currently accessing the parent directory of my file using Pathlib as follows: Path(__file__).parent When I print it, and this gives me the following output: print(‘Parent: ‘, Path(__file__).parent) #output /home/user/EC/main-folder The main-folder has a .env file which I want to access and for that I want to join the parent path with the .env. … Read more

Switch between python 2.7 and python 3.5 on Mac OS X

I generally use Python 2.7 but recently installed Python 3.5 using Miniconda on Mac OS X. Different libraries have been installed for these two versions of python. Now, the entering either of the keywords ‘python’ or ‘python3’ in terminal invokes python 3.5, and ‘python2’ returns ‘-bash: python2: command not found’. How can I now invoke … Read more

Using multiple Python engines (32Bit/64bit and 2.7/3.5)

I would like to use Python for scientific applications and after some research decided that I will use Anaconda as it comes bundled with loads of packages and add new modules using conda install through the cmd is easy. I prefer to use the 64 bit version for better RAM use and efficiency but 32bit … Read more

A good way to make long strings wrap to newline?

In my project, I have a bunch of strings that are read in from a file. Most of them, when printed in the command console, exceed 80 characters in length and wrap around, looking ugly. I want to be able to have Python read the string, then test if it is over 75 characters in … Read more

Cannot install NumPy from a wheel format

I am trying to install NumPy from a wheel (.whl) file. I get the error: numpy-1.9.1%2Bmkl-cp34-none-win_amd64.whl is not a supported wheel on this platform. Details: Windows 8.1 pro x64, elevated command prompt Python 3.4.2 Package NumPy from Gohlke’s site File numpy-1.9.1%2Bmkl-cp34-none-win_amd64.whl copied in the pip.exe folder The log file shows: d:\Program Files\WinPython-64bit-3.4.2.4\python-3.4.2.amd64\Scripts\pip run on 01/23/15 … Read more