更新第五次实验

This commit is contained in:
Luthics 2022-11-26 11:26:52 +08:00
parent d377eb08e1
commit 533f9d9752
6 changed files with 59 additions and 0 deletions

4
test/5/1.py Normal file
View File

@ -0,0 +1,4 @@
n = int(input())
print(bin(n)[2:])
print(oct(n)[2:])
print(hex(n)[2:])

2
test/5/2.py Normal file
View File

@ -0,0 +1,2 @@
for i in range(33, 127):
print(str(i) + " " + chr(i))

7
test/5/3.py Normal file
View File

@ -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])

6
test/5/4.py Normal file
View File

@ -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="")

10
test/5/5.py Normal file
View File

@ -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))

30
test/5/6,7.py Normal file
View File

@ -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))