is that really prime?
so, today I wrote my second python script ( big accomplishment ) which just lists prime numbers. I put it in a file called prime.py so I might be able to use it later on!! This is how it looks like:
====================================================
#printing a range of prime numbers def isPrime( n ): factor = n // 2 while factor > 1: if n % factor == 0: return 0 break else: factor -= 1 else: return 1 def listPrimes( num ): for n in range( num + 1 ): if n > 1: if isPrime( n ): print n, 'is prime' listPrimes( 100 );
====================================================
and that’s all there is to it! Well, just add the indentation yourself, I still haven’t figured out how to keep the indentation when posting scripts!
hahahaha and on a side note, I had to check all of the output numbers myself ( not thoroughly though ) just to make sure I didn’t make any mistakes in the script! funny way of debugging.
UPDATE: thanks to a fantastic blogger, Vlad Dolezal ( anamazingmind.com ) I’m able to keep the formatting of the code!
A fancy keyboard
Today I was typing a little bit and then I just wanted to move my mouse to some other place on the screen. At that moment I remember the old laptops which had a dot in the middle of their keyboards and you could push that dot to a specific direction and then your mouse moved. My uncle had that kind of laptops once I was just a little kid ( as if I’m so huge now! ).
Now, that, made me think that what if there were keyboards in which you had a small, very small dot in the middle of it and if you pushed it, your mouse moved, without the need to get your hand off keyboard and reach for mouse just for a little move. It really doesn’t worth it!! A good use of this ‘dot’ would be when you’re for example scripting, and you want to just open a file and keep typing. Well, you could just get off the keyboard and move the mouse and do your stuff with it, or just set some shortcuts before hand and then use those shortcuts you made to reach your file, but it would be so much easier if you could just move your mouse with keyboard, a virtual, fast-accessed mouse right build into your keyboard. If any of you have seen those old laptop I’m talking about, you have then a very clear idea of what I’m thinking.
The built-in mouse ( that ‘dot ) could be somewhere between Y, U, and H on keyboard. It would make life soooooooooooo much easier, seriously. Not just that, maybe some people just don’t like to use mouse ( e.g. me ) but NEED to use it for just a fraction of a second ( figuratively speaking ), then you could just use that ‘dot’ in your keyboard!!!
wouldn’t that be a good idea? let me know what you think about it!