Skip to content
tryout
import pandas as pd nasdaq_df = pd.read_csv("nasdaq_data.csv") percent_changes = [] for year in nasdaq_df["year"].unique(): year_df = nasdaq_df[nasdaq_df["year"] == year] start_value = year_df.iloc[0]["value"] end_value = year_df.iloc[-1]["value"] percent_change = (end_value - start_value) / start_value percent_changes.append(percent_change) print(percent_changes)
import matplotlib.pyplot as plt
# Calculate the BMI index for a given weight and height
def bmi_index(weight, height):
bmi = weight / (height * height)
return bmi
# Test the function with some values
bmi1 = bmi_index(70, 1.75)
bmi2 = bmi_index(80, 1.70)
bmi3 = bmi_index(65, 1.80)
# Print the result
print(f"BMI 1: {bmi1:.2f}")
print(f"BMI 2: {bmi2:.2f}")
print(f"BMI 3: {bmi3:.2f}")
# Plot the BMI index of three individuals
plt.plot([1, 2, 3], [bmi1, bmi2, bmi3])
plt.xlabel('Person')
plt.ylabel('BMI')
# Plot the BMI index of three individuals with different line styles and colors
plt.plot([1, 2, 3], [bmi1, bmi2, bmi3], 'd')
plt.plot([1, 2, 3], [bmi1, bmi2, bmi3], 'go')
plt.show()