- Create conda environment:
$ conda create --name 4thBrain python=3.8
$ conda activate 4thBrain
- pandas (will install numpy)
Do not be the person who has practiced 10,000 things once, but be the person who has practiced one thing 10,000 times.
— Intentionally misquoting Bruce Lee
Find out if each of the following is either an acceptable or not acceptable Python identifier.
Do this by trying to assign them as an identifier for a variable.
If you get a SyntaxError: can't assign to operator
, fix the error by changing the identifier.
- sumTotal
- sumtotal
- sum-total
- sum total
# Solutions | |
sumTotal = 42 # Valid | |
# sum-total = 42 # Invalid. Dashes are a no-no. | |
sum_total = 42 | |
# sum total = 42 # Invalid. Spaces are a no-no. White space is often meaningful in Python. | |
sum_total = 42 |
What | How |
---|---|
Fix Unicode encoding errors | import ftfy ftfy.fix_text('✔ No problems') |
Remove specific words | s = s.replace("foo", "") |
Remove punctuation | import string s = s.translate(str.maketrans('', '', string.punctuation)) |
Remove hyperlinks | import re s = re.sub(r"https?://\S+", "", s) |
"""Check for 3rd party package, if not present, pip install it. | |
This is potentially dangerous code. It should only be used for educational purposes. | |
Defining a requirements.txt is one of the much better options. | |
""" | |
from importlib import import_module | |
module_name = 'pytest' |
Download the wheel called tensorflow-2.4.1-py3-none-any.whl
located at this public google drive link:
drive.google.com/drive/folders/1oSipZLnoeQB0Awz8U68KYeCPsULy_dQ7
Assuming you downloaded the wheel to your Downloads folder, install it with pip:
$ pip install ~/Downloads/tensorflow-2.4.1-py3-none-any.whl --user
Test that it works with ipython
at the command line: