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
-[Coursera - Python for Everybody](https://www.coursera.org/specializations/python)
183
+
184
+
185
+
### Learning more AI and ML
186
+
187
+
Python is one of the most popular languages for machine learning and artificial intelligence. If you are interested in learning more about these topics, we recommend the following resources as good starting points:
188
+
189
+
-[Coursera - Machine Learning by Andrew Ng](https://www.coursera.org/learn/machine-learning)
190
+
-[fast.ai - Practical Deep Learning for Coders](https://course.fast.ai/)
191
+
192
+
193
+
### Datasets for more practice
194
+
195
+
There are many websites that aggregate interesting datasets that you can use to practice your Python skills. Here are a few popular ones:
-[Coursera - Python for Everybody](https://www.coursera.org/specializations/python)
57
+
58
+
59
+
### Learning more AI and ML
60
+
61
+
Python is one of the most popular languages for machine learning and artificial intelligence. If you are interested in learning more about these topics, we recommend the following resources as good starting points:
62
+
63
+
-[Coursera - Machine Learning by Andrew Ng](https://www.coursera.org/learn/machine-learning)
64
+
-[fast.ai - Practical Deep Learning for Coders](https://course.fast.ai/)
65
+
66
+
67
+
### Datasets for more practice
68
+
69
+
There are many websites that aggregate interesting datasets that you can use to practice your Python skills. Here are a few popular ones:
Copy file name to clipboardExpand all lines: lessons/02_variables.qmd
+10-34Lines changed: 10 additions & 34 deletions
Original file line number
Diff line number
Diff line change
@@ -69,7 +69,7 @@ When creating variables in Python, there are some rules and guidelines that you
69
69
There is an [official Python style guide](https://peps.python.org/pep-0008/) that has much more detailed guidelines.
70
70
:::
71
71
72
-
If we would like to see the value of a variable we have created, we can use the the `print()` function:
72
+
If we would like to see the value of a variable we have created, we can call the variable name:
73
73
74
74
```{python}
75
75
#| label: show_my_number
@@ -87,28 +87,23 @@ Another way you can print a variable is by putting it within a `print()` functio
87
87
print(my_number)
88
88
```
89
89
90
-
Putting variables within `print()` function can be very helpful in case you want to inspect multiple variables. We will see this shortly. You can also add text around a variable within the `print()` function:
90
+
We can also print entire messages that include variables by putting the variable within the `print()` function. When we add text around a variable, it automatically adds spaces on either side of that variable inside the `print()` function.
91
91
92
92
```{python}
93
93
#| label: text_within_print
94
94
# Added text within the print function
95
95
print('I want to remember', my_number, 'for later use.')
96
96
```
97
97
98
-
::: {.callout-note}
99
-
# The `print()` function
100
-
You can see that when we add text around a variable, it automatically adds spaces on either side of that variable inside the `print()` function.
101
-
:::
102
-
103
-
Let's go ahead and create a second number that we are interested in:
98
+
Now let us create a second variable that we are interested in. We can assign it a different value and continue to investigate variables and the `print()` fucntion.
104
99
105
100
```{python}
106
101
#| label: create_variable_2
107
102
# Creating a second variable called your_number
108
103
your_number = 8.5
109
104
```
110
105
111
-
We can use the `print()` function to see the values of these variables:
106
+
Putting variables within `print()` function can be very helpful in case you want to inspect _multiple variables_. We can use the `print()` function to see the values of these variables:
112
107
113
108
```{python}
114
109
#| label: multiple_variable_within_print
@@ -131,7 +126,7 @@ Do you notice that it only has the output from `your_number`? This is because wi
131
126
132
127
```{python}
133
128
#| label: with_print
134
-
# Print my number
129
+
# Print my_number
135
130
print(my_number)
136
131
137
132
# Print your_number
@@ -147,6 +142,7 @@ f-strings (formatted string literals) are a concise way to build strings (text v
147
142
# f-string Example
148
143
print(f'I want to remember {my_number} and {your_number}')
149
144
```
145
+
150
146
:::
151
147
152
148
You can carry out basic arithmetic using variables. For example, if we wanted to add `my_number` and `your_number`, we could do that with:
@@ -252,6 +248,7 @@ difference = a - b
252
248
#| echo: false
253
249
print('The difference of', a, 'and', b, 'is', difference)
254
250
```
251
+
255
252
:::
256
253
257
254
## Types of variables
@@ -290,30 +287,9 @@ Integers are whole numbers and floats are numbers with decimals. Both of these d
290
287
5 + 3.14
291
288
```
292
289
293
-
::: {.callout-note collapse="true"}
294
-
# You do not always have to `print()` your variables
295
-
You can directly see the output for a variable to if you run a cell and the variable is the last line in the code chunk. However, this will ony work for seeing on variable at a time, so if you wanted to see two variables as the same time, we would have to use the print function. For example:
296
-
297
-
```{python}
298
-
#| label: print_example_1
299
-
our_sum
300
-
my_number
301
-
```
302
-
303
-
versus
304
-
305
-
```{python}
306
-
#| label: print_example_2
307
-
print(our_sum)
308
-
print(my_number)
309
-
```
310
-
311
-
:::
312
-
313
-
314
290
### Strings
315
291
316
-
Strings are a data type that can hold a sequence of characters. Strings are denoted by wrapping the string in either single- or double-quotes and either is acceptable.
292
+
Strings are a data type that can hold a sequence of characters. Strings are denoted by wrapping the string in either single(`''`)- or double-quotes(`""`). Both are allowed in Python.
If we right click on some empty space within the JupyterLab interface, we can open up the `Variable Inspector`. This is a helpful tool to see all of the variables that you have created and their data types.
Options after right-clicking an empty spot within JupyterLab.
451
427
:::
452
428
453
-
Once we open up the `Variable Inspector`, a new tab will open. From this tab, we can see all of the variables that we have created, their data types and their values. This is a useful resource to quickly check what variables you have created and what they contain, especially if you have created many variables and cannot recall what each are.
429
+
Once we open up the Variable Inspector, a new tab will open. From this tab, we can see all of the variables that we have created, their data types and their values. This is a useful resource to quickly check what variables you have created and what they contain, especially if you have created many variables and cannot recall what each are.
0 commit comments