web_programming.get_top_billionaires

CAUTION: You may get a json.decoding error. This works for some of us but fails for others.

Attributes

API_URL

LIMIT

TODAY

Functions

display_billionaires(→ None)

Display Forbes real-time billionaires in a rich table.

get_forbes_real_time_billionaires(→ list[dict[str, ...)

Get the top 10 real-time billionaires using Forbes API.

years_old(→ int)

Calculate the age in years based on the given birth date. Only the year, month,

Module Contents

web_programming.get_top_billionaires.display_billionaires(forbes_billionaires: list[dict[str, int | str]]) None

Display Forbes real-time billionaires in a rich table.

Args:

forbes_billionaires (list): Forbes top 10 real-time billionaires

web_programming.get_top_billionaires.get_forbes_real_time_billionaires() list[dict[str, int | str]]

Get the top 10 real-time billionaires using Forbes API.

Returns:

List of top 10 realtime billionaires data.

web_programming.get_top_billionaires.years_old(birth_timestamp: int, today: datetime.date | None = None) int

Calculate the age in years based on the given birth date. Only the year, month, and day are used in the calculation. The time of day is ignored.

Args:

birth_timestamp: The date of birth. today: (useful for writing tests) or if None then datetime.date.today().

Returns:

int: The age in years.

Examples: >>> today = date(2024, 1, 12) >>> years_old(birth_timestamp=datetime(1959, 11, 20).timestamp(), today=today) 64 >>> years_old(birth_timestamp=datetime(1970, 2, 13).timestamp(), today=today) 53 >>> all( … years_old(datetime(today.year - i, 1, 12).timestamp(), today=today) == i … for i in range(1, 111) … ) True

web_programming.get_top_billionaires.API_URL
web_programming.get_top_billionaires.LIMIT = 10
web_programming.get_top_billionaires.TODAY