Lesson 5
上节课使用python2实验了很多数据类型,本节来看看python3做了哪些改变,有什么不同之处。
int类型
# Let's begin!
# Types of Numbers: int, float, complex
a = 496 # This is a perfect number
type(a) # get a's type
int
a # get a's value
496
print(a) # print a's value
496
float类型
# define float number e
e = 2.71821291
# To confirm it is a float, get its type.
type(e)
float
complex类型
1 | # define complex number z |
和python2一样,都是用float类型来表示实部和虚部的。
Conclusion
1 | "Numbers in python2 and python3 are no difference.") print( |
Youtube source:
https://www.youtube.com/watch?v=bY6m6_IIN94&list=PLi01XoE8jYohWFPpC17Z-wWhPOSuh8Er-