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
Copy file name to clipboardExpand all lines: 003-Variables.md
+16-14Lines changed: 16 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -5,8 +5,9 @@ Python is a dynamically typed programming language meaning that you do not need
5
5
## How to make a variable
6
6
7
7
A variable is created by giving it a name and then assigning its contents to it with a single equals sign, for example:
8
-
<pre><code>example = "value"</code></pre>
9
-
8
+
```python
9
+
example ="value"
10
+
```
10
11
## What information can variables hold?
11
12
12
13
Variables can hold several different types of values and information, each of which will have its very own chapter in the coming series, however here they are in simple bullet form.
@@ -23,25 +24,26 @@ Variables can be called upon in order to use the values for various parts of a p
23
24
## How to format a variable
24
25
25
26
Variables should stick to specific formatting rules, so that your code not only works, but can also be read by other users. To assign a variable, remember that the letters are CASE SENSITIVE. So:
26
-
27
-
<pre><code> cat = "paws" </code></pre>
28
-
27
+
```python
28
+
cat ="paws"
29
+
```
29
30
is completely different to:
30
-
31
-
<pre><code> Cat = "paws" </code></pre>
32
-
31
+
```python
32
+
Cat ="paws"
33
+
```
33
34
Variables should always start with a letter, can never have an empty space and can contain numbers. If spaces are needed to make the variable more understandable use an underscore like this example:
34
-
35
-
<pre><code> my_first_variable = "I did it!" </code></pre>
36
-
35
+
```python
36
+
my_first_variable ="I did it!"
37
+
```
37
38
For strings, add quote marks around the string (see string chapter for more info on this.) For numbers there is no need for quotes, for example:
38
39
39
-
<pre><code>numbers = 132
40
+
```python
41
+
numbers =132
40
42
more_numbers =567
41
43
even_more_numbers =3.5632
42
44
and_again =1
43
-
string = "Strings have single or double quotes around them"</code></pre>
44
-
45
+
string ="Strings have single or double quotes around them"
0 commit comments