From 533f9d97522b8cd474b432cc26bad0e123765c83 Mon Sep 17 00:00:00 2001 From: Luthics Date: Sat, 26 Nov 2022 11:26:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=AC=AC=E4=BA=94=E6=AC=A1?= =?UTF-8?q?=E5=AE=9E=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/5/1.py | 4 ++++ test/5/2.py | 2 ++ test/5/3.py | 7 +++++++ test/5/4.py | 6 ++++++ test/5/5.py | 10 ++++++++++ test/5/6,7.py | 30 ++++++++++++++++++++++++++++++ 6 files changed, 59 insertions(+) create mode 100644 test/5/1.py create mode 100644 test/5/2.py create mode 100644 test/5/3.py create mode 100644 test/5/4.py create mode 100644 test/5/5.py create mode 100644 test/5/6,7.py diff --git a/test/5/1.py b/test/5/1.py new file mode 100644 index 0000000..bcd353e --- /dev/null +++ b/test/5/1.py @@ -0,0 +1,4 @@ +n = int(input()) +print(bin(n)[2:]) +print(oct(n)[2:]) +print(hex(n)[2:]) \ No newline at end of file diff --git a/test/5/2.py b/test/5/2.py new file mode 100644 index 0000000..af325c6 --- /dev/null +++ b/test/5/2.py @@ -0,0 +1,2 @@ +for i in range(33, 127): + print(str(i) + " " + chr(i)) \ No newline at end of file diff --git a/test/5/3.py b/test/5/3.py new file mode 100644 index 0000000..5e14b38 --- /dev/null +++ b/test/5/3.py @@ -0,0 +1,7 @@ +s = input() +print(str(s.encode("GB2312"))[2:-1]) +print(str(s.encode("GBK"))[2:-1]) +print(str(s.encode("GB18030"))[2:-1]) +print(str(s.encode("UTF-8"))[2:-1]) +print(str(s.encode("UTF-16-BE"))[2:-1]) +print(str(s.encode("UTF-16-LE"))[2:-1]) \ No newline at end of file diff --git a/test/5/4.py b/test/5/4.py new file mode 100644 index 0000000..66d6387 --- /dev/null +++ b/test/5/4.py @@ -0,0 +1,6 @@ +s = input() +for i in s: + if (ord(i) >= ord('a') and ord(i) <= ord('z')): + print(chr(ord(i) - 32), end="") + else: + print(i, end="") diff --git a/test/5/5.py b/test/5/5.py new file mode 100644 index 0000000..efe6f19 --- /dev/null +++ b/test/5/5.py @@ -0,0 +1,10 @@ +def b(x): + s = "" + while (x): + s += str(x % 2) + x //= 2 + return s[::-1] + + +a = int(input()) +print(b(a)) \ No newline at end of file diff --git a/test/5/6,7.py b/test/5/6,7.py new file mode 100644 index 0000000..7502673 --- /dev/null +++ b/test/5/6,7.py @@ -0,0 +1,30 @@ +def b(x): + if (x == 0): + return "0" + s = "" + while (x): + s += str(x % 2) + x //= 2 + return s[::-1] + + +def binx(x): + x -= int(x) + if (x == 0): + return "" + binn = "." + while x: + x *= 2 + if x >= 1: + binn += "1" + else: + binn += "0" + x -= int(x) + if (len(binn) >= 9): + return binn + return binn + + +a = float(input()) +print(b(int(a)), end="") +print(binx(a)) \ No newline at end of file