-
Notifications
You must be signed in to change notification settings - Fork 67
/
Variable_names_c2.py
51 lines (35 loc) · 1.07 KB
/
Variable_names_c2.py
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
"""
Variable Names
A variable can have a short name (like x and y) or a more descriptive name (age, carname, total_volume). 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)
"""
#Legal variable names:
myvar = "Mohan"
my_var = "Mohan"
_my_var = "Mohan"
myVar = "Mohan"
MYVAR = "Mohan"
myvar2 = "Mohan"
"""
Illegal variable names:
2myvar = "John"
my-var = "John"
my var = "John"
"""
"""
Multi Words Variable Names
Variable names with more than one word can be difficult to read.
There are several techniques you can use to make them more readable:
"""
#Camel Case
#Each word, except the first, starts with a capital letter:
myVariableName = "Mohan"
#Pascal Case
#Each words starts with capital letter ;
MyVariableName="Mohan"
#snake case
#Each word is seperated by underscore charchater
my_variable_name="Mohan"