Editor (Python program/code 🐍) |
Console (input/output) |
import matplotlib.pyplot as plt
import pandas as pd
age = [5.5, 6,
7, 7.5]
height = [120.5, 125, 132.5, 135]
Kunsel = pd.DataFrame(age, columns=['Age'])
Kunsel['Height'] = height
print(Kunsel)
print("Kunsel's min height is", Kunsel.Height.min(), "cm.")
print("Kunsel's max height is", Kunsel.Height.max(), "cm.")
Kunsel.plot.line(
x = 'Age', y = 'Height',
title = "Kunsel's height vs. age",
color = 'purple',
ylabel = 'Height (cm)',
style = '.-')
plt.show()
|
Out:
Age Height
0 5.5 120.5
1 6.0 125.0
2 7.0 132.5
3 7.5 135.0
Out: Kunsel's min height is 120.5 cm.
Out: Kunsel's max height is 135 cm.
In:
|
|
To run the height vs. age code with trinket, delete code from main.py (below) & paste in code from above. Then select ' Run'.
Make sure that there is not a blank space at the beginning of the first line. Note: the editor & console above are not active.
The Spyder Python environment is an alternative. You can type and run code, but not paste.
Click the Spyder icon to open a virtual desktop (may take some time), then double click the Spyder icon on that desktop.
|