Welcome young Jedi! In this Kata you must create a function that takes an amount of US currency in `cents`, and returns a dictionary/hash which shows the least amount of coins used to make up that amount. The only coin denominations considered in this exercise are: `Pennies (1¢), Nickels (5¢), Dimes (10¢) and Quarters (25¢)`.
Therefor the dictionary returned should contain exactly 4 key/value pairs.

Notes:

* If the function is passed either 0 or a negative number, the function should return the dictionary with all values equal to 0.
* If a float is passed into the function, its value should be be rounded down, and the resulting dictionary should never contain fractions of a coin.


## Examples
```
loose_change(56)    ==>  {'Nickels': 1, 'Pennies': 1, 'Dimes': 0, 'Quarters': 2}
loose_change(-435)  ==>  {'Nickels': 0, 'Pennies': 0, 'Dimes': 0, 'Quarters': 0}
loose_change(4.935) ==>  {'Nickels': 0, 'Pennies': 4, 'Dimes': 0, 'Quarters': 0}
```

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Mathematics

Starter code: def loose_change(cents):
	

Solutions:
import math

def loose_change(cents):
	if cents < 0:
		cents = 0
	cents = int(cents)
	change = {}
	change['Quarters'] = cents // 25
	cents = cents % 25
	change['Dimes'] = cents // 10
	cents = cents % 10
	change['Nickels'] = cents // 5
	cents = cents % 5
	change['Pennies'] = cents
	return change


CHANGES = (('Quarters', 25), ('Dimes', 10), ('Nickels', 5), ('Pennies', 1))

def loose_change(cents):
	(cents, changed) = (max(0, int(cents)), {})
	for (what, value) in CHANGES:
		(n, cents) = divmod(cents, value)
		changed[what] = n
	return changed


def loose_change(cents):
	coins = {'Nickels': 0, 'Pennies': 0, 'Dimes': 0, 'Quarters': 0}
	if cents <= 0:
		return coins
	coins['Quarters'] = cents // 25
	coins['Dimes'] = cents % 25 // 10
	coins['Nickels'] = cents % 25 % 10 // 5
	coins['Pennies'] = cents % 25 % 10 % 5 // 1
	return coins


def loose_change(cents):
	res = {}
	(res['Quarters'], cents) = divmod(cents, 25) if cents > 0 else (0, 0)
	(res['Dimes'], cents) = divmod(cents, 10)
	(res['Nickels'], cents) = divmod(cents, 5)
	(res['Pennies'], cents) = divmod(cents, 1)
	return res


def loose_change(cents):
	total_cents = 0
	denomination_list = [['Quarters', 25], ['Dimes', 10], ['Nickels', 5], ['Pennies', 1]]
	change_dict = {}
	for denomination in denomination_list:
		coin_count = 0
		while total_cents + denomination[1] <= cents:
			total_cents += denomination[1]
			coin_count += 1
		change_dict[denomination[0]] = coin_count
	return change_dict


def loose_change(cents):
	cents = max(cents, 0)
	d = {}
	for (coin, n) in (('Quarters', 25), ('Dimes', 10), ('Nickels', 5), ('Pennies', 1)):
		(d[coin], cents) = divmod(cents, n)
	return d


def loose_change(cents):
	if cents <= 0:
		cents = 0
	return {'Nickels': int(cents) % 25 % 10 // 5, 'Pennies': int(cents) % 5, 'Dimes': int(cents) % 25 // 10, 'Quarters': int(cents) // 25}


from math import floor

def loose_change(cents):
	change_dict = {}
	cents = 0 if cents < 0 else floor(cents)
	change_dict['Quarters'] = cents // 25
	cents %= 25
	change_dict['Dimes'] = cents // 10
	cents %= 10
	change_dict['Nickels'] = cents // 5
	cents %= 5
	change_dict['Pennies'] = cents
	return change_dict


def loose_change(cents):
	cents = max(int(cents), 0)
	changes = {}
	for (i, n) in enumerate((25, 10, 5, 1)):
		units = ['Quarters', 'Dimes', 'Nickels', 'Pennies']
		changes[units[i]] = cents // n
		cents = cents % n
	return changes