-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython-number.py
More file actions
106 lines (73 loc) · 1.08 KB
/
Copy pathpython-number.py
File metadata and controls
106 lines (73 loc) · 1.08 KB
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
"""
x = 1 #int
y = 2.8 #float
z = 1j #complex
print(type(x))
print(type(y))
print(type(z))
"""
"""
x = 1
y = 35656323242424324
z = -3423342314
print(type(x))
print(type(y))
print(type(z))
"""
"""
x = 1.10
y = 1.0
z = -35.59
print(type(x))
print(type(y))
print(type(z))
"""
"""
x = 35e3
y = 12E4
z = -877.21e100
print(type(x))
print(type(y))
print(type(z))
"""
"""
x = 3+5j
y = 5j
z = -5j
print(type(x))
print(type(y))
print(type(z))
"""
"""
#Type Conversion
x = 1
y = 2.8
z = 1j
#convert from int to float:
a = float(x)
#convert from float to int:
b = int(y)
#convert from int to complex:
c = complex(x)
print(a)
print(b)
print(c)
print(type(a))
print(type(b))
print(type(c))
"""
"""
import random
print(random.randrange(1,10))
"""
#python specify a variable type
x = int(1) # x will be 1
y = int(2.8) # y will be 2
z = int("3") # z will be 3
x = float(1) # x will be 1.0
y = float(2.8) # y will be 2.8
z = float("3") # z will be 3.0
w = float("4.2") # w will be 4.2
x = str("s1") # x will be 's1'
y = str(2) # y will be '2'
z = str(3.0) # z will be '3.0'