官术网_书友最值得收藏!

Data Types and Modules

Because Python is built upon the C language, many aspects of Python will be familiar to users of C-like languages. However, Python makes life easier because it isn't as low-level as C. The high-level nature of Python means that many data primitives aren't required, as a number of complicated data structures are provided in the language by default.

In addition, Python includes features not often found in low-level languages, such as garbage collection and dynamic memory allocation. On the flip side, Python isn't known for its ability to interact with hardware or perform other low-level work. In other words, Python is great for writing applications but wouldn't be a good choice for writing a graphics card device driver.

Learning how to use built-in data structures helps your programming. Data structures are particular ways of organizing data so they can be used most efficiently. It's easier to write code because the included data structures tend to provide all the features you need, so you spend less time creating your own. If you do need to create your own, you'll probably use the built-in structures as a foundation to start from. This, in turn, means your customized structures will generally perform better than fully customized code, as the built-in data structures have been vetted by multiple developers over a long period of time, so they are fully optimized. Finally, using built-in structures means you always know what is available; proprietary frameworks are an unknown entity, as you can never be sure what is available to you.

In this chapter, we will cover the following topics:

  • Structuring code
  • Common data types
  • Python numbers
  • Strings
  • Lists
  • Dictionaries
  • Tuples
  • Sets
  • Using data type methods
  • Importing modules
主站蜘蛛池模板: 壶关县| 襄汾县| 宿松县| 三明市| 庄浪县| 梅州市| 北海市| 阜新市| 东兰县| 磐石市| 淮北市| 遂溪县| 正定县| 阜新市| 滁州市| 胶南市| 永州市| 武陟县| 进贤县| 获嘉县| 遂昌县| 盱眙县| 吐鲁番市| 新巴尔虎左旗| 罗山县| 泗洪县| 滦平县| 江口县| 会宁县| 华亭县| 含山县| 南开区| 武定县| 武冈市| 北票市| 瓮安县| 塔河县| 奇台县| 太湖县| 安宁市| 阿勒泰市|