136 2108 0965
136 2108 0965
1039900924
1039900924@qq.com
The total cost of a new car is determined by the total number of components (C) and the cost per component (P). The formula to calculate the total cost (T) is given by:
T = C × P
To solve this problem, you need to write a function in Python that calculates the total cost based on the number of components and the cost per component.
Certainly! Here is a simple Python function that takes the number of components (C) and the cost per component (P) as inputs and returns the total cost (T):
def calculate_total_cost(number_of_components, cost_per_component):
total_cost = number_of_components * cost_per_component
return total_cost
# Example usage:
number_of_components = 100
cost_per_component = 25
total_cost = calculate_total_cost(number_of_components, cost_per_component)
print(fThe total cost for the car is: {total_cost})
This function `calculate_total_cost` will multiply the number of components by the cost per component to find the total cost, and then it returns that value. The example usage shows how to call this function with specific values and print the result.