Skip to content

Instantly share code, notes, and snippets.

@pandanote-info
Created May 13, 2020 13:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pandanote-info/94ced36deb5435654b676accf9213387 to your computer and use it in GitHub Desktop.
Save pandanote-info/94ced36deb5435654b676accf9213387 to your computer and use it in GitHub Desktop.
第1引数に与えられた数xの最上位の桁以外の桁を0にした数を出力するPython3のプログラム。
#!/usr/bin/env python3
import sys
import math
args = sys.argv
x = float(args[1])
n = math.floor(math.log10(x))
y = math.floor(x/math.pow(10,n))*math.pow(10,n)
print("{0:d}".format(int(y)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment