-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patha.py
73 lines (57 loc) · 1.13 KB
/
a.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
def f(n, d):
"""asddsad
>>> q, r = f(2013, 10)
>>> q
201
>>> r
3
"""
return n // d, n % d
def a():
print("a")
return "aaa"
def b():
print("b")
return "bbb"
# 2022/12/12
# nonlocal and global
doc = "abc"
def changeD(doc):
# global doc
# nonlocal doc
def changeDoc():
# nonlocal doc
# doc = doc + "def"
print(doc)
return changeDoc
class Account:
interest = 0.02
def __init__(self, holder_name) -> None:
self.balance = 0
self.holder_name = holder_name
def deposit(self, amount):
self.balance += amount
return self.balance
# 2022/12/21
from fractions import Fraction
half = Fraction(1,2)
print(half)
print(repr(half))
print(str(half))
print(eval(repr(half)))
print(eval(str(half)))
class Bear:
def __init__(self):
self.__repr__ = lambda: 'oski'
self.__str__ = lambda: "this bear"
def __repr__(self):
return "Bear()"
def __str__(self):
return "a bear"
oski = Bear()
print()
print(oski)
print(str(oski))
print(repr(oski))
print(oski.__str__())
print(oski.__repr__())