From 48a422bf4c317a79f25d872abda4a1c8f2873d02 Mon Sep 17 00:00:00 2001 From: alexkok25 <68406648+alexkok25@users.noreply.github.com> Date: Fri, 21 Aug 2020 16:59:51 +0800 Subject: [PATCH] simple python code i hope someone can provide more sample code for other to reference. --- python | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 python diff --git a/python b/python new file mode 100644 index 000000000..c7e50fd09 --- /dev/null +++ b/python @@ -0,0 +1,46 @@ +import matplotlib.pyplot as plt + +# Assume that first line is number of book read per week for adam +X1 = [1,2,3,4,5,6,7,8,9] +Y1 = [1,7,4,7,8,4,6,0,7] +# label name +plt.plot(X1, Y1, label = "Adam") +# Assume that second line is number of book read per week for william +X2 = [1,2,3,4,5,6,7,8,9] +Y2 = [1,4,3,2,10,0,2,4,5] +# label name +plt.plot(X2, Y2, label = "William") + +# Label x +plt.xlabel('X-axis') +# Label y +plt.ylabel('Y-axis') + +# title of graph +plt.title('number of book reading per week') + +# show legend +plt.legend() +#generate the final graph +plt.show() + + +# number list +numbers = [5,3,4,2,1,0,8] + +# Sorting number +numbers.sort() + +print(numbers) + + +import pandas as pd +# assign number to a and b +data = { + 'a': [4, 7, 0, 2], + 'b': [9, 1, 6, 3] +} +# assign y-axis +c = pd.DataFrame(data, index=['1', '2', '3', '4']) +#show output +c