G+_Guttormur Ingi Einarsso Posted April 24, 2014 Share Posted April 24, 2014 so the homework from ep-14 was not all that clear to me, I think I'm doing what was asked for if not this example dose have a read from file, some very basic maths and a prime number function :) https://github.com/gormuri/c101-python files: 14-1.txt has the numbers in csv ep-14.py is the code that reads from 14-1.txt https://github.com/gormuri/c101-python Link to comment Share on other sites More sharing options...
G+_Shannon Morse Posted April 25, 2014 Share Posted April 25, 2014 is there a way to get this to work if I don't have the math import from php? " import math # ported my php basic prime number function " Link to comment Share on other sites More sharing options...
G+_Guttormur Ingi Einarsso Posted April 25, 2014 Author Share Posted April 25, 2014 HI ! the import math is actually a python maths library that is built in. you need to import it to get the square root function, what I mean by saying ported, is that I already had that primary number function in php that I wrote some years ago and I just changed the php code into python code using the exact same logic :) https://docs.python.org/2.7/library/math.html Link to comment Share on other sites More sharing options...
G+_Guttormur Ingi Einarsso Posted April 25, 2014 Author Share Posted April 25, 2014 p.s. this code runs both on python 2.x and 3.x but the output is a little prettier in 3.x :) Link to comment Share on other sites More sharing options...
G+_Shannon Morse Posted April 25, 2014 Share Posted April 25, 2014 Ah! So it's already built in. I took another look - all i had to do was add that 'enter to exit' line at the end. It works! How do I pronounce your name? I'd like to demo this on the show next week :) Link to comment Share on other sites More sharing options...
G+_Guttormur Ingi Einarsso Posted April 25, 2014 Author Share Posted April 25, 2014 well 2 weeks ago i was on the IRC channel and you did a good job with Guttormur before the show but Gutti is probably a lot easier and usually go by that nick, but if you want to you can just say it as you think it sounds :) on my code I had to make a minor change to the is_prime function as was having some issues with the int() function rounding, it will not give false positives if you use my dataset but with smaller int's it will give you a false positives :) it has some thing to do with it rounding down. looking forward to next week's show :D Link to comment Share on other sites More sharing options...
G+_Guttormur Ingi Einarsso Posted May 1, 2014 Author Share Posted May 1, 2014 great show ! and you did pretty good on pronouncing my all so simple name :) Link to comment Share on other sites More sharing options...
Recommended Posts