Posts

Showing posts with the label python

How to Install Python 2.7 on Windows 10

Image
Unlike Linux OS or Mac, Windows never include Python as default program. Windows users have to install it by their own. Fortunately, Python installation in Windows isn't big problem. Just with some clicks and everything gets done. For very beginning step, from your browser, go to Python download page  and download the installer from the page.

What a confuse 'False'

Image
Hi everybody! Recently I was working with dictionary contains 0 value and string key. Little bit annoyed when I ran the code, the algorithm was not successful. What I did was checking dictionary value (which contains 0 value) with "get" method. Yeah it's returned to 0 which is read as false in python. If you use it in if-else statement, it would be passed to else. Let me explain what I did in my case below.

Extended Euclid for GCD

Image
After GCD, I introduce you Extended Euclid algorithm to prove GCD of two integer numbers. I repeat, this algorithm only for proving purpose. So, in the end of the code you will only see it's proved oor not. It's said that GCD will fulfill equation below. 1 s * a + t * b = gcd(a, b) Where s and t is integers. What I did in my program is finding value of s and t then I could prove that my GCD follows Extended Euclid. My codes could be forked  here  as extended_euclid.py file. Simply go to your terminal and change the directory to x0x folder and run python extended_euclid.py . The terminal console is like my illustration below:

Greatest Common Divisor

If you have two different numbers and also they are integers, let's say 6 and 3, we could easily the greatest common divisor is 3. Why? 1 2 6 = 3 x 2 x 1 3 = 3 x 1 Both of 6 and 3 have same 1 and 3 as divisor. But the greatest one is 3. How about two big integers? it's hard to derived big integers into its prime numbers and see what number the greatest is. I developed a program in python named gcd. You can fork the program  here . But I will give you the main idea of this program.

Hello World!

Firstly, thanks to God who created the programming language. Yeah, in fact it's a human creation but originally it's His creation. Okay, don't talk about God anymore. God is always listening, always understanding. lol.