The following Python script compares a contrast of colored text (foreground) color against a background color. It is important to have good, high contrast. High contrast allows for easy readability and it’s easier on the eyes. This becomes more important when considering web page development to allow accessibility.
Sources
“How to calculate colour contrast” Accessibility Developer Guide (ADG*). An initiative of Access for all. Last Edited July 29, 2023. Accessed August 8, 2023. https://www.accessibility-developer-guide.com/knowledge/colours-and-contrast/how-to-calculate/
“Relative Luminance” Web Content Accessibility Guidelines (WCAG) 2.0. W3C, Inc. (World Wide Web Consortium, Inc.) Last Edited December 11, 2008. Accessed August 8, 2023. https://www.w3.org/TR/WCAG20/#relativeluminancedef
My math and calculator blog: edspi31415.blogspot.com