Intermediate Python for Developers
George Boorman
Curriculum Manager, DataCamp
# Sales variable sales = [125.97, 84.32, 99.78, 154.21, 78.50, 83.67, 111.13]
# Calculating average sales average_sales = sum(sales) / len(sales)
# Rounding the results rounded_average_sales = round(average_sales, 2) print(rounded_average_sales)
105.37
# Create a custom function to calculate the average value
def
# Create a custom function to calculate the average value
def average
# Create a custom function to calculate the average value
def average(
# Create a custom function to calculate the average value
def average(values)
# Create a custom function to calculate the average value
def average(values):
# Create a custom function to calculate the average value
def average(values):
# Calculate the average
average_value = sum(values) / len(values)
# Create a custom function to calculate the average value
def average(values):
# Calculate the average
average_value = sum(values) / len(values)
# Round the results
rounded_average = round(average_value, 2)
# Create a custom function to calculate the average value def average(values): # Calculate the average average_value = sum(values) / len(values) # Round the results rounded_average = round(average_value, 2)
# Return an output return
# Create a custom function to calculate the average value
def average(values):
# Calculate the average
average_value = sum(values) / len(values)
# Round the results
rounded_average = round(average_value, 2)
# Return rounded_average as an output
return rounded_average
# Create a custom function to calculate the average value
def average(values):
# Calculate the average
average_value = sum(values) / len(values)
# Return the rounded results
return round(average_value, 2)
sales = [125.97, 84.32, 99.78, 154.21, 78.50, 83.67, 111.13]
# Calculating the average average(sales)
105.37
# Calculating the average
average(sales)
105.37
# Storing average_sales
average_sales = average(sales)
print(average_sales)
105.37
Intermediate Python for Developers