max python

Just another WordPress site

Display a random fact using a python module

Randfacts is a Python module that generates random facts.

There are thousands of facts built in.


pip install randfacts



import randfacts
fact = randfacts.get_fact()

When you run this you should see something like this, a random fact

The human brain cannot feel pain.

This package has a filter option to filter out potentially inappropriate facts. The filter is on by default. To disable the filter, you can just set the filter_enabled parameter to False.

import randfacts
fact = randfacts.get_fact()
filtered_fact = randfacts.get_fact(filter_enabled=False)

Running this I saw this

Medieval chastity belts are a myth. A great majority of examples now existing were made in the 18th and 19th centuries as jokes.
The catfish has over 27,000 taste buds.

If you want to access the list of facts directly, you can just import the safe_factsunsafe_facts, or all_facts lists from the randfacts module.

Leave a Comment

Your email address will not be published. Required fields are marked *

This div height required for enabling the sticky sidebar
Ad Clicks : Ad Views : Ad Clicks : Ad Views :