From 8ca991e3d0321b7310214366282344d3a586760d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E4=BC=9F=E6=B3=B0?= <2509165006@student.example.com> Date: Mon, 6 Jul 2026 14:24: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_3.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 q4/q4_3a/q4_3.py diff --git a/q4/q4_3a/q4_3.py b/q4/q4_3a/q4_3.py new file mode 100644 index 0000000..aa4f820 --- /dev/null +++ b/q4/q4_3a/q4_3.py @@ -0,0 +1,15 @@ +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') \ No newline at end of file