Check out my new books that I just published...
Below are some quick fun little projects/tip/tricks that script or use as a one-liner from console using Python. This code does require that you have a fairly recent version of Python installed (i.e. v3.8 or higher).
Notes:
Depending on your systems configuration, to execute the python environments is generally done by typing python3 or python in the console.
If pip3 does not work try pip.
Description: Python One-liner jokes for programmers
Requirements: To use the code, you need to Install the following module. At the console type:
pip3 install pyjokes
Execute the code, type:
python3 -c "import pyjokes; print(pyjokes.get_joke())"
More Information:
Description: A Python wrapper for the Goodreads Quote API
Requirements: To use the code, you need to Install the following module. At the console type:
pip3 install quotes
Source Code: Create a file with the following code and save it (i.e. quotes.py) directory of your choice.
from quote import quote
author = 'Albert Einstein'
result = quote(author, limit=2)
print(result)
Execute the code, type:
$ python3 quotes.py
More Information:
https://pypi.org/project/quote/
One-liner trick (Bonus): This trick will allow you to run the code from the command line.
python3 -c "import quote; print(quote.quote('Steven Wright', limit=1)[0]['quote'])"
This function can have any number of parameters but, can have just one statement.
For Example:
a = lambda x, y : x*y
print(a(5, 12))
List comprehension is a syntax construction to ease the creation of a list based on existing iterable.
For Example:
a = [i for i in range(1, 10)]
Notice:
All this information is only provided purposes educational, and can change at anytime. There is no warranty of the quality of the content. So use at your own risk. I am not endorsing any products, sites, content or authors.