UV index readings

from bisect import bisect from random import uniform from calendar import day_name import numpy as np weekdays = list(day_name) lower_boundaries = [0, 3, 5, 7, 10] uv_index_labels = np.array(['Low', 'Moderate', 'High', 'Very high', 'Extreme']) protective_measures = np.array([ 'Apply SPF 15 sunscreen', 'Wear a hat and apply SPF 15 sunscreen', 'Wear a hat, protective clothing, and sunglasses with UV-A and UV-B protections; apply SPF 15+ sunscreen', 'Wear a hat, protective clothing, and sunglasses; stay in shady areas, and apply SPF 15+ sunscreen', 'Wear a hat, protective clothing, and sunglasses; use SPF 15+ sunscreen; avoid being in sun between 10am and 4pm' ]) week_uv_vals = [uniform(0, 12) for i in range(7)] indices = [bisect(lower_boundaries, value) - 1 for value in week_uv_vals] for week_day, val, label, how_to_protect in zip(weekdays, week_uv_vals, uv_index_labels[indices], protective_measures[indices]): print("%s -> UV %.4f: %s -> %s" % (week_day, val, label, how_to_protect)) """ Monday -> UV 9.8074: Very high -> Wear a hat, protective clothing, and sunglasses; stay in shady areas, and apply SPF 15+ sunscreen Tuesday -> UV 4.9051: Moderate -> Wear a hat and apply SPF 15 sunscreen Wednesday -> UV 6.5723: High -> Wear a hat, protective clothing, and sunglasses with UV-A and UV-B protections; apply SPF 15+ sunscreen Thursday -> UV 6.6383: High -> Wear a hat, protective clothing, and sunglasses with UV-A and UV-B protections; apply SPF 15+ sunscreen Friday -> UV 1.2166: Low -> Apply SPF 15 sunscreen Saturday -> UV 6.9749: High -> Wear a hat, protective clothing, and sunglasses with UV-A and UV-B protections; apply SPF 15+ sunscreen Sunday -> UV 4.3295: Moderate -> Wear a hat and apply SPF 15 sunscreen """