回答編集履歴
1
ソースコードを追加
test
CHANGED
@@ -51,3 +51,43 @@
|
|
51
51
|
2.141592653589793
|
52
52
|
|
53
53
|
```
|
54
|
+
|
55
|
+
ソースコードは以下です。
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
```python
|
60
|
+
|
61
|
+
class Float(float):
|
62
|
+
|
63
|
+
def __repr__(self):
|
64
|
+
|
65
|
+
if self == 2.718281828459045: return 'e'
|
66
|
+
|
67
|
+
elif self == 3.141592653589793: return 'π'
|
68
|
+
|
69
|
+
else: return super().__repr__()
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
x = Float(2.718281828459045)
|
74
|
+
|
75
|
+
print(x)
|
76
|
+
|
77
|
+
print(x-1)
|
78
|
+
|
79
|
+
x = Float(3.141592653589793)
|
80
|
+
|
81
|
+
print(x)
|
82
|
+
|
83
|
+
print(x-1)
|
84
|
+
|
85
|
+
import math
|
86
|
+
|
87
|
+
x = Float(math.pi)
|
88
|
+
|
89
|
+
print(x)
|
90
|
+
|
91
|
+
print(x-1)
|
92
|
+
|
93
|
+
```
|