To write a function that gives the total cost of apples in terms of the number of pounds, we can use the following linear equation:
\[ \text{Total Cost} = \text{Price per Pound} \times \text{Number of Pounds} \]
Given that the price per pound of apples is $1.25, we can define the function \( f(x) \) as follows:
def f(x):
price_per_pound = 1.25
total_cost = price_per_pound * x
return total_cost
In this function:
x
is the number of pounds of apples.price_per_pound
is set to 1.25.- The function calculates the total cost by multiplying the price per pound by the number of pounds
x
. - It returns the total cost.
You can call this function with a specific number of pounds to get the total cost, for example:
cost_for_3_pounds = f(3) # This will return 3.75