You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In this section we are going to learn how to represent variables in python language
3
-
It helps you store the data better so therefore we use the variable.
4
-
* Variables can be reassigned at any time
5
-
* We can also assign variables together
2
+
In this section we are going to learn how to represent variables in the Python language. Please note that variables in Python are dynamically typed, which means unlike languages like Java and C++, you don't need to specify whether the variable is a string, integer, etc.
3
+
4
+
There are some basic conveniences Python variables provide:
5
+
6
+
* Variables can be reassigned at any time
7
+
* We can also assign variables together (more on this later)
6
8
* We can also assign variables to each other
7
9
8
10
```Python
9
11
x =100
10
12
y =10
11
13
all, us , about =10, 11 ,12
12
-
#In this case we have assigned variables at once
13
-
print(x+y) #This will print 110
14
-
print(us) #TO see if it is going to print the us variable that we declared
14
+
#In this case we have assigned variables at once
15
+
print(x+y) #This will print 110
16
+
print(us) #To see if it is going to print the us variable that we declared
15
17
```
16
18
#### Variable Naming Conventions
17
-
* There are some naming variable conventions used in python language
18
-
* You cannot start a variable with a number
19
-
* Lowercase and Uppercase does matter when naming the variables
20
-
* Naming conventions are really import
21
-
* Variables should be snake_case (This makes your code looks better its just a convetion)
22
-
* Most variables are lowercase
23
-
* Upper camelcase is usually used for the classes
24
-
* Variables that start with dunder: double underscores **Dont Touch Them**
25
-
* Variables should Contain valid data types
19
+
20
+
There are some naming variable conventions used in python language:
21
+
22
+
* A variable name cannot start with a number. For instance, if you write something like `2morrow = 'day after'`, Python will complain loudly.
23
+
* Variable names are case-sensitive. `total` and `Total` are _not_ the same variable.
24
+
* Variables should be snake_case (that is, small caps with words joined by underscores). Please note that this is just a convention in the Python community, as we believe this lends to clearer, easily readable code.
25
+
* Camelcase is usually used for class names. For instance, `RssReader`.
26
+
* There are some predefined variables in Python that start with dunder (double underscores), for example, `__dir__`. **Don't Touch Them. Ever.**
0 commit comments