# Set up the exercise
import math
from learntools.core import binder
binder.bind(globals())
from learntools.intro_to_programming.ex2 import *
print('Setup complete.')

"""
Explanation: In the tutorial, you learned about functions. In this exercise, you'll write some of your own!
Set up the notebook
Run the next code cell without changes to set up the notebook.
End of explanation
"""


# TODO: Complete the function
def get_expected_cost(beds, baths):
    value = ____
    return value

# Check your answer 
q1.check()

#%%RM_IF(PROD)%%
# Complete the function
def get_expected_cost(beds, baths):
    value = 80000 + 30000 * beds + 10000 * baths
    return value

q1.assert_check_passed()

# Uncomment to see a hint
#_COMMENT_IF(PROD)_
q1.hint()

# Uncomment to view the solution
#_COMMENT_IF(PROD)_
q1.solution()

"""
Explanation: Question 1
In the House Prices - Advanced Regression Techniques competition, you need to use information like the number of bedrooms and bathrooms to predict the price of a house.  Inspired by this competition, you'll write your own function to do this.
In the next code cell, create a function get_expected_cost() that has two arguments:
- beds - number of bedrooms 
- baths - number of bathrooms
It should return the expected cost of a house with that number of bedrooms and bathrooms.  Assume that:
- the expected cost for a house with 0 bedrooms and 0 bathrooms is 80000.
- each bedroom adds 30000 to the expected cost
- each bathroom adds 10000 to the expected cost.
For instance, 
- a house with 1 bedroom and 1 bathroom has an expected cost of 120000, and 
- a house with 2 bedrooms and 1 bathroom has an expected cost of 150000.
End of explanation
"""


# TODO: Use the get_expected_cost function to fill in each value
option_one = ____
option_two = ____
option_three = ____
option_four = ____

print(option_one)
print(option_two)
print(option_three)
print(option_four)

# Check your answer
q2.check()

#%%RM_IF(PROD)%%
# Use the get_expected_cost function to fill in each value
option_one = get_expected_cost(2, 3)
option_two = get_expected_cost(3, 2)
option_three = get_expected_cost(3, 3)
option_four = get_expected_cost(3, 4)

print(option_one)
print(option_two)
print(option_three)
print(option_four)

q2.assert_check_passed()

# Uncomment to see a hint
#_COMMENT_IF(PROD)_
q2.hint()

# Uncomment to view the solution
#_COMMENT_IF(PROD)_
q2.solution()

"""
Explanation: Question 2
You are thinking about buying a home and want to get an idea of how much you will spend, based on the number of bedrooms and bathrooms.  You are trying to decide between four different options:
- Option 1: house with two bedrooms and three bathrooms
- Option 2: house with three bedrooms and two bathrooms
- Option 3: house with three bedrooms and three bathrooms
- Option 4: house with three bedrooms and four bathrooms
Use the get_expected_cost() function you defined in question 1 to set option_1, option_2, option_3, and option_4 to the expected cost of each option.
End of explanation
"""


# TODO: Finish defining the function
def get_cost(sqft_walls, sqft_ceiling, sqft_per_gallon, cost_per_gallon):
    cost = ____
    return cost

# Check your answer
q3.check()

#%%RM_IF(PROD)%%
def get_cost(sqft_walls, sqft_ceiling, sqft_per_gallon, cost_per_gallon):
    total_sqft = sqft_walls + sqft_ceiling
    gallons_needed = total_sqft / sqft_per_gallon
    cost = cost_per_gallon * gallons_needed
    return cost

q3.assert_check_passed()

# Uncomment to see a hint
#_COMMENT_IF(PROD)_
q3.hint()

# Uncomment to view the solution
#_COMMENT_IF(PROD)_
q3.solution()

"""
Explanation: Question 3
You're a home decorator, and you'd like to use Python to streamline some of your work.  Specifically, you're creating a tool that you intend to use to calculate the cost of painting a room.
As a first step, define a function get_cost() that takes as input:
- sqft_walls = total square feet of walls to be painted
- sqft_ceiling = square feet of ceiling to be painted
- sqft_per_gallon = number of square feet that you can cover with one gallon of paint
- cost_per_gallon = cost (in dollars) of one gallon of paint
It should return the cost (in dollars) of putting one coat of paint on all walls and the ceiling.  Assume you can buy the exact amount of paint that you need, so you can buy partial gallons (e.g., if you need 7.523 gallons, you can buy that exact amount, instead of needing to buy 8 gallons and waste some paint).  Do not round your answer.
End of explanation
"""


# TODO: Set the project_cost variable to the cost of the project
project_cost = ____

# Check your answer
q4.check()

#%%RM_IF(PROD)%%
# Set the project_cost variable to the cost of the project
project_cost = get_cost(432, 144, 400, 15) 

q4.assert_check_passed()

# Uncomment to see a hint
#_COMMENT_IF(PROD)_
q4.hint()

# Uncomment to view the solution
#_COMMENT_IF(PROD)_
q4.solution()

"""
Explanation: Question 4
Use the get_cost() function you defined in Question 3 to calculate the cost of applying one coat of paint to a room with:
- 432 square feet of walls, and
- 144 square feet of ceiling.
Assume that one gallon of paint covers 400 square feet and costs $15.  As in Question 3, assume you can buy partial gallons of paint.  Do not round your answer.
End of explanation
"""


test_value = 2.17

rounded_value = math.ceil(test_value)
print(rounded_value)

"""
Explanation: 🌶️ Question 5
Now say you can no longer buy fractions of a gallon.  (For instance, if you need 4.3 gallons to do a project, then you have to buy 5 gallons of paint.)
With this new scenario, you will create a new function get_actual_cost that uses the same inputs and calculates the cost of your project.
One function that you'll need to use to do this is math.ceil().  We demonstrate usage of this function in the code cell below.  It takes as a number as input and rounds the number up to the nearest integer.  
Run the next code cell to test this function for yourself.  Feel free to change the value of test_value and make sure math.ceil() returns the number you expect.
End of explanation
"""


def get_actual_cost(sqft_walls, sqft_ceiling, sqft_per_gallon, cost_per_gallon):
    cost = ____
    return cost

# Check your answer
q5.check()

#%%RM_IF(PROD)%%
def get_actual_cost(sqft_walls, sqft_ceiling, sqft_per_gallon, cost_per_gallon):
    total_sqft = sqft_walls + sqft_ceiling
    gallons_needed = total_sqft / sqft_per_gallon
    gallons_to_buy = math.ceil(gallons_needed)
    cost = cost_per_gallon * gallons_to_buy
    return cost

q5.assert_check_passed()

# Uncomment to see a hint
#_COMMENT_IF(PROD)_
q5.hint()

# Uncomment to view the solution
#_COMMENT_IF(PROD)_
q5.solution()

"""
Explanation: Use the next code cell to define the function get_actual_cost().  You'll need to use the math.ceil() function to do this.
When answering this question, note that it's completely valid to define a function that makes use of another function.  For instance, we can define a function round_up_and_divide_by_three that makes use of the math.ceil function:
def round_up_and_divide_by_three(num):
    new_value = math.ceil(num)
    final_value = new_value / 3
    return final_value
End of explanation
"""


get_actual_cost(432, 144, 400, 15) 

"""
Explanation: Once your function is verified as correct, run the next code cell to calculate the updated cost of your project.
End of explanation
"""


get_actual_cost(594, 288, 400, 15) 

"""
Explanation: Say you're working with a slightly larger room.  Run the next code cell to calculate the cost of the project.
End of explanation
"""


