### Basic Math

###### Written by Mitch in Misc on Tue 02 February 2016. Tags: python, basic math,

### Python Basic Math

###### Updated below (Feb 13th 2016)

###### Originally Written on June 24th 2015

I had been interviewing lately... (its more official now which is why I'm writing about it) I did a bunch of interviews, some wanting to test my python prowess, and well they stumped me. On basic math with python... yeah I was extremely frustrated by the experience as I've been doing python for years... never had many on the spot, do some basic math now kind of moments. None the less, it irritated me. So, I went home and revisited the question. Not 5 minutes later I had the answer, but it bugged me the whole drive home. Which is something I do a lot, something bugs me regardless of how small and meaningless (like needing to do basic math in python), I'm posting here for posterity. Question is not word for word what I got, because I didn't copy it, but heres the basics of it:

Write a script that will check numbers 1 through 100, to see if they are divisible by 4, if they are print "word". If they are divisible by 6, print "anotherword", if they are divisible by both, print "both". Otherwise print the number.

```
for x in range(1,101):
is4 = False
is6 = False
if float(x/4.0).is_integer():
print str(x) + "/4 = " + str(float(x/4.0))
is4 = True
if float(x/6.0).is_integer():
print str(x) + "/6 = " + str(float(x/6.0 ...
```