Python 1.1 Python Data Structures
此篇文章是我學習Python整理的筆記,如果有任何錯誤請留訊息給我,萬分感謝。
Python intro
Python is an interpreted, interactive, object-oriented programming language. It incorporates modules, exceptions, dynamic typing, very high level dynamic data types, and classes. Python combines remarkable power with very clear syntax. It has interfaces to many system calls and libraries, as well as to various window systems, and is extensible in C or C++. It is also usable as an extension language for applications that need a programmable interface. Finally, Python is portable: it runs on many Unix variants, on the Mac, and on PCs under MS-DOS, Windows, Windows NT, and OS/2.
Python Installation https://www.anaconda.com/
With over 20 million users worldwide, the open-source Individual Edition (Distribution) is the easiest way to perform Python/R data science and machine learning on a single machine.
Python practice
Data Types
- Text Type:
str - Numeric Types:
int,float,complex - Sequence Types:
list,tuple,range - Mapping Type:
dict - Set Types:
set,frozenset - Boolean Type:
bool - Binary Types:
bytes,bytearray,memoryview - None Type:
NoneType
| Data type | Example |
|---|---|
| str | x =”Hello Eunice” |
| int | x = 12 |
| float | x = 10.5 |
| complex | x = 2j |
| list | x = [“dog”, “cat”, “turtle”] |
| tuple | x = (“dog”, “cat”, “turtle”) |
| range | x = range(6) |
| dict | x = {“name” : “Eunice”, “age” : 18} |
| set | x = {“dog”, “cat”, “turtle”} |
| frozenset | x = frozenset({“dog”, “cat”, “turtle”}) |
| bool | x = True |
| bytes | x = b”Hello” |
| bytearray | x = bytearray(5) |
| memoryview | x = memoryview(bytes(5)) |
| NoneType | x = None |
How to check data types?
1 | x = 5 |
<class ‘int’>
<class ‘bool’>
<class ‘str’>



