-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathnumbers.py
executable file
·59 lines (49 loc) · 1010 Bytes
/
numbers.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
#!/usr/bin/env python
# Python Numbers
#
# There are three numeric types in Python:
#
# int
# float
# complex
x = 1 # int
y = 2.8 # float
z = 1j # complex
# To verify the type of any object in Python, use the type() function:
print( type(x) )
print( type(y) )
print( type(z) )
# Int
#
# Int, or integer, is a whole number, positive or negative, without decimals, of unlimited length.
x = 1
y = 35656222554887711
z = -3255522
print( type(x) )
print( type(y) )
print( type(z) )
# Float
#
# Float, or "floating point number" is a number, positive or negative, containing one or more decimals.
x = 1.10
y = 1.0
z = -35.59
print( type(x) )
print( type(y) )
print( type(z) )
# Float can also be scientific numbers with an "e" to indicate the power of 10.
x = 35e3
y = 12E4
z = -87.7e100
print( type(x) )
print( type(y) )
print( type(z) )
# Complex
#
# Complex numbers are written with a "j" as the imaginary part:
x = 3 + 5j
y = 5j
z = -5j
print( type(x) )
print( type(y) )
print( type(z) )