Skip to content

Commit 028c8dc

Browse files
add variable
1 parent 9b86958 commit 028c8dc

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

basics/variable.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
def main():
2+
"""
3+
>>> a = 3
4+
>>> b = 4
5+
>>> a + b
6+
7
7+
>>> a - b
8+
-1
9+
>>> a * b
10+
12
11+
>>> a / b
12+
0.75
13+
>>> a // b
14+
0
15+
>>> a % b
16+
3
17+
>>> 3 ** 4
18+
81
19+
20+
>>> type(3)
21+
<class 'int'>
22+
>>> type(3.14)
23+
<class 'float'>
24+
>>> type('a')
25+
<class 'str'>
26+
>>> type("abc")
27+
<class 'str'>
28+
>>> type(True)
29+
<class 'bool'>
30+
>>> type(None)
31+
<class 'NoneType'>
32+
>>> type(3 + 4j)
33+
<class 'complex'>
34+
35+
>>> int(3.14)
36+
3
37+
>>> int(-3)
38+
-3
39+
>>> float("3.14")
40+
3.14
41+
>>> str(3.14)
42+
'3.14'
43+
>>> str(3 + 4j)
44+
'(3+4j)'
45+
>>> chr(65)
46+
'A'
47+
>>> chr(97)
48+
'a'
49+
>>> ord("a")
50+
97
51+
>>> ord("A")
52+
65
53+
>>> chr(ord('a') - 32)
54+
'A'
55+
>>> chr(ord('A') + 32)
56+
'a'
57+
"""
58+
59+
60+
if __name__ == "__main__":
61+
from doctest import testmod
62+
63+
testmod()

0 commit comments

Comments
 (0)