Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc7548d2

Browse files
committed
Adicionados exemplos de números em Python.
1 parentdd832e5 commitc7548d2

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

‎numbers.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/usr/bin/env python
2+
3+
# Python Numbers
4+
#
5+
# There are three numeric types in Python:
6+
#
7+
# int
8+
# float
9+
# complex
10+
x=1# int
11+
y=2.8# float
12+
z=1j# complex
13+
14+
# To verify the type of any object in Python, use the type() function:
15+
print(type(x) )
16+
print(type(y) )
17+
print(type(z) )
18+
19+
# Int
20+
#
21+
# Int, or integer, is a whole number, positive or negative, without decimals, of unlimited length.
22+
x=1
23+
y=35656222554887711
24+
z=-3255522
25+
26+
print(type(x) )
27+
print(type(y) )
28+
print(type(z) )
29+
30+
# Float
31+
#
32+
# Float, or "floating point number" is a number, positive or negative, containing one or more decimals.
33+
x=1.10
34+
y=1.0
35+
z=-35.59
36+
37+
print(type(x) )
38+
print(type(y) )
39+
print(type(z) )
40+
41+
# Float can also be scientific numbers with an "e" to indicate the power of 10.
42+
x=35e3
43+
y=12E4
44+
z=-87.7e100
45+
46+
print(type(x) )
47+
print(type(y) )
48+
print(type(z) )
49+
50+
# Complex
51+
#
52+
# Complex numbers are written with a "j" as the imaginary part:
53+
x=3+5j
54+
y=5j
55+
z=-5j
56+
57+
print(type(x) )
58+
print(type(y) )
59+
print(type(z) )

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp