![]() ![]() the part of imaginary number, and use real() to acquire its real part, i.e. ![]() For example, for a complex number, we may use imag() to acquire its imaginary part, i.e. The function used here is real() and imag(). As for a complex number, its real part and its imaginary part can also be separated. Surely a complex may have no real part, like in this form. In Python, an imaginary number is identified by the tag j, like 2.4+5.6j. As for imaginary numbers, you know, they refer to numbers whose squares are negative numbers. PYTHON BASIC DATA TYPES PLUSA real number plus an imaginary number constitute a complex number. To use this type, a program is needed to generate it. It does not exist in many other programming languages. The complex number type is a very special type. The floating point type is called float in Python. So what's this value? It is -4.78 times 10 to the power of -2. Should that be 10 to the power of 3? e-2 is surely 10 to the power of -2. For example, as for this form of 9.8e3, its actual value is 9800.0. Besides, a floating point number in Python, like in any other programming language, may be expressed in scientific notation. The floating point type is actually the real number in mathematics, like this value 3.22. We would then see that its actual value is 1 or 0. In practice, you may assign True or False to a variable to express the meaning of true or false you want it to represent. In Python, as for any number whose value is 0 or empty set, like an empty list or an empty tuple we'll talk about later, its Boolean value in Python is always False. Essentially True is stored as 1, while False is stored as 0. The Boolean type is indeed a sub-class of integer. So that is also a very lovely point of Python. If you have learned any other language, you might think overflow is a quite boring problem. We may generally say that, in Python, there is almost no error of overflow in integer type. And similarly it can express a very huge integer. But actually after Python 2.2, the integer type and the long type have been unified, so the length supported by integer type is also related to the size of memory. In Python the long integer type is related to the size of memory supported by the machine, so it can easily express a very long integer. ![]() What if it is a 64-bit machine? Its range should be between -2 to the power of 63 and 2 to the power of 63 minus 1(-2^63 ~ 2^63-1) The range of long type in Python is far larger than that in the C language or any other similar compiled language. For example, for a standard integer type at a 32-bit machine, its range shall be between -2 to the power of 31 and 2 to the power of 31 minus 1(-2^31 ~ 2^31-1). For standard integer type, its length is related to the machine word length. And we'll talk about list, tuple and dictionary etc. In this section, we'll first introduce integer, floating point, complex number, Boolean and string. The standard data types in Python include integer, floating point, complex number, Boolean, string, list, tuple and dictionary. Let's first look at the common data types in Python. If the type is unclear, the size of storage space may be random often leading to failure in direct computing. Only with a definite data type can a program allocate definite space to the data to conduct accurate computing. Each type has a different range and ability of representation, and the efficiency to tackle problems is also different. View Syllabusįor different objects involved in a task, different types may be chosen for representation. Note: videos are in Chinese (Simplified) with English subtitles. Web API is also added.ģ) Improve the content order and enrich details of some content especially for some practice projects. ![]() PYTHON BASIC DATA TYPES MANUALUpdates in the new version are :ġ) the whole course has moved from Python 2.x to Python 3.xĢ) Added manual webpage fetching and parsing. Similarly, it may also be flexibly applied into other fields. Also, it discusses the fast, convenient and efficient data processing capacity of Python in humanities and social sciences fields like literature, sociology and journalism and science and engineering fields like mathematics and biology, in addition to business fields. This course, as a whole, based on Finance data and through the establishment of popular cases one after another, enables learners to more vividly feel the simplicity, elegance, and robustness of Python. PYTHON BASIC DATA TYPES HOW TOIt starts with the basic syntax of Python, to how to acquire data in Python locally and from network, to how to present data, then to how to conduct basic and advanced statistic analysis and visualization of data, and finally to how to design a simple GUI to present and process data, advancing level by level. This course (The English copy of "用Python玩转数据" ) is mainly for non-computer majors. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |