From bf36c767cc26a517737f5d260148e7844c9d6d6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8E=AB=E5=A2=9E?= <2509165014@student.example.com> Date: Sun, 5 Jul 2026 18:18:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6=E8=87=B3?= =?UTF-8?q?=20q4/q4=5F3b?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- q4/q4_3b/q4_3b.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 q4/q4_3b/q4_3b.py diff --git a/q4/q4_3b/q4_3b.py b/q4/q4_3b/q4_3b.py new file mode 100644 index 0000000..2e12382 --- /dev/null +++ b/q4/q4_3b/q4_3b.py @@ -0,0 +1,14 @@ +import json +import matplotlib.pyplot as plt + +movies = json.load(open('movies.json', encoding='utf-8'))['movies'] +# print(movies) +ratings = [] +durations = [] +for m in movies: + ratings.append(m['rating']) + durations.append(m['duration']) + +plt.figure(figsize=(8,5)) +plt.hist(durations, bins=5,color='blue') +plt.savefig('q4_3b_hist.png',dpi=150) \ No newline at end of file