כותבים בעורך שבכל תרגיל, לוחצים הרצה כדי לראות פלט, ובדיקה כדי שהבודק האוטומטי יבדוק. אפשר גם לעבוד ב-VS Code. ההתקדמות נשמרת.Write in each exercise's editor, press Run to see output and Check for the automatic checker. You can also work in VS Code. Progress is saved.
חימום: 3 שאלותWarm-up: 3 questions
תרגיליםExercises
תרגילExercise 1
גרף טמפרטורותA temperature chart
ציירו גרף קו של הטמפרטורות לפי יום, עם כותרת Week temperatures, תווית °C לציר y, ונקודות (marker="o"). שמרו ל-temps.png.
Draw a line chart of temperatures by day, with the title Week temperatures, a °C y-label, and dots (marker="o"). Save to temps.png.
איך הפלט אמור להיראות?What should the output look like?
מדף, צעד 25: גרף קריאה חודשיShelf, step 25: a monthly reading chart
פרויקט מלווהCompanion project
כתבו reading_chart(books, path) שמקבלת רשימת מילונים עם month ו-pages, מסכמת עמודים לפי חודש (בסדר Jan עד Jun, 0 לחודש בלי קריאה), מציירת עמודות עם ערכים, מדגישה את החודש הטוב ביותר, שומרת ל-path ומחזירה את שם החודש הטוב.
Write reading_chart(books, path) taking a list of dicts with month and pages, totalling pages per month (in order Jan to Jun, 0 for a month without reading), drawing bars with values, highlighting the best month, saving to path and returning the best month's name.
איך הפלט אמור להיראות?What should the output look like?
Feb
chart.py
רמזHint 1:totals = {m: 0 for m in MONTHS} ואז לולאה שמוסיפה.totals = {m: 0 for m in MONTHS} then a loop that adds.
צרו Figure עם 3 גרפים בשורה (plt.subplots(1, 3)): עמודות של ספרים לפי סופר (מ-Counter), היסטוגרמה של עמודים, ופיזור של עמודים מול דירוג. לכל גרף כותרת. החזירו מ-dashboard(books) את ה-Figure.
Create a Figure with 3 charts in a row (plt.subplots(1, 3)): bars of books per author (from Counter), a histogram of pages, and a scatter of pages against rating. Each chart gets a title. Return the Figure from dashboard(books).
איך הפלט אמור להיראות?What should the output look like?
3 ['Books per author', 'Pages', 'Pages vs rating']
main.py
רמזHint 1:from collections import Counter; c = Counter(b["author"] for b in books)from collections import Counter; c = Counter(b["author"] for b in books)
רמזHint 2:a, b, c = axes ואז מציירים על כל אחד.a, b, c = axes then draw on each.
כתבו moving_avg(values, k) שמחזירה ממוצע נע של k ערכים (רשימה קצרה ב-k-1 מהמקור, מעוגל ל-1), וציירו גם את הנתונים המקוריים (נקודות אפורות) וגם את הממוצע הנע (קו בולט) על אותו גרף, עם מקרא.
Write moving_avg(values, k) returning a k-value moving average (a list k-1 shorter than the input, rounded to 1), and draw both the raw data (grey dots) and the moving average (a bold line) on the same chart, with a legend.
איך הפלט אמור להיראות?What should the output look like?
[35.0, 31.7, 51.7, 40.0, 51.7, 45.0]
main.py
רמזHint 1:[round(sum(values[i:i + k]) / k, 1) for i in range(len(values) - k + 1)][round(sum(values[i:i + k]) / k, 1) for i in range(len(values) - k + 1)]
רמזHint 2:ה-x של הממוצע מתחיל ב-k-1.The average's x starts at k-1.