- Practical Data Wrangling
- Allan Visochek
- 246字
- 2021-07-02 15:16:10
Naming variables
Using the right name for a variable is important. There are some conventions and some syntactical rules to name variables properly. Variables have to be one word, they have to start with a letter or underscore, and all remaining characters must be a letter, a number, or an underscore. If these rules are not followed, the program will produce an error.
There are two best practices to take into account when choosing a variable name. First, the variable name should reflect its function in the program. This makes it easier to keep track of how the program functions. Second, if the variable name consists of several words, these should be separated using either camel case or snail case to make it easier to read.
In camel case, the first word starts with a lowercase letter, while all the following words start with an uppercase letter. In snail case, each word is lowercase and is separated by an underscore. It is best practice to use either one or the other for a given program and stick with it, though this can get tricky, especially if multiple people are working on the same project.
Variables are a key part of what makes programming an effective means of expression. Storing and labeling data can make it easier to reference and keep track of, but it also makes it possible to build more sophisticated operations. This will become clear when I introduce compound statements later in this chapter.
- 現代測控系統典型應用實例
- Canvas LMS Course Design
- Cloud Analytics with Microsoft Azure
- JMAG電機電磁仿真分析與實例解析
- 21天學通Visual Basic
- 數據通信與計算機網絡
- CentOS 8 Essentials
- Nginx高性能Web服務器詳解
- Practical Big Data Analytics
- 激光選區熔化3D打印技術
- Hands-On Data Warehousing with Azure Data Factory
- Linux Shell編程從初學到精通
- Linux系統下C程序開發詳解
- 機器人制作入門(第4版)
- 網管員世界2009超值精華本