From da1897291a286b4e318a838d4e7d50d0d752449e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E5=AE=87=E6=99=A8?= <2509165026@student.example.com> Date: Sun, 5 Jul 2026 18:21:08 +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=5F3a?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- q4/q4_3a/q4_3a.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 q4/q4_3a/q4_3a.py diff --git a/q4/q4_3a/q4_3a.py b/q4/q4_3a/q4_3a.py new file mode 100644 index 0000000..ff6357c --- /dev/null +++ b/q4/q4_3a/q4_3a.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(ratings, bins=5,color='blue') +plt.savefig('q4_3a_hist.png',dpi=150)