- Practical Data Wrangling
- Allan Visochek
- 344字
- 2021-07-02 15:16:08
Why integers?
It may seem peculiar at first to distinguish between int and float as fundamentally different data types. The first reason to make the distinction is that computers store these numbers differently and, for the sake of computer programming, there are a couple of scenarios in which it makes more sense for a programming language to use one or the other. For example, as we will see later in this chapter, using a float to index an array will cause an error and thus prevent the program from running.
You can add, divide, and multiply in a single statement, using the same rules you would expect in a scientific calculator. The order of operations is as follows:
- Expressions inside parentheses.
- Exponents.
- Division.
- Multiplication.
- Addition and subtraction.
The following commands are some examples of arithmetic in Python:
>> 2 * 3
>> 4 + 5 / 6
>> (4 + 5) / 6
>> ( ( 1 * 2 ) / 3 / 4 ) + 5 - (6 / 5)
Exponents in Python are denoted using two consecutive multiplication ** symbols. Careful not to use the ^ symbol for exponentiation in Python. The following is an example of arithmetic in python:
>> 3 ** 2
- 21天學通PHP
- Excel 2007函數與公式自學寶典
- Getting Started with MariaDB
- 電腦上網直通車
- MicroPython Projects
- Hands-On Cybersecurity with Blockchain
- OpenStack Cloud Computing Cookbook(Second Edition)
- Windows Server 2008 R2活動目錄內幕
- Machine Learning Algorithms(Second Edition)
- 貫通Java Web輕量級應用開發
- 漢字錄入技能訓練
- SketchUp 2014 for Architectural Visualization(Second Edition)
- 單片機C語言編程實踐
- C++面向對象程序設計
- Network Science with Python and NetworkX Quick Start Guide