Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |
Tags
- MySQL
- break
- variables
- train/test
- AS
- Else
- Default X points
- continue
- SQL
- line width
- __init__
- pie charts
- Github
- multiple lines
- data distribution
- PROJECT
- line color
- error
- machine learning
- self parameter
- matplotlib.pyplot
- Text mining
- start exercise
- PANDAS
- polynomial regression
- matplotlib
- iterates
- Text Analytics
- For loops
- Python
Archives
- Today
- Total
Data Science Explorer
[Basic Grammar] Python Variables: Variable Names 본문
반응형
Rules for Python variables:
- A variable name must start with a letter or the underscore character
- A variable name cannot start with a number
- A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ )
- Variable names are case-sensitive (age, Age and AGE are three different variables)
- A variable name cannot be any of the Python keywords
For better understanding, please refer to the following example.
Example
Legal variable names:
myvar = "Will"
my_var = "Will"
_my_var = "Will"
myVar = "Will"
MYVAR = "Will"
myvar2 = "Will"
Ilegal variable names:
2myvar = "Kim"
my-var = "Kim"
my var = "Kim"
- Techniques to make it more readeable
- Camel Case
Each word, except the first, starts with a capital letter:
myVariableName = "David"
- Pascal Case
Each word starts with a capital letter:
MyVariableName = "John"
- Snake Case
my_variable_name = "Berry"
'Python' 카테고리의 다른 글
[Basic Grammar] Python Numbers (0) | 2023.10.20 |
---|---|
[Basic Grammar] Python Data Types (0) | 2023.10.20 |
[Basic Grammar] Python Variables: Output Variables (0) | 2023.10.19 |
[Basic Grammar] Python Variables: Assign Multiple Values (0) | 2023.10.19 |
[Basic Grammar] Python Variables (0) | 2023.10.15 |