# Day fifteen only took twenty three days to complete, wonder how long a hundred day challenge will take to finish.

Wow, took along time to finish but I have finally done the python day fifteen code challenge out of my #hundreddaycodingchallenge. Took about three weeks, yes you heard it right... Three weeks.

Of course I could just have said it too me a day since it is meant to be a daily coding challenge but I am not very good and sometimes I get kind of distracted... not busy... distracted. With anything and everything my brain sees as being something it wants me to focus on.

This morning my brain decided to make me focus on my coding challenge so I didn't fart arse around but actually spent a good hour to make it work. It is not perfect but I am satisfied since it has worked. I even made it use another .py file to import into my main file.

##### The main.py file
``````from data import resources, MENU

machine = False
money = 0

def print_report():
"""Report for resources"""
print(
f"Water: {resources['water']}ml\nMilk: {resources['milk']}ml\nCoffee: {resources['coffee']}g\nMoney: \${money}")

def check_resources(choice):
"""Enough to make coffee check function"""
print("Not enough to make coffee. Money refunded.")
return False
elif choice != 'espresso' and MENU[choice]['ingredients']['milk'] > resources['milk']:
print("Not enough to make coffee. Money refunded.")
return False
print("Not enough to make coffee. Money refunded.")
return False
else:
# make_coffee(choice)
return True

def change(coins, choice):
""""Give Change"""

def make_coffee(choice):
"""Lets make some coffee and reduce our supplies"""
if choice == 'espresso':
resources['water'] -= 50
resources['coffee'] -= 18
elif choice == 'latte':
resources['water'] -= 200
resources['coffee'] -= 24
resources['milk'] -= 150
elif choice == 'cappuccino':
resources['water'] -= 250
resources['coffee'] -= 24
resources['milk'] -= 100
print(f"Here is {change(payment, choice)} in change.")

while not machine:
selection = input("What would you like? (espresso/latte/cappuccino): ")
if selection == 'report':
print_report()
elif selection == 'end':
machine = True
else:
q = int(input("how many quarters?: ")) * 0.25
d = int(input("how many dimes?: ")) * 0.10
n = int(input("how many nickels?: ")) * 0.05
p = int(input("how many pennies?: ")) * 0.01
payment = q + d + n + p

if selection == key and payment > MENU[selection]["cost"]:
if check_resources(selection):
make_coffee(selection)

print("Sorry that's not enough money. Money refunded.")
``````
##### The data.py file
``````MENU = {
"espresso": {
"ingredients": {
"water": 50,
"coffee": 18,
},
"cost": 1.5,
},
"latte": {
"ingredients": {
"water": 200,
"milk": 150,
"coffee": 24,
},
"cost": 2.5,
},
"cappuccino": {
"ingredients": {
"water": 250,
"milk": 100,
"coffee": 24,
},
"cost": 3.0,
}
}

resources = {
"water": 300,
"milk": 200,
"coffee": 100,
}
``````

Currently now just watching the Udemy course video to see the teachers version. They outlined as with all of the last 14 days prior to this one of having multiple ways to code anything and having difference between mine and theirs does not mean I am wrong. It just means I need more practice.

Practice makes permanent.

A karateka friend told me the quote a long time ago and it has stuck with me. Repetitive exercises requires you to take your time and make sure you work at things methodically so your memory is as close to perfection each repetition. Or something like that.

If you enjoy my posts, and would like to support me with more than an upvote, thank you very much, see my links below.

Browse merch here.

Geomining to a better future referral link if you decide to support me

Shameless referral link to space game

My post favourite, by me.

0
0
0.000