Created
May 11, 2018 17:07
-
-
Save edenizk/7f656fe211f29d91868dffbe560c8f9b to your computer and use it in GitHub Desktop.
checks decimal lenght
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| x = int(eval(input("x = ") ) ) | |
| k = int(input("k = ")) | |
| print(k , "position digit = ", (abs(x) // 10 ** k) % 10) | |
| print(k , "position digit = ", (abs(x) // 10 ** k) % 2) | |
| print ("length of the decimal number = ", len(str(x))) | |
| print ("length of the binary number = ", len(str(bin(abs(x))))-2, ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment